/**
 * ASARIS — affichage adapté au type d'écran (PC / tablette / mobile)
 */

/* ——— Menu mobile ——— */
.header-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    cursor: pointer;
    flex-shrink: 0;
}

.header-menu-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 20px;
}

.header-menu-bars span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 850;
}

.mobile-nav-backdrop[hidden] {
    display: none;
}

body.mobile-nav-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .header-menu-toggle {
        display: inline-flex;
    }

    .app-header {
        flex-wrap: wrap;
        position: relative;
    }

    .header-nav {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        width: min(88vw, 320px);
        height: 100dvh;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 72px 16px 24px;
        background: linear-gradient(180deg, #083a5c 0%, #0c4a72 100%);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.28);
        z-index: 860;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .header-nav.is-open {
        display: flex;
    }

    .header-nav .btn,
    .header-nav a.btn {
        width: 100%;
        justify-content: flex-start;
        min-height: 44px;
        font-size: 0.92rem;
    }

    .header-user-pill {
        width: 100%;
        justify-content: flex-start;
    }

    .header-user-name {
        display: inline !important;
    }

    .header-ops-date,
    .header-wifi-chip {
        font-size: 0.72rem;
    }

    /* Portails à outils dédiés : pas de tiroir plein écran (évite le bandeau bleu) */
    body.laundry-portal .header-menu-toggle,
    body.fin-portal .header-menu-toggle,
    body.admin-portal .header-menu-toggle,
    body.manager-portal .header-menu-toggle,
    body.pos-portal .header-menu-toggle {
        display: none !important;
    }

    body.laundry-portal .header-nav,
    body.fin-portal .header-nav,
    body.admin-portal .header-nav,
    body.manager-portal .header-nav,
    body.pos-portal .header-nav {
        display: flex !important;
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        width: auto !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
        flex-direction: row !important;
        align-items: center !important;
        z-index: auto !important;
    }
}

/* ——— Classes appareil ——— */
.device-tablet .hub-grid {
    grid-template-columns: repeat(2, 1fr);
}

.device-mobile .hub-grid {
    grid-template-columns: 1fr;
}

.device-tablet .dash-func-grid {
    grid-template-columns: repeat(3, 1fr);
}

.device-mobile .dash-func-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* POS — tablette */
.device-tablet .pos-terminal-layout {
    grid-template-columns: 1fr 1.1fr;
}

.device-mobile .pos-terminal-layout {
    grid-template-columns: 1fr;
}

.device-mobile .pos-nav {
    flex-wrap: wrap;
    gap: 6px;
}

.device-mobile .pos-nav-link {
    flex: 1 1 auto;
    min-height: 44px;
    justify-content: center;
}

/* Admin terminaux — tableau responsive */
@media (max-width: 768px) {
    .adm-terminals-table thead {
        display: none;
    }

    .adm-terminals-table tr {
        display: block;
        margin-bottom: 14px;
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 10px;
        padding: 12px;
        background: #fff;
    }

    .adm-terminals-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        border: none;
    }

    .adm-terminals-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.78rem;
        color: #666;
        flex-shrink: 0;
    }

    .adm-terminals-table .adm-inline-form {
        flex: 1;
        display: flex;
        gap: 6px;
        justify-content: flex-end;
    }
}

/* Touch targets globaux */
.device-tablet .btn,
.device-mobile .btn,
.device-tablet .btn-lunas,
.device-mobile .btn-lunas {
    min-height: 44px;
}

.device-mobile input,
.device-mobile select,
.device-mobile textarea,
.device-tablet input,
.device-tablet select,
.device-tablet textarea {
    min-height: 44px;
}

/* PWA standalone — marges safe area */
.pwa-standalone .app-header {
    padding-top: max(8px, env(safe-area-inset-top));
}

.pwa-standalone body {
    padding-bottom: env(safe-area-inset-bottom);
}
