/**
 * MMAS — Parent Shell (header + side menu)
 *
 * Styles partagés entre toutes les pages parent (index.html, famille.html,
 * summer.html, etc.).
 *
 * IMPORTANT : box-sizing forcé en border-box sur tous les éléments du shell
 * pour rendu identique entre les pages (certaines ont `* { box-sizing }`
 * global, d'autres non).
 */

.shell-header, .shell-header *,
.side-menu, .side-menu *,
.side-menu-overlay,
.hamburger-btn, .hamburger-badge,
.shell-logout-btn,
.lang-switcher, .lang-btn {
    box-sizing: border-box;
}

/* ===== HEADER STICKY ===== */
.shell-header {
    background: var(--white, #ffffff);
    padding: calc(env(safe-area-inset-top, 0) + 0.8rem) 1.2rem 0.8rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.shell-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.shell-header .brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.shell-header .brand img {
    height: 40px;
    object-fit: contain;
}
.shell-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
/* Titre de page central (optionnel — défini via body[data-page-title]) */
.shell-page-title {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary, #4338ca);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}
.shell-page-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.shell-page-title i { font-size: 0.95em; }
/* Mobile : cacher la brand image pour laisser de la place au titre */
@media (max-width: 480px) {
    .shell-header .brand img { display: none; }
    .shell-page-title { font-size: 0.95rem; }
}

/* ===== HAMBURGER ===== */
.hamburger-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--primary-50, #eef2ff);
    color: var(--primary, #4338ca);
    border: 1px solid var(--gray-100);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
    font-size: 1.1rem;
    -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:active { transform: scale(0.95); }
.hamburger-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: var(--danger, #ef4444); color: white;
    border-radius: 999px;
    font-size: 0.7rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid white;
}
.hamburger-badge.hidden { display: none; }

/* ===== LOGOUT BTN (header) ===== */
.shell-logout-btn {
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
    border: none;
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.shell-logout-btn:active { transform: scale(0.95); }

/* ===== LANGUAGE SWITCHER ===== */
.lang-switcher {
    display: flex;
    gap: 4px;
}
.lang-btn {
    padding: 6px 10px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 6px;
    background: transparent;
    color: var(--gray-600, #4b5563);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.lang-btn:hover, .lang-btn.active {
    background: var(--primary-50, #eef2ff);
    color: var(--primary, #4338ca);
    border-color: var(--primary-light, #818cf8);
}

/* ===== SIDE MENU (slide-in from left) ===== */
.side-menu-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 5000;
}
.side-menu-overlay.is-open {
    opacity: 1; pointer-events: auto;
}
.side-menu {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 78%; max-width: 320px;
    background: white;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 5001;
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
.side-menu.is-open { transform: translateX(0); }
.side-menu-header {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--gray-100);
}
.side-menu-close {
    margin-left: auto;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--gray-50);
    border: none; cursor: pointer;
    color: var(--gray-600);
    display: inline-flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.side-menu-nav {
    flex: 1; overflow-y: auto;
    padding: 12px 8px;
    display: flex; flex-direction: column;
    gap: 2px;
}
.side-menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: transparent; border: none; cursor: pointer;
    text-align: left;
    border-radius: 10px;
    color: var(--gray-800);
    font-size: 0.95rem; font-weight: 500;
    position: relative;
    min-height: 48px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.side-menu-item i { width: 22px; text-align: center; color: var(--gray-500); font-size: 1.05rem; }
.side-menu-item:hover { background: var(--gray-50); }
.side-menu-item.active {
    background: var(--primary-50, #eef2ff);
    color: var(--primary, #4338ca);
    font-weight: 700;
}
.side-menu-item.active i { color: var(--primary, #4338ca); }
.side-menu-item .notif-badge {
    margin-left: auto;
    min-width: 22px; height: 22px;
    padding: 0 7px;
    background: var(--danger, #ef4444);
    color: white;
    border-radius: 999px;
    font-size: 0.72rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.side-menu-item .notif-badge.hidden,
.notif-badge.hidden { display: none; }
.side-menu-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 8px 16px;
}
.side-menu-item--danger { color: var(--danger, #ef4444); }
.side-menu-item--danger i { color: var(--danger, #ef4444); }
.side-menu-item--danger:hover { background: #fef2f2; }

/* RTL */
[dir="rtl"] .shell-header { flex-direction: row-reverse; }
[dir="rtl"] .brand { flex-direction: row-reverse; }
[dir="rtl"] .side-menu {
    left: auto; right: 0;
    transform: translateX(100%);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
[dir="rtl"] .side-menu.is-open { transform: translateX(0); }

/* ===== Barre d'onglets bas d'écran (style appli native) ===== */
.shell-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 900;
    display: flex;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--gray-100, #f1f5f9);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 18px -12px rgba(15, 23, 42, 0.25);
}
.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 58px;
    text-decoration: none;
    color: var(--gray-400, #94a3b8);
    font-size: 0.66rem;
    font-weight: 600;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
}
.tabbar-item i {
    font-size: 1.18rem;
    transition: transform 0.15s ease;
}
.tabbar-item:active i { transform: scale(0.86); }
.tabbar-item.active { color: var(--primary, #4338ca); }
.tabbar-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 34px; height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--primary, #4338ca);
}
.tabbar-item .tab-badge {
    position: absolute;
    top: 7px;
    right: calc(50% - 22px);
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tabbar-item .tab-badge.hidden { display: none; }
/* Le contenu ne doit jamais passer sous la barre */
body.has-tabbar { padding-bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
/* Desktop large : le menu latéral suffit */
@media (min-width: 900px) {
    .shell-tabbar { display: none; }
    body.has-tabbar { padding-bottom: 40px !important; }
}

/* ===== Sensations « appli » ===== */
main { animation: shellFadeIn 0.22s ease; }
@keyframes shellFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
button, a { -webkit-tap-highlight-color: transparent; }
@media (prefers-reduced-motion: reduce) {
    main { animation: none; }
}

/* =========================================================================
   Look « appli native » — aligné sur MMAS Familles (Flutter v1.2).
   Même palette (kPrimary #4744B2), même fond (#F4F6FB), en-tête violet
   plein façon AppBar et barre d'onglets Material 3 (pastille derrière
   l'icône active). Chargé en dernier → gagne la cascade sur les pages.
   ========================================================================= */
:root {
    --primary: #4744B2;
    --primary-light: #6360c9;
    --primary-dark: #37348c;
}
body { background: #F4F6FB; }
@media (prefers-color-scheme: dark) {
    body { background: #0f0f23; }
}

@media (max-width: 899px) {
    /* — En-tête : AppBar violette de l'appli — */
    .shell-header {
        background: var(--primary, #4744B2);
        box-shadow: 0 2px 10px -4px rgba(55, 52, 140, 0.55);
    }
    .shell-page-title { color: #fff; }
    .shell-header .brand span { color: #fff !important; }
    .hamburger-btn {
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
        border-color: transparent;
    }
    .lang-btn {
        color: rgba(255, 255, 255, 0.85);
        border-color: rgba(255, 255, 255, 0.35);
    }
    .lang-btn.active {
        color: #fff;
        font-weight: 700;
        background: rgba(255, 255, 255, 0.18);
        border-color: transparent;
    }
    /* Logo sur fond violet : pastille blanche, comme l'écran de connexion de l'appli */
    .shell-header .brand img {
        background: #fff;
        border-radius: 10px;
        padding: 4px 8px;
        height: 36px;
    }

    /* — Barre d'onglets : NavigationBar Material 3 de l'appli — */
    .shell-tabbar {
        background: #fff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border-top: none;
        box-shadow: 0 -1px 14px rgba(15, 23, 42, 0.08);
    }
    .tabbar-item {
        min-height: 64px;
        gap: 4px;
        font-size: 0.7rem;
        color: var(--gray-500, #64748b);
    }
    .tabbar-item i { position: relative; z-index: 1; font-size: 1.22rem; }
    /* Pastille derrière l'icône active (indicator M3) au lieu du trait haut */
    .tabbar-item.active::before {
        top: 8px;
        width: 54px;
        height: 30px;
        border-radius: 999px;
        background: rgba(71, 68, 178, 0.12);
    }
    .tabbar-item.active { color: var(--primary, #4744B2); font-weight: 700; }
    .tabbar-item .tab-badge { top: 4px; right: calc(50% - 26px); z-index: 2; }
    body.has-tabbar { padding-bottom: calc(82px + env(safe-area-inset-bottom)) !important; }

    /* — Cartes : blanches, rayon 16, sans bordure (cardTheme de l'appli) — */
    .card {
        border-radius: 16px;
        border: none;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    }
}
