/* ============================================================
   KOMBI Business — Design système
   Identité : noir profond, marron foncé, marron clair, blanc,
   touches dorées. Mobile-first : gros boutons, textes lisibles.
   ============================================================ */

:root {
    --noir:         #141110;
    --noir-2:       #201a17;
    --marron-fonce: #4a2e1e;
    --marron:       #6b452c;
    --marron-clair: #a9765a;
    --dore:         #d4a24e;
    --dore-clair:   #e8c98a;
    --blanc:        #ffffff;
    --creme:        #f7f2ec;
    --gris:         #8d8177;
    --vert:         #3e8e5a;
    --rouge:        #c0392b;
    --radius:       12px;
    --ombre:        0 4px 14px rgba(20, 17, 16, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; }

body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--creme);
    color: var(--noir);
    min-height: 100vh;
    line-height: 1.5;
}

/* ---------- Écrans centrés (connexion, inscription) ---------- */
.ecran-centre {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, var(--noir) 0%, var(--marron-fonce) 100%);
}

.logo { font-size: 1.9rem; font-weight: 700; color: var(--blanc); letter-spacing: 1px; }
.logo span { color: var(--dore); }
.slogan { color: var(--marron-clair); font-size: 0.92rem; margin: 6px 0 22px; text-align: center; }

/* ---------- Cartes ---------- */
.carte {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 24px 20px;
    width: 100%;
    max-width: 430px;
}

.carte h1, .carte h2 { font-size: 1.25rem; margin-bottom: 16px; color: var(--marron-fonce); }

/* ---------- Formulaires ---------- */
.champ { margin-bottom: 14px; }

.champ label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--marron-fonce);
    margin-bottom: 5px;
}

.champ input, .champ select {
    width: 100%;
    padding: 13px 14px;
    font-size: 1rem;
    border: 1.5px solid #d9cfc4;
    border-radius: var(--radius);
    background: var(--blanc);
    color: var(--noir);
}

.champ input:focus, .champ select:focus {
    outline: none;
    border-color: var(--dore);
    box-shadow: 0 0 0 3px rgba(212, 162, 78, 0.2);
}

.erreur-champ { color: var(--rouge); font-size: 0.82rem; margin-top: 3px; }

/* ---------- Boutons (gros, adaptés au téléphone) ---------- */
.btn {
    display: inline-block;
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: opacity 0.15s;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.55; cursor: wait; }

.btn-principal { background: var(--marron-fonce); color: var(--blanc); }
.btn-dore      { background: var(--dore); color: var(--noir); }
.btn-secondaire {
    background: transparent;
    color: var(--marron-fonce);
    border: 1.5px solid var(--marron-clair);
}
.btn-petit { width: auto; padding: 8px 14px; font-size: 0.85rem; }
.btn-danger { background: var(--rouge); color: var(--blanc); }

