/* ==========================================================================
   SAHELIA LEARNING - Thème professionnel vert foncé / doré
   Mobile-first, clair / sombre
   ========================================================================== */

:root {
    --vert-fonce: #0d3b2e;
    --vert-fonce-2: #123f31;
    --vert-degrade: #0a2e24;
    --vert-moyen: #1a5c48;
    --or: #d4af37;
    --or-clair: #e8c95a;
    --or-doux: rgba(212, 175, 55, 0.15);
    --blanc: #ffffff;
    --rouge: #e5484d;
    --vert-ok: #2ecc71;
    --rayon: 16px;
    --rayon-sm: 12px;
    --ombre: 0 8px 24px rgba(0, 0, 0, 0.12);
    --ombre-forte: 0 12px 40px rgba(0, 0, 0, 0.2);
    --transition: 0.25s ease;
}

/* ---- Thème unique (vert foncé + or, cartes blanches) ---- */
:root {
    --fond-app: #0a2e24;
    --fond-app-2: #123f31;
    --fond-carte: #ffffff;
    --fond-carte-alt: #f7f9f8;
    --fond-input: #f4f6f5;
    --texte-principal: #16241f;
    --texte-secondaire: #4a5c56;
    --texte-muted: #6b7a76;
    --bordure: #e2e8e5;
    --bordure-forte: rgba(13, 59, 46, 0.15);
    --header-texte: #ffffff;
    --nav-fond: #ffffff;
    --nav-texte: #6b7a76;
    --nav-actif: var(--or);
    --ombre-carte: 0 4px 18px rgba(0, 0, 0, 0.08);
    --sidebar-fond: #ffffff;
    --sidebar-texte: #0d3b2e;
    --sidebar-lien: #2a3f38;
    --sidebar-hover: rgba(13, 59, 46, 0.06);
    --divider: rgba(212, 175, 55, 0.3);
}

* { box-sizing: border-box; }

/* L'application n'a qu'un seul thème (vert foncé / doré). On force le
   navigateur/WebView à ne JAMAIS appliquer son propre mode sombre
   automatique par-dessus, ce qui provoquait un texte quasi invisible
   (fond assombri deux fois + couleurs inversées). */
html {
    color-scheme: light only;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    background: var(--fond-app);
    color: var(--texte-principal);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
    /* Filet de sécurité : si un navigateur ignore quand même color-scheme,
       on réaffirme explicitement les mêmes couleurs que le thème clair
       (l'app n'a volontairement pas de second thème sombre). */
    :root {
        --fond-app: #0a2e24;
        --fond-app-2: #123f31;
        --fond-carte: #ffffff;
        --texte-principal: #16241f;
        --texte-secondaire: #4a5c56;
        --texte-muted: #6b7a76;
        --header-texte: #ffffff;
        --nav-fond: #ffffff;
        --nav-texte: #6b7a76;
        --sidebar-fond: #ffffff;
        --sidebar-texte: #0d3b2e;
    }
}

/* ---------- App shell ---------- */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--fond-app);
    background-image: radial-gradient(ellipse at 50% -10%, var(--fond-app-2), var(--fond-app) 65%);
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 84px;
}


/* ---------- En-tête ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    color: var(--header-texte);
}

.app-header .header-logo-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.5);
}


.app-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    padding-left: 8px;
    letter-spacing: -0.02em;
}

.app-header .user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--or);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
}

.app-header .user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 108px;
}


.app-header .user-chip .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--or), var(--or-clair));
    color: var(--vert-fonce);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.35);
}

.header-divider {
    border: none;
    border-top: 1px solid var(--divider);
    margin: 0 18px 14px;
}

/* ---------- Contenu ---------- */
.app-content {
    flex: 1;
    padding: 0 16px 16px;
    animation: apparition 0.16s ease-out;
}

@keyframes apparition {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Retour visuel immédiat au clic (formulaire envoyé / lien suivi) pour que
   l'app se sente réactive même le temps que la page suivante se charge. */
body.chargement-page .app-content {
    opacity: 0.5;
    pointer-events: none;
}

.btn[disabled] {
    opacity: 0.7;
    cursor: default;
}

/* ---------- Cartes ---------- */
.carte {
    background: var(--fond-carte);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-carte);
    padding: 16px 18px;
    margin-bottom: 14px;
    border: 1px solid var(--bordure);
}

.carte-titre {
    font-size: 12px;
    color: var(--texte-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 2px 0 12px;
}

/* ---------- Formulaires ---------- */
.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-row > * {
    /* Sans ça, un bouton/texte non-coupable (white-space:nowrap) impose sa
       largeur naturelle et déborde du conteneur au lieu de se réduire à la
       part que lui donne flex (ex: bouton "Générer le mois" qui débordait). */
    min-width: 0;
}

.form-row .btn {
    white-space: normal;
    text-align: center;
    line-height: 1.2;
}

input[type=text],
input[type=password],
input[type=number],
input[type=tel],
input[type=date],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--rayon-sm);
    border: 1px solid var(--bordure);
    background: var(--fond-input);
    font-size: 14.5px;
    color: var(--texte-principal);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--or);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--texte-secondaire);
    display: block;
    margin: 12px 0 6px;
}

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 18px;
    border-radius: var(--rayon-sm);
    border: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow var(--transition), background var(--transition);
}

