/* ═══════════════════════════════════════════════════════════
   Design tokens
   Palette : indigo profond (tagelmust/boubou), sable chaud (désert),
   ambre (thé/épices), argile plus sombre pour les CTA — volontairement
   différente du cliché terracotta #D97757 généré par défaut.
   ═══════════════════════════════════════════════════════════ */
:root {
    --indigo: #16324A;
    --indigo-clair: #234A68;
    --sable: #F2E8D5;
    --sable-fonce: #E4D5B5;
    --ambre: #E8A33D;
    --argile: #A8492F;
    --argile-fonce: #8A3A25;
    --encre: #2A2118;
    --encre-douce: #6B5E4C;
    --blanc-papier: #FFFCF6;
    --ombre: rgba(42, 33, 24, 0.14);
    --police-affichage: 'Fraunces', serif;
    --police-corps: 'Manrope', system-ui, sans-serif;
    --police-chiffres: 'IBM Plex Mono', monospace;
}

* {
    box-sizing: border-box;
}

/* ⚠️ Règle défensive indispensable : sans elle, n'importe quelle classe qui
   définit sa propre propriété "display" (ex: .ecran-plein { display: flex })
   peut écraser l'attribut HTML "hidden" — les deux ont exactement la même
   spécificité CSS (0-0-1-0), et la règle d'auteur (la nôtre) vient après la
   feuille de style par défaut du navigateur dans la cascade, donc elle gagne.
   Cette règle avec !important force "hidden" à toujours l'emporter. */
[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--sable);
    color: var(--encre);
    font-family: var(--police-corps);
    -webkit-tap-highlight-color: transparent;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* ── En-tête ── */
.entete {
    background: var(--indigo);
    color: var(--blanc-papier);
    padding: 18px 20px 22px;
    border-radius: 0 0 22px 22px;
}

