/* ============================================
   MOBILE-APP.CSS — Web app mobile Stories WL (15/10/2026)
   - Barre d'onglets du bas (js/mobile-tabbar.js), < 768px uniquement
   - Puce « Installer l'app » + feuille d'aide iOS (js/pwa.js)
   - Onglet compte « Appli & notifs » (js/pages/account/notifications.js)
   - Confort au doigt des pages compte / personnages / boutique / candidature (cibles >= 44px,
     champs a 16px pour eviter le zoom auto iOS)
   Fichier SEPARE de base.css / components.css / themes.css (corriges en parallele par un autre
   chantier) : uniquement des variables existantes (--bg-*, --text-*, --glass-*, --red-*) -> clair
   ET sombre suivent automatiquement html[data-color-mode] (cf. base.css).
   ============================================ */

:root {
    --swl-tabbar-h: 64px;
    --swl-tabbar-total: calc(var(--swl-tabbar-h) + env(safe-area-inset-bottom, 0px));
}

/* ─────────────── Barre d'onglets du bas ─────────────── */

.swl-tabbar { display: none; }

@media (max-width: 767px) {
    .swl-tabbar {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 950; /* au-dessus des barres de page (90-900), sous la banniere cookies (10000) et les modales */
        height: var(--swl-tabbar-total);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
        background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
        backdrop-filter: blur(var(--glass-blur, 16px));
        -webkit-backdrop-filter: blur(var(--glass-blur, 16px));
        border-top: 1px solid var(--glass-border);
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
        transition: transform 0.2s ease;
    }

    .swl-tabbar[hidden] { display: none; }

    .swl-tabbar-list {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        height: var(--swl-tabbar-h);
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .swl-tabbar-list li { display: flex; min-width: 0; }

    .swl-tabbar-item {
        flex: 1;
        min-width: 0;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 6px 2px;
        color: var(--text-tertiary);
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 600;
        line-height: 1.1;
        -webkit-tap-highlight-color: transparent;
        position: relative;
    }

    .swl-tabbar-item i { font-size: 1.2rem; line-height: 1; }

    .swl-tabbar-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .swl-tabbar-item[aria-current="page"] { color: var(--red-bright); }

    .swl-tabbar-item[aria-current="page"]::before {
        content: '';
        position: absolute;
        top: 0;
        left: 28%;
        right: 28%;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--red-bright);
    }

    .swl-tabbar-item:active { background: var(--bg-glass-hover); }

    .swl-tabbar-item:focus-visible {
        outline: 2px solid var(--red-bright);
        outline-offset: -4px;
        border-radius: 12px;
    }

    /* Espace reserve en bas de page pour ne rien masquer derriere la barre */
    body.has-mobile-tabbar { padding-bottom: var(--swl-tabbar-total); }

    /* La tabbar remplace la barre « Candidater / Discord » (StickyCta, js/app.js) */
    body.has-mobile-tabbar .sticky-cta-bar { display: none !important; }
    body.has-mobile-tabbar.has-sticky-cta { padding-bottom: var(--swl-tabbar-total); }

    /* Barre d'achat collante de la fiche produit : posee au-dessus de la tabbar */
    body.has-mobile-tabbar .shop-sticky-bar {
        bottom: var(--swl-tabbar-total);
        padding-bottom: 10px;
    }

    /* Bulle de l'assistant : au-dessus de la tabbar */
    body.has-mobile-tabbar .swl-assistant-bubble {
        bottom: calc(var(--swl-tabbar-total) + 12px);
    }

    /* Clavier virtuel ouvert (champ focus) : la barre s'efface pour liberer le formulaire */
    body.swl-keyboard-open .swl-tabbar { transform: translateY(110%); }
    body.swl-keyboard-open .swl-install-chip { display: none; }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .swl-tabbar { transition: none; }
}

/* ─────────────── Puce « Installer l'app » (js/pwa.js) ─────────────── */

.swl-install-chip {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    z-index: 940;
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: calc(100vw - 32px);
    padding: 4px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border-hover);
    box-shadow: var(--glass-shadow);
}

body.has-mobile-tabbar .swl-install-chip { bottom: calc(var(--swl-tabbar-total) + 12px); }

