<!doctype html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <title>Stiftung – Jahresbericht {{ jahr }}</title>
  <style>
    {{ css_content }}
    /* Cover page styles */
    .cover-page {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      min-height: 85vh;
      text-align: center;
    }
    .cover-logo-img { max-height: 100px; max-width: 250px; margin-bottom: 30px; }
    .cover-title h1 {
      font-size: 24pt;
      color: {{ corporate_settings.primary_color|default:"#2c3e50" }};
      margin: 0 0 10px 0;
      border-bottom: none;
    }
    .cover-title h2 {
      font-size: 18pt;
      color: {{ corporate_settings.secondary_color|default:"#3498db" }};
      margin: 0 0 5px 0;
    }
    .cover-subtitle { font-size: 12pt; color: #666; }
    .cover-meta { margin-top: 40px; font-size: 11pt; color: #555; }
    .cover-meta p { margin: 5px 0; }
    .cover-footer { margin-top: 60px; font-size: 9pt; color: #999; }
    .cover-footer p { margin: 3px 0; }
    .cover-confidential {
      margin-top: 15px !important;
      font-weight: bold;
      color: {{ corporate_settings.primary_color|default:"#2c3e50" }} !important;
      font-size: 10pt;
    }
    /* Bilanz cards */
    .bilanz-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
      margin-bottom: 20px;
    }
    .bilanz-card { border-radius: 8px; padding: 16px; text-align: center; }
    .bilanz-card.einnahmen { background: #d4edda; border: 1px solid #c3e6cb; }
    .bilanz-card.ausgaben { background: #f8d7da; border: 1px solid #f5c6cb; }
    .bilanz-card.netto-positiv { background: #d1ecf1; border: 1px solid #bee5eb; }
    .bilanz-card.netto-negativ { background: #fff3cd; border: 1px solid #ffeeba; }
    .bilanz-card .value { font-size: 1.5em; font-weight: bold; }
    .bilanz-card .label { font-size: 0.85em; margin-top: 4px; color: #555; }
    /* Status badges extra */
    .status-aktiv { background-color: #d4edda; color: #155724; }
    .status-beendet { background-color: #e2e3e5; color: #383d41; }
    .status-gekuendigt { background-color: #f8d7da; color: #721c24; }
    .status-geplant, .status-faellig { background-color: #e2e3e5; color: #383d41; }
    .status-abgeschlossen { background-color: #d4edda; color: #155724; }
    @media print {
      .no-print { display: none; }
    }
  </style>
</head>
<body>
  <!-- Aktionsleiste (nur Bildschirm, nicht Druck) -->
  <div class="no-print" style="margin-bottom: 20px; display: flex; align-items: center; gap: 12px;">
    <a href="{% url 'stiftung:bericht_list' %}" style="color: #1a4a2e;">&#8592; Berichte</a>
    <span style="color: #dee2e6;">|</span>
    <a href="{% url 'stiftung:jahresbericht_pdf' jahr=jahr %}" style="display: inline-block; padding: 8px 20px; background: #1a4a2e; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.9em; text-decoration: none; margin-right: 8px;">
      PDF herunterladen
    </a>
    <button onclick="window.print()" style="display: inline-block; padding: 8px 20px; background: #34495e; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.9em;">
      Drucken
    </button>
  </div>

  {% if show_cover %}
  {% include "berichte/cover_page.html" %}
  {% endif %}

  <!-- Kopfzeile -->
  <div class="header">
    <div class="header-content">
      <div class="header-left">
        {% if logo_base64 %}
        <img src="{{ logo_base64 }}" alt="Logo" class="logo">
        {% endif %}
        <p class="stiftung-name">{{ corporate_settings.stiftung_name }}</p>
        <p class="document-title">Jahresbericht {{ jahr }}</p>
      </div>
      <div class="header-right">
        <div class="contact-info">
          {% if corporate_settings.address_line1 %}<p>{{ corporate_settings.address_line1 }}</p>{% endif %}
          {% if corporate_settings.address_line2 %}<p>{{ corporate_settings.address_line2 }}</p>{% endif %}
          {% if corporate_settings.phone %}<p>{{ corporate_settings.phone }}</p>{% endif %}
          {% if corporate_settings.email %}<p>{{ corporate_settings.email }}</p>{% endif %}
        </div>
      </div>
    </div>
    <div class="header-info">
      Erstellt am {% now "d.m.Y" %} &middot; Berichtszeitraum: {{ jahr }}
    </div>
  </div>

  <!-- Modulare Sektionen -->
  {% include "berichte/sektionen/bilanz.html" %}
  {% include "berichte/sektionen/unterstuetzungen.html" %}
  {% include "berichte/sektionen/foerderungen.html" %}
  {% include "berichte/sektionen/grundstuecke.html" %}
  {% include "berichte/sektionen/verwaltungskosten.html" %}

  <div class="footer">
    <p>Jahresbericht {{ jahr }} &mdash; automatisch generiert von der Stiftungsverwaltung</p>
    <p>{{ corporate_settings.stiftung_name }} &middot; {{ corporate_settings.footer_text }}</p>
  </div>
</body>
</html>