/* ---------- Messages ---------- */
.message { padding: 12px 14px; border-radius: var(--radius); font-size: 0.92rem; margin-bottom: 14px; display: none; }
.message.visible { display: block; }
.message-erreur  { background: #fdecea; color: var(--rouge); border: 1px solid #f5c6c0; }
.message-succes  { background: #eaf6ee; color: var(--vert); border: 1px solid #bfe3cc; }

/* ---------- Liens ---------- */
.lien { color: var(--marron); font-weight: 600; text-decoration: none; }
.lien:hover { text-decoration: underline; }
.sous-carte { margin-top: 16px; color: var(--dore-clair); font-size: 0.92rem; text-align: center; }
.sous-carte a { color: var(--dore); }

/* ---------- En-tête d'application ---------- */
.entete {
    background: var(--noir);
    color: var(--blanc);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.entete .logo { font-size: 1.25rem; }
.entete-infos { text-align: right; font-size: 0.8rem; color: var(--marron-clair); }
.entete-infos strong { display: block; color: var(--blanc); font-size: 0.9rem; }

/* ---------- Contenu principal ---------- */
.contenu { padding: 16px; max-width: 760px; margin: 0 auto; }

.grille-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.carte-module {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 18px 14px;
    text-align: center;
    text-decoration: none;
    color: var(--noir);
    border-bottom: 3px solid var(--dore);
}
.carte-module .icone { font-size: 1.7rem; }
.carte-module .titre { font-weight: 700; margin-top: 6px; font-size: 0.95rem; }
.carte-module .detail { font-size: 0.78rem; color: var(--gris); margin-top: 3px; }
.carte-module.inactif { opacity: 0.5; border-bottom-color: #d9cfc4; }

/* ---------- Listes (employés, etc.) ---------- */
.ligne-item {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.ligne-item .nom { font-weight: 700; }
.ligne-item .details { font-size: 0.82rem; color: var(--gris); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-role   { background: var(--creme); color: var(--marron-fonce); border: 1px solid var(--marron-clair); }
.badge-actif  { background: #eaf6ee; color: var(--vert); }
.badge-inactif{ background: #fdecea; color: var(--rouge); }

.actions-ligne { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cartes de chiffres (tableau de bord) ---------- */
.grille-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.carte-stat {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 14px;
    border-left: 4px solid var(--dore);
}
.carte-stat .valeur { font-size: 1.35rem; font-weight: 800; color: var(--marron-fonce); }
.carte-stat .valeur small { font-size: 0.75rem; font-weight: 600; color: var(--gris); }
.carte-stat .libelle { font-size: 0.8rem; color: var(--gris); margin-top: 2px; }
.carte-stat.a-venir { opacity: 0.55; border-left-color: #d9cfc4; }
.carte-stat .note-phase {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--marron-clair);
    background: var(--creme);
    padding: 2px 8px;
    border-radius: 12px;
}

/* ---------- Bandeau d'abonnement ---------- */
.bandeau {
    background: linear-gradient(120deg, var(--marron-fonce), var(--noir-2));
    color: var(--blanc);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.bandeau .plan { font-weight: 800; color: var(--dore); text-transform: capitalize; }
.bandeau .restant { font-size: 0.85rem; color: var(--dore-clair); }

/* ---------- Activité récente ---------- */
.liste-activite {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 6px 16px;
    margin-top: 12px;
}
.liste-activite .activite {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f0e9e1;
    font-size: 0.88rem;
}
.liste-activite .activite:last-child { border-bottom: none; }
.liste-activite .quand { color: var(--gris); font-size: 0.78rem; white-space: nowrap; }

/* ---------- Fenêtres de dialogue (mouvements, historique…) ---------- */
/* Centrage explicite : le reset « * { margin:0 } » annule le margin:auto
   qui centre nativement les <dialog>, d'où l'affichage en haut à gauche.
   On recentre donc en position fixe au milieu de l'écran. */
dialog {
    /* Centrage géométrique fiable (inset + margin auto) : reste centré même
       quand le contenu est haut ou que le clavier réduit l'écran du téléphone */
    position: fixed;
    inset: 0;
    margin: auto;
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(20, 17, 16, 0.45);
    padding: 20px;
    width: min(430px, calc(100vw - 24px));
    max-height: 88vh;
    max-height: 88dvh; /* suit l'ouverture du clavier (navigateurs récents) */
    overflow-y: auto;
}
dialog::backdrop { background: rgba(20, 17, 16, 0.55); }
dialog h2 { font-size: 1.15rem; color: var(--marron-fonce); margin-bottom: 14px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 14px; }
.dialog-actions .btn { flex: 1; }

/* ---------- Barre de filtres ---------- */
.barre-filtres { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.barre-filtres input, .barre-filtres select {
    flex: 1;
    min-width: 130px;
    padding: 11px 12px;
    font-size: 0.95rem;
    border: 1.5px solid #d9cfc4;
    border-radius: var(--radius);
    background: var(--blanc);
}

/* ---------- Lignes d'historique ---------- */
.mouvement {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px solid #f0e9e1;
    font-size: 0.86rem;
}
.mouvement:last-child { border-bottom: none; }
.mouvement .type-in         { color: var(--vert); font-weight: 700; }
.mouvement .type-out        { color: var(--marron); font-weight: 700; }
.mouvement .type-loss       { color: var(--rouge); font-weight: 700; }
.mouvement .type-adjustment { color: var(--dore); font-weight: 700; }

/* ---------- Écran de caisse ---------- */
.resultats-recherche {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 12px;
}
.resultat-produit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #f0e9e1;
    cursor: pointer;
}
.resultat-produit:active { background: var(--creme); }
.resultat-produit:last-child { border-bottom: none; }

.panier-ligne {
    background: var(--blanc);
    border-radius: var(--radius);
    box-shadow: var(--ombre);
    padding: 10px 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
    width: 38px; height: 38px;
    font-size: 1.2rem; font-weight: 700;
    border: 1.5px solid var(--marron-clair);
    background: var(--blanc);
    color: var(--marron-fonce);
    border-radius: 10px;
    cursor: pointer;
}
.stepper input {
    width: 64px;
    text-align: center;
    padding: 8px 4px;
    font-size: 1rem;
    border: 1.5px solid #d9cfc4;
    border-radius: 10px;
}

.barre-total {
    position: sticky;
    bottom: 0;
    background: var(--noir);
    color: var(--blanc);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 16px -16px 0;
}
.barre-total .montant { font-size: 1.4rem; font-weight: 800; color: var(--dore); }
.barre-total .btn { width: auto; padding: 12px 22px; }

.recu {
    background: var(--creme);
    border: 1px dashed var(--marron-clair);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    line-height: 1.45;
}

/* ---------- Titres de section ---------- */
.titre-page { font-size: 1.3rem; color: var(--marron-fonce); margin: 18px 0 4px; }
.sous-titre { color: var(--gris); font-size: 0.9rem; margin-bottom: 14px; }

.separateur { border: none; border-top: 1px solid #e5dcd2; margin: 22px 0; }
