/* ============================================================================
 * ZONA GO - UNIFIED MOBILE-FIRST UI & RESPONSIVE DESIGN SYSTEM
 * Fichier : public_html/assets/css/zona_go_ui.css
 * ============================================================================ */

:root {
    /* Hauteurs Shell Dashboard (valeurs par défaut si non définies dans index.php) */
    --header-h: 52px;
    --bottom-h: 56px;

    /* Hauteur réelle utile du viewport (Desktop & Mobile avec Safe Areas) */
    --zona-viewport-h: calc(100dvh - var(--header-h) - env(safe-area-inset-top, 0px));

    /* Échelle stricte des Z-INDEX (Shell + ZONA GO) */
    --zgo-z-sticky: 900;
    --zgo-z-header: 2500;
    --zgo-z-bottombar: 3000;
    --zgo-z-fab: 3100;
    --zgo-z-sidebar: 4000;
    --zgo-z-modal: 5000;
    --zgo-z-modal-top: 5500;
    --zgo-z-toast: 10000;

    /* Tokens Design System ZONA GO */
    --zgo-brand: #111111;
    --zgo-primary: #0a66c2;
    --zgo-green: #1e8e3e;
    --zgo-gold: #FFD700;
    --zgo-warn: #d97706;
    --zgo-danger: #d93025;
    --zgo-bg: #ffffff;
    --zgo-bg-alt: #f9f9f9;
    --zgo-bg-soft: #f0f2f5;
    --zgo-border: #ebebeb;
    --zgo-text: #111111;
    --zgo-text-muted: #666666;
    --zgo-radius-sm: 8px;
    --zgo-radius-md: 12px;
    --zgo-radius-lg: 20px;
    --zgo-shadow-fab: 0 8px 24px rgba(0, 0, 0, 0.22);
    --zgo-shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.16);
}

@media (max-width: 900px) {
    :root {
        --zona-viewport-h: calc(
            100dvh
            - var(--header-h)
            - env(safe-area-inset-top, 0px)
            - var(--bottom-h)
            - env(safe-area-inset-bottom, 0px)
        );
    }
}

/* ============================================================================
 * 1. PROTECTION GLOBALE CONTENEURS & ANTI-DÉBORDEMENT
 * ============================================================================ */
.zgo-wrapper,
.sp-wrapper,
.kds-wrapper,
.kds-container,
.zgo-customer-container,
.go-app-container,
.go-reg-wrapper,
.builder-root,
.admin-wrapper,
.kyc-admin-wrap {
    --go-brand: var(--zgo-green);
    --li-primary: var(--zgo-primary);
    --li-border: var(--zgo-border);
    --li-text-main: var(--zgo-text);
    --li-text-muted: var(--zgo-text-muted);
    --border: var(--zgo-border);
    --bg-main: var(--zgo-bg);
    --bg-panel: var(--zgo-bg-alt);
    --danger: var(--zgo-danger);
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: clip;
}

.zgo-wrapper *, .zgo-wrapper *::before, .zgo-wrapper *::after,
.sp-wrapper *, .sp-wrapper *::before, .sp-wrapper *::after,
.kds-wrapper *, .kds-wrapper *::before, .kds-wrapper *::after,
.kds-container *, .kds-container *::before, .kds-container *::after,
.zgo-customer-container *, .zgo-customer-container *::before, .zgo-customer-container *::after,
.go-app-container *, .go-app-container *::before, .go-app-container *::after,
.go-reg-wrapper *, .go-reg-wrapper *::before, .go-reg-wrapper *::after,
.builder-root *, .builder-root *::before, .builder-root *::after,
.admin-wrapper *, .admin-wrapper *::before, .admin-wrapper *::after,
.kyc-admin-wrap *, .kyc-admin-wrap *::before, .kyc-admin-wrap *::after {
    box-sizing: border-box;
    min-width: 0;
}

/* Chiffres stables (prix, soldes, chronos, distances) */
.zgo-num,
.zgo-prod-price,
.p-price,
.o-total,
.o-price,
.stat-val,
.val {
    font-variant-numeric: tabular-nums;
}

