<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <title>Apercu billet - {{ event.title }}</title>
    <style>
        {% set ac = accent_color %}
        {% set inv_color = invitation_color %}
        {% set inv_title = invitation_title %}

        * { margin: 0; padding: 0; box-sizing: border-box; }
        @page { size: A4; margin: 0; }
        body {
            width: 595px;
            height: 842px;
            font-family: 'Helvetica Neue', Arial, sans-serif;
            background: #fff;
            color: #111;
            overflow: hidden;
            font-size: 11px;
        }

        /* HEADER */
        .header {
            background: {{ ac }};
            color: #fff;
            padding: 14px 28px;
            font-size: 11px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 2px;
        }

        /* MAIN CONTENT */
        .content {
            display: flex;
            min-height: 0;
        }
        .content-left {
            flex: 1;
            padding: 20px 16px 16px 28px;
            border-right: 3px solid {{ ac }};
            display: flex;
            flex-direction: column;
        }
        .content-right {
            width: 220px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #fafafa;
            overflow: hidden;
        }
        .content-right img { width: 100%; height: 100%; object-fit: contain; }
        .poster-placeholder { font-size: 9px; font-weight: 900; text-transform: uppercase; opacity: 0.15; text-align: center; }

        /* EVENT */
        .event-title { font-size: 18px; font-weight: 900; text-transform: uppercase; letter-spacing: -0.5px; line-height: 1.15; margin-bottom: 10px; }
        .info-row { display: flex; align-items: baseline; padding: 3px 0; border-bottom: 1px solid #11111110; }
        .info-row:last-child { border-bottom: none; }
        .info-label { width: 60px; flex-shrink: 0; font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; opacity: 0.4; }
        .info-value { font-size: 10px; font-weight: 700; }

        .sep { height: 3px; background: {{ ac }}; margin: 10px 0; }

        /* BILLET */
        .billet-name { font-size: 14px; font-weight: 900; text-transform: uppercase; margin-bottom: 2px; }
        .billet-price { font-size: 18px; font-weight: 900; color: {{ ac }}; margin-bottom: 8px; }
        .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; }
        .meta-label { font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; opacity: 0.4; }
        .meta-value { font-size: 9px; font-weight: 700; margin-bottom: 3px; }

        /* BADGES */
        .billet-badges { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
        .exit-badge { display: inline-block; padding: 3px 6px; font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; border: 2px solid; }
        .exit-definitive { background: #fee2e2; color: #991b1b; border-color: #991b1b; }
        .exit-libre { background: #dcfce7; color: #166534; border-color: #166534; }
        .invitation-badge { display: inline-block; padding: 3px 6px; font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; color: #fff; }

        /* QR */
        .qr-section { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; padding-top: 8px; border-top: 1px solid #11111112; }
        .qr-box { width: 110px; height: 110px; display: flex; align-items: center; justify-content: center; background: #fff; }
        .qr-text { font-size: 6px; font-weight: 900; text-align: center; color: #999; text-transform: uppercase; margin-top: 3px; }
        .ref-block { text-align: right; }
        .ref-label { font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; opacity: 0.35; }
        .ref-value { font-size: 8px; font-weight: 700; font-family: monospace; opacity: 0.55; }

        /* ORGA + DESCRIPTION */
        .orga-desc { display: flex; border-top: 3px solid {{ ac }}; font-size: 8px; }
        .orga-desc-left { flex: 1; padding: 10px 12px 10px 28px; border-right: 1px solid #eee; }
        .orga-desc-right { flex: 1; padding: 10px 28px 10px 12px; }
        .section-title { font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; color: #999; margin-bottom: 4px; }
        .section-text { font-size: 7px; color: #555; line-height: 1.4; }

        /* INFO PRATIQUES + CONDITIONS */
        .info-conditions { display: flex; border-top: 1px solid #eee; background: #fafafa; }
        .info-conditions-left { flex: 1; padding: 8px 12px 8px 28px; }
        .info-conditions-right { flex: 1; padding: 8px 28px 8px 12px; }

        /* PAYMENT */
        .payment-block { padding: 6px 28px; border-top: 1px solid #eee; background: #fafafa; }

        /* FOOTER */
        .footer { background: {{ ac }}; color: #fff; padding: 12px 28px; display: flex; align-items: center; gap: 12px; }
        .footer-logo { width: 35px; height: 35px; object-fit: contain; flex-shrink: 0; }
        .footer-org { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; }
        .footer-details { font-size: 7px; opacity: 0.7; margin-top: 1px; }
        .footer-info { flex: 1; }
        .powered { font-size: 6px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: 0.4; text-align: right; flex-shrink: 0; }
    </style>
</head>
<body>
    <!-- HEADER -->
    <div class="header">Billet Entree — {{ event.title }} — Nom du billet</div>

    <!-- CONTENT -->
    <div class="content">
        <div class="content-left">
            <div class="event-title">{{ event.title }}</div>

            <div class="info-row"><div class="info-label">Date</div><div class="info-value">{{ event.startAt|date('d/m/Y') }}</div></div>
            <div class="info-row"><div class="info-label">Horaires</div><div class="info-value">{{ event.startAt|date('H:i') }} — {{ event.endAt|date('H:i') }}</div></div>
            <div class="info-row"><div class="info-label">Lieu</div><div class="info-value">{{ event.address }}</div></div>
            <div class="info-row"><div class="info-label">Ville</div><div class="info-value">{{ event.zipcode }} {{ event.city }}</div></div>

            <div class="sep"></div>

            <div class="billet-name">Nom du billet</div>
            <div class="billet-price">00,00 &euro; HT</div>

            <div class="meta-grid">
                <div><div class="meta-label">Categorie</div><div class="meta-value">Categorie</div></div>
                <div><div class="meta-label">Date d'achat</div><div class="meta-value">{{ "now"|date('d/m/Y H:i') }}</div></div>
                <div><div class="meta-label">Acheteur</div><div class="meta-value">Prenom Nom</div></div>
                <div><div class="meta-label">E-mail</div><div class="meta-value">email@exemple.fr</div></div>
            </div>

            <div class="billet-badges">
                <div class="exit-badge exit-definitive">Sortie definitive</div>
                {% if show_invitation %}
                    <div class="invitation-badge" style="background: {{ inv_color }};">{{ inv_title }}</div>
                {% endif %}
            </div>

            <div class="qr-section">
                <div>
                    <div class="qr-box">
                        <svg viewBox="0 0 21 21" width="100" height="100" xmlns="http://www.w3.org/2000/svg">
                            <rect width="21" height="21" fill="#fff"/>
                            <g fill="#111">
                                <rect x="0" y="0" width="7" height="1"/><rect x="0" y="1" width="1" height="5"/><rect x="6" y="1" width="1" height="5"/><rect x="0" y="6" width="7" height="1"/>
                                <rect x="2" y="2" width="3" height="3"/>
                                <rect x="14" y="0" width="7" height="1"/><rect x="14" y="1" width="1" height="5"/><rect x="20" y="1" width="1" height="5"/><rect x="14" y="6" width="7" height="1"/>
                                <rect x="16" y="2" width="3" height="3"/>
                                <rect x="0" y="14" width="7" height="1"/><rect x="0" y="15" width="1" height="5"/><rect x="6" y="15" width="1" height="5"/><rect x="0" y="20" width="7" height="1"/>
                                <rect x="2" y="16" width="3" height="3"/>
                                <rect x="8" y="0" width="1" height="1"/><rect x="10" y="0" width="1" height="1"/><rect x="12" y="0" width="1" height="1"/>
                                <rect x="8" y="2" width="1" height="1"/><rect x="10" y="2" width="2" height="1"/>
                                <rect x="9" y="4" width="1" height="1"/><rect x="11" y="4" width="2" height="1"/>
                                <rect x="8" y="8" width="1" height="1"/><rect x="10" y="8" width="1" height="1"/><rect x="12" y="8" width="1" height="1"/><rect x="14" y="8" width="1" height="1"/><rect x="16" y="8" width="1" height="1"/><rect x="18" y="8" width="1" height="1"/><rect x="20" y="8" width="1" height="1"/>
                                <rect x="0" y="8" width="1" height="1"/><rect x="2" y="8" width="1" height="1"/><rect x="4" y="8" width="1" height="1"/><rect x="6" y="8" width="1" height="1"/>
                                <rect x="9" y="9" width="1" height="1"/><rect x="11" y="9" width="1" height="1"/><rect x="15" y="9" width="1" height="1"/><rect x="17" y="9" width="1" height="1"/>
                                <rect x="8" y="10" width="1" height="1"/><rect x="10" y="10" width="1" height="1"/><rect x="13" y="10" width="1" height="1"/><rect x="16" y="10" width="1" height="1"/><rect x="20" y="10" width="1" height="1"/>
                            </g>
                        </svg>
                    </div>
                    <div class="qr-text">Presentez ce QR code<br>pour valider votre ticket</div>
                </div>
                <div class="ref-block">
                    <div class="ref-label">Reference billet</div>
                    <div class="ref-value">ETICKET-XXXX-XXXX-XXXX</div>
                    <br>
                    <div class="ref-label">Commande</div>
                    <div class="ref-value">2026-03-21-1</div>
                    <br>
                    <div class="ref-label">Cle de securite</div>
                    <div class="ref-value" style="letter-spacing: 2px;">A1B2C3D4E5F6G7H8</div>
                </div>
            </div>
        </div>

        <div class="content-right">
            {% if event.eventMainPictureName %}
                <img src="{{ ('/uploads/events/' ~ event.eventMainPictureName) | imagine_filter('large') }}" alt="{{ event.title }}">
            {% else %}
                <div class="poster-placeholder">Affiche<br>evenement</div>
            {% endif %}
        </div>
    </div>

    <!-- ORGA + DESCRIPTION -->
    <div class="orga-desc">
        <div class="orga-desc-left">
            <div class="section-title">Organisateur</div>
            {% if show_logo and user.logoName %}
                <img src="{{ ('/uploads/logos/' ~ user.logoName) | imagine_filter('organizer_logo') }}" alt="Logo" style="width: 24px; height: 24px; vertical-align: middle; margin-right: 4px;">
            {% endif %}
            <span style="font-size: 10px; font-weight: 900;">{{ user.companyName ?? (user.firstName ~ ' ' ~ user.lastName) }}</span>
            {% if user.siret %}<div class="section-text">SIRET: {{ user.siret }}</div>{% endif %}
            {% if user.address %}<div class="section-text">{{ user.address }}{% if user.postalCode %}, {{ user.postalCode }}{% endif %}{% if user.city %} {{ user.city }}{% endif %}</div>{% endif %}
            {% if user.email %}<div class="section-text">{{ user.email }}</div>{% endif %}
            {% if user.phone %}<div class="section-text">{{ user.phone }}</div>{% endif %}
            {% if user.website %}<div class="section-text">{{ user.website }}</div>{% endif %}
        </div>
        <div class="orga-desc-right">
            <div class="section-title">A propos de l'evenement</div>
            {% if event.description %}
                <div class="section-text" style="max-height: 50px; overflow: hidden;">{{ event.description|striptags }}</div>
            {% endif %}
        </div>
    </div>

    <!-- INFORMATIONS PRATIQUES + CONDITIONS -->
    <div class="info-conditions">
        <div class="info-conditions-left">
            <div class="section-title" style="font-size: 8px;">Informations pratiques</div>
            <div class="section-text" style="font-size: 7px;">
                &bull; Il est recommande d'arriver en avance.<br>
                &bull; En arrivant, preparez votre billet pour accelerer les controles a l'entree.<br>
                &bull; A l'approche des controles de securite, merci de preparer vos affaires.
            </div>
        </div>
        <div class="info-conditions-right">
            <div class="section-title" style="font-size: 8px;">Conditions generales</div>
            <div class="section-text" style="font-size: 7px;">
                &bull; Billet non remboursable (art. L. 121-21-8 12&deg; C. conso.).<br>
                &bull; Revente interdite.<br>
                &bull; Infraction = annulation sans remboursement.<br>
                &bull; Force majeure : remboursement aupres de l'organisateur.<br>
                &bull; E-Ticket n'organise pas les evenements.
            </div>
        </div>
    </div>

    <!-- PAYMENT -->
    <div class="payment-block">
        <div class="section-title" style="font-size: 8px;">Details du paiement</div>
        <div class="section-text" style="font-size: 7px;">
            Methode : Carte bancaire — VISA **** 4242 &bull; Date : {{ "now"|date('d/m/Y H:i') }} &bull; Montant : 00,00 &euro; HT &bull; Commande : 2026-03-21-1
        </div>
    </div>

    <!-- FOOTER -->
    <div class="footer">
        {% if show_logo and user.logoName %}
            <img src="{{ ('/uploads/logos/' ~ user.logoName) | imagine_filter('organizer_logo') }}" alt="Logo" class="footer-logo">
        {% endif %}
        <div class="footer-info">
            <div class="footer-org">{{ user.companyName ?? (user.firstName ~ ' ' ~ user.lastName) }}</div>
            {% if user.address %}<div class="footer-details">{{ user.address }}{% if user.postalCode %}, {{ user.postalCode }}{% endif %}{% if user.city %} {{ user.city }}{% endif %}</div>{% endif %}
            {% if user.email or user.phone %}<div class="footer-details">{% if user.email %}{{ user.email }}{% endif %}{% if user.email and user.phone %} — {% endif %}{% if user.phone %}{{ user.phone }}{% endif %}</div>{% endif %}
        </div>
        <div class="powered">E-Ticket<br>by E-Cosplay</div>
    </div>
</body>
</html>