.btn:active {
    transform: scale(0.97);
}

.btn-or {
    background: linear-gradient(135deg, var(--or), var(--or-clair));
    color: var(--vert-fonce);
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
}

.btn-or:hover {
    box-shadow: 0 6px 18px rgba(212, 175, 55, 0.4);
}

.btn-vert {
    background: var(--vert-fonce);
    color: var(--blanc);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--or);
    color: var(--or);
}


.btn-danger {
    background: var(--rouge);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12.5px;
    border-radius: 10px;
}

/* ---------- Recherche ---------- */
.recherche {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--fond-carte);
    border-radius: var(--rayon-sm);
    padding: 12px 14px;
    box-shadow: var(--ombre-carte);
    margin-bottom: 14px;
    color: var(--texte-muted);
    border: 1px solid var(--bordure);
}

.recherche input {
    border: none;
    background: transparent;
    padding: 0;
    flex: 1;
    font-size: 14px;
    box-shadow: none;
}

.recherche input:focus {
    outline: none;
    box-shadow: none;
}

/* ---------- Liste items ---------- */
.liste-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--fond-carte);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--ombre-carte);
    margin-bottom: 12px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--bordure);
    transition: transform 0.15s ease, box-shadow var(--transition);
}

.liste-item:active {
    transform: scale(0.98);
}

.icone-carre {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--vert-fonce), var(--vert-moyen));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--or);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(13, 59, 46, 0.3);
}

.liste-item .infos {
    flex: 1;
    min-width: 0;
}

.liste-item .infos .titre {
    font-weight: 700;
    font-size: 15.5px;
    color: var(--texte-principal);
}

.liste-item .infos .sous-titre {
    font-size: 12.5px;
    color: var(--texte-muted);
    margin-top: 2px;
}

.liste-item .chevron {
    color: var(--or);
    font-size: 18px;
    flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}

.badge-vert {
    background: rgba(46, 204, 113, 0.18);
    color: #2ecc71;
}


.badge-rouge {
    background: rgba(229, 72, 77, 0.18);
    color: #ff6b6f;
}


.badge-or {
    background: rgba(212, 175, 55, 0.2);
    color: var(--or-clair);
}


/* ---------- Appel ---------- */
.appel-ligne {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--bordure);
}

.appel-ligne:last-child {
    border-bottom: none;
}

.appel-nom {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--texte-principal);
}

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

.rond-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0.3;
    transition: opacity 0.2s, transform 0.2s;
}

.rond-btn.absent {
    background: var(--rouge);
}

.rond-btn.present {
    background: var(--vert-ok);
}

.rond-btn.actif {
    opacity: 1;
    transform: scale(1.1);
}

/* ---------- Navigation basse ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--nav-fond);
    display: flex;
    justify-content: space-around;
    padding: 10px 6px calc(10px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    z-index: 50;
    border-top: 1px solid var(--bordure);
}

.bottom-nav a {
    text-decoration: none;
    color: var(--nav-texte);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 10px;
    transition: color var(--transition);
}

.bottom-nav a.actif {
    color: var(--nav-actif);
}

.bottom-nav .icone {
    font-size: 20px;
    line-height: 1;
    position: relative;
    display: inline-block;
}

.badge-nav {
    position: absolute;
    top: -7px;
    right: -11px;
    background: var(--rouge);
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    line-height: 1;
    padding: 2.5px 5px;
    border-radius: 20px;
    min-width: 15px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ---------- Login ---------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 0%, var(--vert-fonce-2), var(--vert-degrade) 70%);
    padding: 20px;
}

.login-carte {
    background: #ffffff;
    border-radius: 22px;
    padding: 32px 26px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
    animation: apparition 0.5s ease;
    color: #16241f;
}

@keyframes apparition {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 76px;
    height: 76px;
    border-radius: 20px;
    background: var(--vert-fonce);
    color: var(--or);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 30px;
    font-weight: 800;
}

.login-logo-img {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 14px;
    display: block;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.45);
    border: 3px solid rgba(212, 175, 55, 0.3);
}

.login-carte h2 {
    margin: 0 0 4px;
    color: var(--vert-fonce);
}

.login-carte p.sub {
    color: #6b7a76;
    font-size: 13px;
    margin: 0 0 22px;
}

.login-role-select {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.login-role-select button {
    flex: 1;
    padding: 9px 0;
    border-radius: 10px;
    border: 1.5px solid #e2e6e4;
    background: #f4f6f5;
    font-size: 12.5px;
    font-weight: 700;
    color: #6b7a76;
    cursor: pointer;
}

.login-role-select button.actif {
    background: var(--vert-fonce);
    color: white;
    border-color: var(--vert-fonce);
}

.erreur-msg {
    background: rgba(229, 72, 77, 0.1);
    color: var(--rouge);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 14px;
    text-align: left;
}

.login-carte label {
    color: #2a3f38;
}

.login-carte input {
    background: #f4f6f5;
    border-color: #e2e6e4;
    color: #16241f;
}

/* ---------- Reçu ---------- */
.recu {
    background: white;
    border-radius: 14px;
    padding: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
    color: #16241f;
}

