/* IUTEA — PWA : bouton de connexion mobile, bannière d'installation, barre de navigation, mode hors ligne */

:root {
    --pwa-bordeaux: #8B0000;
    --pwa-bordeaux-dark: #6B0000;
    --pwa-bottomnav-h: 62px;
}

/* ---------- Bouton « Connexion » visible dans l'en-tête mobile ---------- */
.header-login-btn { display: none; }

@media (max-width: 968px) {
    .header-cta { gap: 0.5rem; }

    .header-login-btn {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.55rem 0.8rem;
        border: 1.5px solid var(--pwa-bordeaux);
        border-radius: 8px;
        background: #fff;
        color: var(--pwa-bordeaux);
        font-size: 0.85rem;
        font-weight: 600;
        line-height: 1;
        text-decoration: none;
        white-space: nowrap;
    }
    .header-login-btn:hover,
    .header-login-btn:active { background: var(--pwa-bordeaux); color: #fff; }
    .header-login-btn.is-auth { background: var(--pwa-bordeaux); color: #fff; }
}

/* Petits écrans : logo plus compact pour laisser la place au bouton Connexion */
@media (max-width: 420px) {
    .header-main .brand-logo { height: 44px !important; }
    .header-login-btn { padding: 0.5rem 0.65rem; font-size: 0.8rem; }
    .header-cta-btn { padding: 0.55rem 0.7rem !important; }
}

/* Très petits écrans : icône seule */
@media (max-width: 340px) {
    .header-login-btn .login-text { display: none; }
}

.mobile-menu .mobile-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.75rem 1rem 0;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--pwa-bordeaux);
    border-radius: 10px;
    color: var(--pwa-bordeaux);
    font-weight: 600;
    text-decoration: none;
}

.mobile-menu .mobile-install {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    margin: 0.75rem 1rem 0;
    padding: 0.85rem 1rem;
    border: 0;
    border-radius: 10px;
    background: #f3f4f6;
    color: #111827;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.mobile-menu .mobile-install.is-visible { display: flex; }

/* ---------- Bannière « Installer l'application » ---------- */
.pwa-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: #1f2937;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    animation: pwa-slide-up 0.3s ease-out;
}
.pwa-banner.is-visible { display: flex; }
body:has(.pwa-bottomnav) .pwa-banner { bottom: calc(var(--pwa-bottomnav-h) + 12px + env(safe-area-inset-bottom)); }

.pwa-banner img { width: 44px; height: 44px; border-radius: 10px; background: #fff; flex-shrink: 0; }
.pwa-banner-text { flex: 1; min-width: 0; font-size: 0.85rem; line-height: 1.35; }
.pwa-banner-text strong { display: block; font-size: 0.92rem; }
.pwa-banner-text span { opacity: 0.8; }

.pwa-btn {
    padding: 0.6rem 1rem;
    border: 0;
    border-radius: 8px;
    background: var(--pwa-bordeaux);
    color: #fff;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.pwa-btn:hover { background: var(--pwa-bordeaux-dark); }
.pwa-banner .pwa-btn { flex-shrink: 0; }
.pwa-banner-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.7;
}

@keyframes pwa-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* Cette bannière n'a de sens que sur téléphone / tablette */
@media (min-width: 969px) { .pwa-banner { display: none !important; } }

/* ---------- Indicateur hors ligne ---------- */
.pwa-offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    display: none;
    padding: 0.4rem 1rem;
    background: #b45309;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}
.pwa-offline-bar.is-visible { display: block; }

/* ---------- Barre de navigation basse (espaces connectés, mobile) ---------- */
.pwa-bottomnav { display: none; }

@media (max-width: 968px) {
    .pwa-bottomnav {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        z-index: 900;
        display: flex;
        height: calc(var(--pwa-bottomnav-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: #fff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    }
    .pwa-bottomnav a {
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        color: #6b7280;
        font-size: 0.68rem;
        font-weight: 500;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .pwa-bottomnav a i { font-size: 1.15rem; }
    .pwa-bottomnav a.active { color: var(--pwa-bordeaux); font-weight: 700; }
    body:has(.pwa-bottomnav) { padding-bottom: calc(var(--pwa-bottomnav-h) + env(safe-area-inset-bottom)); }
}

/* Thème sombre de l'espace connecté */
html.admin-page .pwa-bottomnav { background: #1a1a1f; border-top-color: #2a2a31; }
html.admin-page .pwa-bottomnav a { color: #9ca3af; }
html.admin-page .pwa-bottomnav a.active { color: #ff6b6b; }

/* ---------- Application installée (mode standalone) ---------- */
@media (display-mode: standalone) {
    body { -webkit-tap-highlight-color: transparent; }
    .pwa-banner { display: none !important; }
}

/* ---------- Page hors ligne ---------- */
.pwa-offline-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #f9fafb;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: #111827;
}
.pwa-offline-card {
    max-width: 380px;
    padding: 2rem 1.5rem;
    border-radius: 16px;
    background: #fff;
    border-top: 4px solid var(--pwa-bordeaux);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    text-align: center;
}
.pwa-offline-card img { border-radius: 18px; }
.pwa-offline-card h1 { margin: 1rem 0 0.5rem; font-size: 1.35rem; }
.pwa-offline-card p { margin: 0 0 1.25rem; color: #4b5563; line-height: 1.5; font-size: 0.92rem; }

/* ---------- Page de connexion : le formulaire matricule doit rester atteignable (clavier, app installée) ---------- */
.login-section { padding-bottom: calc(7rem + env(safe-area-inset-bottom)) !important; }
