{% extends "pi_fyad/base.html" %}
{% load pi_fyad_tags %}

{% block pi_content %}

<nav aria-label="breadcrumb" class="mb-3">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="{% url 'pi_fyad:dashboard' %}">Dashboard</a></li>
        <li class="breadcrumb-item">
            <a href="{% url 'pi_fyad:character_planets' character.pk %}">{{ character.character_name }}</a>
        </li>
        <li class="breadcrumb-item active">{{ planet.planet_name }}</li>
    </ol>
</nav>

<div class="d-flex align-items-center mb-4">
    {% eve_planet_image planet.planet_type_id 64 %}
    <div class="ms-3">
        <h3 class="mb-0">{{ planet.planet_name }}</h3>
        <span class="text-muted">
            {{ planet.solar_system_name }} ·
            {{ planet.planet_type_id|planet_type_name }} ·
            CC Level {{ planet.upgrade_level }}
        </span>
    </div>
</div>

<!-- Extractor Section -->
<div class="card mb-4">
    <div class="card-header">
        <h5 class="mb-0">
            <i class="fas fa-hard-hat me-2"></i>Extractors
            <span class="badge bg-success ms-2">{{ summary.active }} active</span>
            {% if summary.expired > 0 %}
            <span class="badge bg-danger ms-1">{{ summary.expired }} expired</span>
            {% endif %}
            {% if summary.idle > 0 %}
            <span class="badge bg-secondary ms-1">{{ summary.idle }} idle</span>
            {% endif %}
        </h5>
    </div>
    <div class="card-body">
        <div class="row">
            {% for pin in extractors %}
                {% render_extractor_card pin %}
            {% empty %}
            <div class="col-12 text-muted">No extractors installed.</div>
            {% endfor %}
        </div>
    </div>
</div>

<!-- Storage Section -->
<div class="card mb-4">
    <div class="card-header">
        <h5 class="mb-0"><i class="fas fa-warehouse me-2"></i>Storage &amp; Launchpads</h5>
    </div>
    <div class="card-body">
        <div class="row">
            {% for pin in storage_pins %}
                {% render_storage_card pin %}
            {% empty %}
            <div class="col-12 text-muted">No storage facilities.</div>
            {% endfor %}
        </div>
    </div>
</div>

<!-- Factory Section -->
<div class="card mb-4">
    <div class="card-header">
        <h5 class="mb-0"><i class="fas fa-cogs me-2"></i>Factories</h5>
    </div>
    <div class="card-body">
        {% for tier, factories in factory_tiers.items %}
            {% render_factory_group tier factories %}
        {% empty %}
        <div class="text-muted">No factories installed.</div>
        {% endfor %}
    </div>
</div>

<!-- Customs Office -->
{% if planet.customs_office %}
<div class="card mb-4">
    <div class="card-header">
        <h5 class="mb-0"><i class="fas fa-building me-2"></i>Customs Office</h5>
    </div>
    <div class="card-body">
        <table class="table table-sm mb-0">
            <tr>
                <th>Tax Rate</th>
                <td>{{ planet.customs_office.tax_rate|percentage }}</td>
            </tr>
            <tr>
                <th>Alliance Access</th>
                <td>{% if planet.customs_office.allow_alliance %}Yes{% else %}No{% endif %}</td>
            </tr>
            <tr>
                <th>Standing Access</th>
                <td>{% if planet.customs_office.allow_standings %}Yes{% else %}No{% endif %}</td>
            </tr>
        </table>
    </div>
</div>
{% endif %}

{% endblock %}