.recu .filigrane {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.07;
    font-size: 90px;
    z-index: 0;
}

.recu > * {
    position: relative;
    z-index: 1;
}

.recu table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
    font-size: 13.5px;
}

.recu table td {
    padding: 6px 0;
    border-bottom: 1px solid #eef1f0;
    text-align: left;
}

.recu table td:last-child {
    text-align: right;
    font-weight: 700;
}

/* ---------- Divers ---------- */
.vide-etat {
    text-align: center;
    padding: 30px 10px;
    color: var(--texte-muted);
}

.fab-plus {
    position: fixed;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.txt-petit {
    font-size: 12px;
    color: var(--texte-muted);
}

a {
    color: inherit;
}

.success-msg {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 14px;
    border: 1px solid rgba(46, 204, 113, 0.25);
}


::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--or);
    border-radius: 4px;
}


/* Paiements : nom et boutons bien séparés */
.liste-item-paiement {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    background: var(--fond-carte);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--ombre-carte);
    margin-bottom: 12px;
    border: 1px solid var(--bordure);
}
.liste-item-paiement .ligne-haut {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.liste-item-paiement .ligne-haut .infos {
    flex: 1;
    min-width: 0;
}
.liste-item-paiement .ligne-haut .titre {
    font-weight: 700;
    font-size: 15px;
    color: var(--texte-principal);
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
}
.liste-item-paiement .ligne-haut .sous-titre {
    font-size: 12.5px;
    color: var(--texte-muted);
    margin-top: 3px;
}
.liste-item-paiement .ligne-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}
.liste-item-paiement .ligne-actions form {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}
.liste-item-paiement .ligne-actions .btn,
.liste-item-paiement .ligne-actions a.btn {
    width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    padding: 10px 12px;
}

/* ==========================================================================
   Mobile : anti-débordement + boutons alignés
   ========================================================================== */

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell,
.app-content,
.carte {
    max-width: 100%;
    overflow-x: hidden;
}

/* Boutons : texte qui peut passer à la ligne, jamais hors cadre */
.btn {
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    word-break: break-word;
}

.btn-block {
    width: 100%;
    display: flex;
}

.btn-sm {
    padding: 10px 12px;
    font-size: 13px;
}

/* Rangées de formulaires : empilées sur petit écran */
.form-row {
    flex-wrap: wrap;
    width: 100%;
}

.form-row > * {
    flex: 1 1 140px;
    min-width: 0;
    max-width: 100%;
}

.form-row .btn {
    flex: 1 1 100%;
    width: 100%;
}

/* Groupes de boutons (rapports, filtres, actions) */
.carte a.btn,
.carte .btn {
    max-width: 100%;
}

/* Conteneurs flex de boutons PDF / actions */
.carte > div[style*="display:flex"],
.carte div[style*="flex-wrap"] {
    max-width: 100%;
}

/* Paiements : boutons sur 2 colonnes max, pleine largeur si un seul */
.liste-item-paiement .ligne-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.liste-item-paiement .ligne-actions form,
.liste-item-paiement .ligne-actions a.btn {
    width: 100%;
    margin: 0;
}

.liste-item-paiement .ligne-actions .btn,
.liste-item-paiement .ligne-actions a.btn {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    font-size: 12.5px;
}

/* Si 3 boutons : 2 + 1 pleine largeur */
.liste-item-paiement .ligne-actions > :nth-child(3) {
    grid-column: 1 / -1;
}

/* Appel : nom + boutons */
.appel-ligne {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-bottom: 1px solid var(--bordure);
}

.appel-nom {
    flex: 1 1 140px;
    min-width: 0;
    font-weight: 600;
    font-size: 14px;
    word-break: break-word;
}

.appel-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
}

/* Badges qui ne cassent pas la ligne */
.badge {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
}

/* Header : éviter débordement nom utilisateur */
.app-header {
    gap: 8px;
    padding-left: 14px;
    padding-right: 14px;
}

.app-header .user-chip span {
    max-width: 90px;
}

/* Nav basse : labels courts, pas de débordement */
.bottom-nav a {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 2px;
    font-size: 10px;
    text-align: center;
}

.bottom-nav a span:not(.icone):not(.badge-nav) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
}

/* Très petits écrans (< 360px) */
@media (max-width: 360px) {
    .app-content {
        padding-left: 12px;
        padding-right: 12px;
    }
    .carte {
        padding: 12px 12px;
    }
    .btn {
        padding: 11px 12px;
        font-size: 13px;
    }
    .liste-item-paiement .ligne-actions {
        grid-template-columns: 1fr;
    }
    .liste-item-paiement .ligne-actions > :nth-child(3) {
        grid-column: auto;
    }
    .app-header h1 {
        font-size: 15px;
    }
}

/* Inputs full width, pas de zoom iOS trop large si possible */
input, select, textarea, button {
    max-width: 100%;
}
