{% load i18n %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% trans "Executive Report" %} - PX360</title>
    <style>
        @page {
            size: A4;
            margin: 2cm;
        }
        body {
            font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
            font-size: 11pt;
            line-height: 1.6;
            color: #1f2937;
        }
        .header {
            border-bottom: 3px solid #4f46e5;
            padding-bottom: 1rem;
            margin-bottom: 1.5rem;
        }
        .header h1 {
            font-size: 24pt;
            color: #4f46e5;
            margin: 0 0 0.25rem 0;
        }
        .meta {
            font-size: 10pt;
            color: #6b7280;
        }
        .section {
            margin-bottom: 1.5rem;
        }
        .section h2 {
            font-size: 14pt;
            color: #111827;
            border-left: 4px solid #4f46e5;
            padding-left: 0.5rem;
            margin-bottom: 0.75rem;
        }
        .narrative {
            background: #f3f4f6;
            padding: 1rem;
            border-radius: 6px;
            white-space: pre-line;
        }
        .item-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .item-list li {
            padding: 0.5rem 0;
            border-bottom: 1px solid #e5e7eb;
            display: flex;
            align-items: flex-start;
            gap: 0.5rem;
        }
        .item-list li:last-child {
            border-bottom: none;
        }
        .badge {
            display: inline-block;
            min-width: 1.25rem;
            height: 1.25rem;
            line-height: 1.25rem;
            text-align: center;
            border-radius: 9999px;
            font-size: 9pt;
            font-weight: bold;
            color: #fff;
            flex-shrink: 0;
        }
        .badge-green { background: #10b981; }
        .badge-red { background: #ef4444; }
        .badge-amber { background: #f59e0b; }
        .metrics-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 1rem;
        }
        .metric-box {
            flex: 1 1 30%;
            background: #f9fafb;
            border: 1px solid #e5e7eb;
            border-radius: 6px;
            padding: 0.75rem;
            text-align: center;
        }
        .metric-value {
            font-size: 16pt;
            font-weight: bold;
            color: #111827;
        }
        .metric-label {
            font-size: 9pt;
            color: #6b7280;
        }
        .footer {
            margin-top: 2rem;
            padding-top: 1rem;
            border-top: 1px solid #e5e7eb;
            font-size: 9pt;
            color: #9ca3af;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>{% trans "Executive Summary Report" %}</h1>
        <div class="meta">
            <p><strong>{% trans "Report Type" %}:</strong> {{ report.get_report_type_display }}</p>
            <p><strong>{% trans "Period" %}:</strong> {{ report.start_date }} – {{ report.end_date }}</p>
            <p><strong>{% trans "Generated" %}:</strong> {{ generated_at }} &nbsp;|&nbsp; <strong>{% trans "By" %}:</strong> {{ user.get_full_name|default:user.email }}</p>
        </div>
    </div>

    {% if narrative %}
    <div class="section">
        <h2>{% trans "AI Executive Narrative" %}</h2>
        <div class="narrative">{{ narrative }}</div>
    </div>
    {% endif %}

    {% if highlights %}
    <div class="section">
        <h2>{% trans "Key Highlights" %}</h2>
        <ul class="item-list">
            {% for item in highlights %}
            <li>
                <span class="badge badge-green">✓</span>
                <span>{{ item }}</span>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}

    {% if concerns %}
    <div class="section">
        <h2>{% trans "Key Concerns" %}</h2>
        <ul class="item-list">
            {% for item in concerns %}
            <li>
                <span class="badge badge-red">!</span>
                <span>{{ item }}</span>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}

    {% if metrics %}
    <div class="section">
        <h2>{% trans "Snapshot Metrics" %}</h2>
        <div class="metrics-grid">
            {% for key, value in metrics.items %}
            <div class="metric-box">
                <div class="metric-value">{{ value|floatformat:1 }}</div>
                <div class="metric-label">{{ key|title }}</div>
            </div>
            {% endfor %}
        </div>
    </div>
    {% endif %}

    <div class="footer">
        <p>{% trans "This report was automatically generated by the PX360 AI system." %}</p>
        <p>© {% now "Y" %} PX360 - Al Hammadi Group</p>
    </div>
</body>
</html>