/* Suppression délai 300ms + feedback tactile natif */
.zgo-wrapper button, .zgo-wrapper a,
.sp-wrapper button, .sp-wrapper a,
.kds-wrapper button, .kds-wrapper a,
.kds-container button, .kds-container a,
.zgo-customer-container button, .zgo-customer-container a,
.go-app-container button, .go-app-container a,
.go-reg-wrapper button, .go-reg-wrapper a,
.admin-wrapper button, .admin-wrapper a,
.kyc-admin-wrap button, .kyc-admin-wrap a {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.zgo-tap:active,
.btn-act:active,
.btn-action:active,
.zgo-btn-add:active,
.btn-add:active {
    transform: scale(0.97);
}

/* Accessibilité clavier propre */
.zgo-wrapper :focus-visible,
.sp-wrapper :focus-visible,
.kds-container :focus-visible,
.zgo-customer-container :focus-visible,
.go-app-container :focus-visible,
.go-reg-wrapper :focus-visible {
    outline: 2px solid var(--zgo-primary);
    outline-offset: 2px;
}

/* État chargement bouton (anti double-clic) */
.zgo-is-loading {
    opacity: 0.7 !important;
    pointer-events: none !important;
    cursor: wait !important;
}

/* ============================================================================
 * 2. VERROUILLAGE SCROLL ARRIÈRE-PLAN QUAND MODALE / SHEET OUVERTE
 * ============================================================================ */
body:has(
    .zgo-sheet-overlay.show,
    .sheet-overlay.show,
    .modal.show,
    .modal-overlay.active,
    .doc-modal.show,
    .c-sheet-modal[style*="flex"]
) {
    overflow: hidden !important;
}

/* Masquer les paniers flottants quand le menu mobile Dashboard est ouvert */
body:has(.sidebar.open) .zgo-float-cart,
body:has(.sidebar.open) .floating-cart-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.85);
}

/* ============================================================================
 * 3. UTILITAIRES SCROLL HORIZONTAL & EDGE-TO-EDGE MOBILE
 * ============================================================================ */
.zgo-h-scroll {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.zgo-h-scroll::-webkit-scrollbar {
    display: none;
}

/* ============================================================================
 * 4. BOTTOM-SHEETS, MODALES & TOASTS UNIFIÉS (MOBILE + SAFE AREA)
 * ============================================================================ */
.zgo-sheet-overlay,
.sheet-overlay,
.c-sheet-modal,
.doc-modal {
    z-index: var(--zgo-z-modal) !important;
}

.zgo-sheet-body,
.sheet-body,
.modal-body,
.m-body,
.active-sheet,
.c-sheet-box {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Bandeau d'alerte hors-ligne réseau */
.zgo-net-banner {
    display: none;
    background: #fef2f2;
    color: #991b1b;
    border-bottom: 1px solid #fecaca;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.zgo-net-banner.visible {
    display: flex;
}

/* ============================================================================
 * 5. RÈGLES MOBILE (<= 900px) : INPUTS 16PX, FAB & TOASTS AU-DESSUS BOTTOM-BAR
 * ============================================================================ */
@media (max-width: 900px) {
    /* Stopper le zoom automatique sur iOS Safari */
    .zgo-wrapper input, .zgo-wrapper select, .zgo-wrapper textarea,
    .sp-wrapper input, .sp-wrapper select, .sp-wrapper textarea,
    .kds-wrapper input, .kds-wrapper select, .kds-wrapper textarea,
    .kds-container input, .kds-container select, .kds-container textarea,
    .zgo-customer-container input, .zgo-customer-container select, .zgo-customer-container textarea,
    .go-app-container input, .go-app-container select, .go-app-container textarea,
    .go-reg-wrapper input, .go-reg-wrapper select, .go-reg-wrapper textarea,
    .builder-root input, .builder-root select, .builder-root textarea,
    .admin-wrapper input, .admin-wrapper select, .admin-wrapper textarea {
        font-size: 16px !important;
    }

    /* Boutons panier flottants au-dessus de la .bottom-tab-bar */
    .zgo-float-cart,
    .floating-cart-btn {
        bottom: calc(var(--bottom-h, 56px) + env(safe-area-inset-bottom, 0px) + 14px) !important;
        z-index: var(--zgo-z-fab) !important;
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    /* Toasts toujours visibles au-dessus de .bottom-tab-bar */
    .zgo-customer-container #toast-container,
    .kds-wrapper #toast-container,
    .kds-container #toast-container {
        bottom: calc(var(--bottom-h, 56px) + env(safe-area-inset-bottom, 0px) + 12px) !important;
        top: auto !important;
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        align-items: center !important;
        z-index: var(--zgo-z-toast) !important;
    }
}

/* Breakpoint ultra-compact (320px - 380px) */
@media (max-width: 380px) {
    .zgo-float-cart,
    .floating-cart-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 18px !important;
        inset-inline-end: 12px !important;
    }
}

/* Mode Paysage mobile (clavier ou rotation horizontale) */
@media (max-height: 540px) and (orientation: landscape) {
    .zgo-sheet-content,
    .sheet-content,
    .modal-content {
        max-height: 96dvh !important;
    }
}

/* Accessibilité : réduction des animations */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}