.entete-ligne-haut {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.entete-marque {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.selecteur-langue {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 3px;
}

    .selecteur-langue button {
        border: none;
        background: transparent;
        color: #B9C7D2;
        font-size: 12px;
        font-weight: 700;
        padding: 5px 10px;
        border-radius: 999px;
    }

        .selecteur-langue button.actif {
            background: var(--ambre);
            color: var(--indigo);
        }

.entete-nom {
    font-family: var(--police-affichage);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

    .entete-nom em {
        font-style: normal;
        color: var(--ambre);
    }

.entete-soustitre {
    font-size: 13px;
    color: #B9C7D2;
    letter-spacing: 0.4px;
}

.banniere-contexte {
    margin-top: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .banniere-contexte strong {
        color: var(--ambre);
    }

/* ── Sélecteur de canal ── */
.selecteur-canal {
    display: flex;
    gap: 10px;
    padding: 16px 16px 0;
}

.onglet-canal {
    flex: 1;
    padding: 12px;
    border-radius: 14px;
    border: 2px solid var(--sable-fonce);
    background: var(--blanc-papier);
    font-weight: 600;
    font-size: 14px;
    color: var(--encre-douce);
    transition: border-color 0.15s, color 0.15s;
}

    .onglet-canal.actif {
        border-color: var(--indigo);
        color: var(--indigo);
    }

/* ── Onglets catégories ── */
.onglets-categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 18px 16px 6px;
    scrollbar-width: none;
}

    .onglets-categories::-webkit-scrollbar {
        display: none;
    }

.onglet-categorie {
    flex: none;
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: var(--sable-fonce);
    color: var(--encre);
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
}

    .onglet-categorie.actif {
        background: var(--indigo);
        color: var(--blanc-papier);
    }

/* ── Grille du menu ── */
.grille-menu {
    padding: 12px 16px 120px;
    display: grid;
    gap: 12px;
}

.etat-chargement {
    text-align: center;
    color: var(--encre-douce);
    padding: 40px 0;
}

.carte-article {
    background: var(--blanc-papier);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 2px var(--ombre);
}

.article-vignette {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--sable-fonce);
}

.article-info {
    flex: 1;
    min-width: 0;
}

.article-libelle {
    font-weight: 700;
    font-size: 15.5px;
    margin: 0 0 3px;
}

.article-description {
    font-size: 12.5px;
    color: var(--encre-douce);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.article-prix {
    font-family: var(--police-chiffres);
    font-weight: 500;
    font-size: 13.5px;
    color: var(--argile);
    margin-top: 6px;
    display: block;
}

.bouton-ajouter {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--argile);
    color: white;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(168, 73, 47, 0.35);
}

    .bouton-ajouter:active {
        transform: scale(0.94);
    }

/* Stepper quantité (remplace le bouton + une fois l'article dans le panier) */
.stepper-quantite {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--sable-fonce);
    border-radius: 999px;
    padding: 4px 6px;
}

    .stepper-quantite button {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        border: none;
        background: var(--indigo);
        color: white;
        font-size: 16px;
        font-weight: 700;
    }

    .stepper-quantite span {
        font-family: var(--police-chiffres);
        font-weight: 500;
        min-width: 16px;
        text-align: center;
    }

/* ── Barre panier flottante ── */
.barre-panier {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    background: var(--indigo);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(22, 50, 74, 0.35);
    z-index: 30;
}

.barre-panier-compte {
    background: var(--ambre);
    color: var(--indigo);
    font-weight: 800;
    font-size: 13px;
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.barre-panier-texte {
    flex: 1;
    text-align: left;
    font-weight: 700;
    font-size: 14.5px;
}

.barre-panier-total {
    font-family: var(--police-chiffres);
    font-weight: 500;
}

/* ── Voile / panneaux modaux ── */
.voile {
    position: fixed;
    inset: 0;
    background: rgba(42, 33, 24, 0.45);
    z-index: 40;
}

.panneau {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--blanc-papier);
    border-radius: 22px 22px 0 0;
    padding: 20px 20px 28px;
    z-index: 41;
    animation: glisser-haut 0.22s ease-out;
}

@keyframes glisser-haut {
    from {
        transform: translateY(24px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.panneau-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

    .panneau-entete h2 {
        font-family: var(--police-affichage);
        font-size: 21px;
        margin: 0;
    }

.bouton-fermer {
    border: none;
    background: var(--sable-fonce);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 15px;
    color: var(--encre);
}

/* ── Signature visuelle : panneau panier en forme de ticket ── */
.panneau-ticket {
    border-radius: 4px 4px 0 0;
    border-top: 2px dashed var(--sable-fonce);
}

.ticket-perforation {
    height: 12px;
    background: radial-gradient(circle 6px at 12px 0, transparent 6px, var(--blanc-papier) 6.5px) repeat-x;
    background-size: 24px 12px;
}

.ticket-perforation-haut {
    margin: -20px -20px 10px;
}

.ticket-perforation-bas {
    margin: 10px -20px -28px;
    transform: scaleY(-1);
}

.liste-panier {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ligne-panier {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--sable-fonce);
}

.ligne-panier-libelle {
    flex: 1;
    font-size: 14.5px;
    font-weight: 600;
}

.ligne-panier-montant {
    font-family: var(--police-chiffres);
    font-size: 13.5px;
    color: var(--argile);
}

.champ-notes {
    margin-bottom: 14px;
}

    .champ-notes label {
        font-size: 12.5px;
        color: var(--encre-douce);
        display: block;
        margin-bottom: 4px;
    }

    .champ-notes textarea {
        width: 100%;
        border: 1px solid var(--sable-fonce);
        border-radius: 10px;
        padding: 8px 10px;
        font-family: inherit;
        font-size: 13.5px;
        resize: none;
    }

.ticket-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--police-affichage);
    font-weight: 700;
    font-size: 19px;
    padding: 14px 0 18px;
}

#totalPanierDetail {
    font-family: var(--police-chiffres);
    font-weight: 500;
    color: var(--argile);
}

/* ── Champs de formulaire (identification / réservation) ── */
.champ-label {
    display: block;
    font-size: 12.5px;
    color: var(--encre-douce);
    margin: 12px 0 4px;
}

.champ-saisie {
    width: 100%;
    border: 1px solid var(--sable-fonce);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 15px;
    font-family: inherit;
    background: var(--sable);
}

.message-erreur {
    color: var(--argile-fonce);
    background: #FBE7E1;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-top: 14px;
}

/* ── Boutons principaux ── */
.bouton-principal {
    width: 100%;
    margin-top: 18px;
    padding: 15px;
    border: none;
    border-radius: 14px;
    background: var(--argile);
    color: white;
    font-weight: 700;
    font-size: 15.5px;
    box-shadow: 0 4px 14px rgba(168, 73, 47, 0.3);
}

    .bouton-principal:disabled {
        opacity: 0.55;
    }

.bouton-secondaire {
    margin-top: 22px;
    padding: 13px 22px;
    border: 2px solid var(--indigo);
    border-radius: 12px;
    background: transparent;
    color: var(--indigo);
    font-weight: 700;
}

/* ── Écran de suivi (plein écran) ── */
.ecran-plein {
    position: fixed;
    inset: 0;
    background: var(--sable);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
}

.suivi-icone {
    font-size: 52px;
    margin-bottom: 8px;
}

.ecran-plein h1 {
    font-family: var(--police-affichage);
    font-size: 24px;
    margin: 0 0 8px;
}

.ecran-plein p {
    color: var(--encre-douce);
    margin: 0;
    max-width: 320px;
}

.suivi-numero {
    font-family: var(--police-chiffres);
    font-size: 13px;
    margin-top: 14px !important;
    color: var(--encre-douce);
}

/* ── Reçu détaillé (après paiement confirmé) — même signature visuelle
   "ticket déchiré" que le panier, pour une cohérence de bout en bout ── */
.recu-carte {
    background: var(--blanc-papier);
    border-radius: 4px;
    border: 2px dashed var(--sable-fonce);
    border-top: none;
    padding: 0 20px 14px;
    margin-top: 20px;
    width: 100%;
    max-width: 320px;
    text-align: left;
    max-height: 42vh;
    overflow-y: auto;
}

.recu-entete {
    text-align: center;
    font-family: var(--police-chiffres);
    font-weight: 500;
    font-size: 13px;
    color: var(--encre-douce);
    padding: 4px 0 8px;
}

.recu-paiement {
    font-size: 12.5px;
    color: var(--encre-douce);
    padding-top: 4px;
}

    .recu-paiement div {
        display: flex;
        justify-content: space-between;
        padding: 3px 0;
    }

/* ── Lien réservation (visible sans table) ── */
.lien-reservation {
    display: block;
    margin: 4px 16px 100px;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed var(--sable-fonce);
    background: transparent;
    color: var(--indigo);
    font-weight: 600;
    font-size: 14px;
    text-align: center;
}

/* ── Accessibilité ── */
button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2.5px solid var(--indigo);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .panneau {
        animation: none;
    }
}

/* ── Petits écrans très étroits ── */
@media (max-width: 340px) {
    .entete-nom {
        font-size: 22px;
    }
}

/* ── Support RTL (arabe) ──
   Le navigateur gère l'essentiel automatiquement via dir="rtl" sur <html>,
   mais quelques éléments à géométrie fixe (barre panier, panneau ticket)
   ont besoin d'un ajustement explicite de la police pour l'arabe. */
[dir="rtl"] body {
    font-family: 'Noto Sans Arabic', var(--police-corps);
}

[dir="rtl"] .entete-nom,
[dir="rtl"] .panneau-entete h2,
[dir="rtl"] .ecran-plein h1 {
    font-family: 'Noto Sans Arabic', var(--police-affichage);
}

[dir="rtl"] .article-prix,
[dir="rtl"] .ligne-panier-montant,
[dir="rtl"] #totalPanierDetail,
[dir="rtl"] .suivi-numero {
    font-family: var(--police-chiffres); /* les montants restent en chiffres latins/mono, plus lisibles */
    direction: ltr;
    unicode-bidi: isolate;
}