.swl-install-chip-btn,
.swl-install-chip-close {
    min-height: 44px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.swl-install-chip-btn {
    padding: 0 18px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    background: linear-gradient(135deg, var(--red-primary), var(--red-bright));
    white-space: nowrap;
}

.swl-install-chip-close {
    width: 44px;
    background: transparent;
    color: var(--text-secondary);
}

/* ─────────────── Feuille d'aide iOS ─────────────── */

.swl-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
}

.swl-sheet {
    width: 100%;
    max-width: 520px;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow-lg);
}

.swl-sheet-title {
    margin: 0 0 16px;
    font-size: 1.15rem;
    font-weight: 700;
}

.swl-sheet-steps {
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.swl-sheet-steps li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.swl-sheet-steps i {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--red-subtle);
    color: var(--red-bright);
}

.swl-sheet-note {
    margin: 0 0 16px;
    font-size: 0.82rem;
    color: var(--text-tertiary);
}

.swl-sheet-btn {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--red-primary), var(--red-bright));
    cursor: pointer;
}

/* ─────────────── Onglet compte « Appli & notifs » ─────────────── */

.swl-notif-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 12px 0 16px;
}

.swl-notif-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
}

.swl-notif-row:last-child { border-bottom: 0; }

.swl-notif-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.swl-notif-row-title { font-weight: 600; color: var(--text-primary); }
.swl-notif-row-desc { font-size: 0.82rem; color: var(--text-tertiary); }

.swl-notif-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    accent-color: var(--red-primary);
    cursor: pointer;
}

.swl-notif-row input[type="checkbox"]:disabled { cursor: not-allowed; }

.swl-notif-status {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin: 12px 0;
    border-radius: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.swl-notif-status i { margin-top: 3px; }
.swl-notif-status.is-ok i { color: #2ecc71; }
.swl-notif-status.is-warn i { color: var(--faction-illegal, #E8842A); }

.swl-notif-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.swl-app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg, 24px);
}

/* ─────────────── Confort au doigt : compte / persos / boutique / candidature ─────────────── */

@media (max-width: 767px) {
    /* Onglets du compte : une seule ligne defilable (au lieu de 4-5 lignes de pastilles) */
    .account-page .account-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-left: calc(-1 * var(--space-md, 16px));
        margin-right: calc(-1 * var(--space-md, 16px));
        padding-left: var(--space-md, 16px);
        padding-right: var(--space-md, 16px);
    }

    .account-page .account-tabs::-webkit-scrollbar { display: none; }

    .account-page .account-tab {
        flex-shrink: 0;
        min-height: 44px;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    /* Boutons : hauteur tactile minimale */
    .account-page .btn,
    .shop-page .btn,
    .whitelist-page .btn,
    .perso-page .btn,
    .shop-sticky-bar .btn,
    .account-page button:not(.account-tab):not(.switch),
    .whitelist-page button,
    .shop-page button:not(.pdp-thumb) {
        min-height: 44px;
    }

    .account-page .btn-sm,
    .shop-page .btn-sm,
    .whitelist-page .btn-sm {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    /* Champs : 44px de haut et 16px de texte (iOS zoome sur tout champ < 16px) */
    .account-page input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    .account-page select,
    .account-page textarea,
    .whitelist-page input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    .whitelist-page select,
    .whitelist-page textarea,
    .shop-page input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    .shop-page select {
        min-height: 44px;
        font-size: 16px;
    }

    .account-page textarea,
    .whitelist-page textarea { min-height: 120px; }

    .account-page input[type="checkbox"]:not(.switch input),
    .account-page input[type="radio"],
    .whitelist-page input[type="checkbox"],
    .whitelist-page input[type="radio"] {
        width: 22px;
        height: 22px;
    }

    /* Interrupteurs (.switch 44x24, account.css) : zone de tap etendue a 44px de haut */
    .account-page .switch::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: -10px;
        bottom: -10px;
    }

    /* Rien ne doit deborder horizontalement */
    .account-page,
    .shop-page,
    .whitelist-page,
    .perso-page { overflow-x: clip; }

    .account-page img,
    .shop-page img,
    .whitelist-page img { max-width: 100%; }
}
