:root {
    /* Color Palette — OPSET Brand 2026 */
    --bg-main: #F3F4F6;
    --text-main: #111827;
    --btn-primary: #0047FF;       /* Electric Cobalt Blue */
    --btn-secondary: #111827;     /* Anthracite Profond */
    --accent-emerald: #10B881;    /* Vert Émeraude */
    --accent-orange: #F97316;     /* Orange check (logo) */

    --alert-success: #10B881;
    --alert-warning: #F59E0B;
    --alert-critical: #EF4444;
    --alert-neutral: #9CA3AF;

    --bg-card: #FFFFFF;
    --text-muted: #6B7280;

    --border-color: rgba(17, 24, 39, 0.08);
    --border-radius: 20px;
    --shadow-premium: 0 10px 25px -5px rgba(0, 71, 255, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.06);

    /* Layout */
    --nav-height: 85px;
    --header-height: 70px;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; 
}

.font-primary  { font-family: 'Montserrat', sans-serif; }
.font-secondary { font-family: 'Montserrat', sans-serif; font-weight: 900; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    user-select: none;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    width: 100vw;
}

/* CRITICAL: toggle visibility */
.hidden { display: none !important; }

/* App Shell Layout */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: var(--bg-main);
}


/* --- Premium Utilities --- */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: var(--shadow-premium); }

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.animate-fade-in { animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-slide-up { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Login */
.login-overlay {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #0047FF 0%, #111827 100%);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}
.login-card {
    background: #ffffff; width: 90%; max-width: 400px;
    padding: 40px; border-radius: 32px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
}
.input-light {
    width: 100%; padding: 16px; border: 1px solid #e2e8f0;
    border-radius: 16px; font-family: inherit; font-size: 1rem;
    background: #f8fafc; color: var(--text-main); outline: none; transition: all 0.2s;
}
.input-light:focus { border-color: var(--btn-primary); background: #fff; box-shadow: 0 0 0 4px rgba(0, 71, 255, 0.12); }

.btn-large-primary {
    width: 100%; background: var(--btn-primary);
    color: #fff; border: none; border-radius: 16px;
    padding: 18px; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all 0.2s;
    font-family: 'Montserrat', sans-serif; letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(0, 71, 255, 0.35);
}
.btn-large-primary:active { transform: scale(0.98); }

/* Header */
#app-header {
    height: var(--header-height); display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; gap: 8px;
    background: rgba(248, 250, 252, 0.9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color); z-index: 10;
}
#header-title { font-size: 1.3rem; font-weight: 800; color: var(--btn-secondary); letter-spacing: -0.5px; }

.header-actions {
    display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; justify-content: flex-end;
}

.restaurant-dropdown {
    background-color: #fff;
    padding: 8px 28px 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem; font-weight: 700; color: var(--text-main);
    border: 1px solid var(--border-color);
    outline: none; cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7' /%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 12px auto;
    box-shadow: var(--shadow-premium);
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Main Content */
#main-content {
    flex: 1; overflow-y: auto; padding: 24px;
    padding-bottom: calc(var(--nav-height) + 24px); scroll-behavior: smooth;
}
#main-content::-webkit-scrollbar { display: none; }

/* Bottom Nav */
#bottom-nav {
    position: absolute; bottom: 0; left: 0; width: 100%; height: var(--nav-height);
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex; justify-content: space-around; align-items: center; 
    border-top: 1px solid var(--border-color); z-index: 100;
}

.nav-item {
    background: none; border: none; color: var(--text-muted);
    padding: 8px 4px 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; height: 100%; cursor: pointer; transition: all 0.2s;
    font-family: inherit; font-weight: 700; gap: 4px;
    min-width: 0;
}

.nav-item span {
    font-size: 0.62rem; line-height: 1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.nav-item.active { color: var(--btn-primary); }
.nav-item i { font-size: 1.2rem; transition: transform 0.2s; }
.nav-item.active i { transform: translateY(-1px); }

.notification-badge {
    position: absolute; top: -8px; right: -10px;
    background: var(--alert-critical); color: #fff; 
    font-size: 0.65rem; font-weight: 800; min-width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}

/* Cards */
.card {
    background: var(--bg-card); border-radius: 24px;
    padding: 20px; border: 1px solid var(--border-color); margin-bottom: 16px;
    box-shadow: var(--shadow-premium); transition: transform 0.2s;
}
.card:active { transform: scale(0.98); }

.card-title { font-weight: 800; font-size: 1.1rem; color: var(--text-main); letter-spacing: -0.3px; }
.card-subtitle { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* Dashboard Trends */
.chart-container {
    width: 100%; height: 220px; margin-top: 16px; position: relative;
}

/* Today Hub Blocks */
.today-grid {
    display: grid; grid-template-columns: 1fr; gap: 16px;
}

.status-indicator {
    padding: 6px 12px; border-radius: 12px; font-size: 0.75rem; font-weight: 800;
    text-transform: uppercase;
}
.status-todo { background: #eff6ff; color: #2563eb; }
.status-late { background: #fef2f2; color: #dc2626; }
.status-done { background: #f0fdf4; color: #16a34a; }

/* Onboarding */
.onboarding-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.95);
    z-index: 5000; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px; color: #fff; text-align: center;
}
.onboarding-card {
    max-width: 340px; width: 100%;
}
.onboarding-img {
    font-size: 5rem; margin-bottom: 32px; color: var(--btn-primary);
}
.onboarding-dots {
    display: flex; gap: 8px; justify-content: center; margin: 32px 0;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.3); }
.dot.active { background: var(--btn-primary); width: 24px; border-radius: 4px; }

/* Specific components for Audit Suspect */
.badge-suspect {
    background: #fff7ed; color: #c2410c; border: 1px solid #ffedd5;
    padding: 4px 8px; border-radius: 8px; font-size: 0.7rem; font-weight: 800;
}

/* ========================================
   RESPONSIVE — DESKTOP (768px+)
   ======================================== */
@media (min-width: 768px) {
    #app { max-width: 1000px; margin: 0 auto; box-shadow: 0 0 100px rgba(0,0,0,0.1); position: relative; }
    .today-grid { grid-template-columns: 1fr 1fr; }
    .desktop-grid {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px;
    }
}

.flex-between { display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 0.9rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin: 24px 0 12px 0; }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal-card {
    background: #fff; width: 90%; max-width: 450px; border-radius: 32px; padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 32px; }
.btn-huge {
    border: none; border-radius: 24px; padding: 32px 16px; font-size: 1.2rem; font-weight: 800;
    cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 12px; transition: all 0.2s;
}
.btn-yes { background: #f0fdf4; color: #16a34a; }
.btn-no { background: #fef2f2; color: #dc2626; }
.btn-huge:active { transform: scale(0.95); }

.tag { padding: 4px 10px; border-radius: 8px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; }
.tag-urgent { background: #fee2e2; color: #ef4444; }
.tag-normal { background: #f1f5f9; color: #64748b; }
.tag-moyen { background: #fef9c3; color: #92400e; }

/* ========================================
   CLASSES UTILITAIRES ESSENTIELLES (app.js)
   ======================================== */

/* Bouton interne */
.btn-primary {
    width: 100%; padding: 14px; border: 1px solid var(--border-color);
    border-radius: 14px; font-family: inherit; font-size: 0.9rem; font-weight: 700;
    cursor: pointer; background: var(--bg-main); color: var(--text-main); transition: all 0.2s;
}
.btn-primary:hover { background: #f1f5f9; }
.btn-primary:active { transform: scale(0.98); }

/* Filtre pill */
.filter-btn {
    padding: 8px 14px; border: 1px solid var(--border-color);
    border-radius: 100px; font-family: inherit; font-size: 0.8rem; font-weight: 700;
    cursor: pointer; background: var(--bg-main); color: var(--text-muted); white-space: nowrap; transition: all 0.15s;
}
.filter-btn.active { background: var(--text-main); color: #fff; border-color: var(--text-main); }

/* Input interne */
.input-primary {
    width: 100%; padding: 14px 16px; border: 1px solid var(--border-color);
    border-radius: 14px; font-family: inherit; font-size: 0.95rem;
    background: var(--bg-main); color: var(--text-main); outline: none; transition: all 0.2s;
    -webkit-appearance: none; appearance: none;
}
.input-primary:focus { border-color: var(--btn-primary); background: #fff; box-shadow: 0 0 0 3px rgba(0,71,255,0.12); }

/* Formulaires */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }

/* Flex utilities */
.flex-row { display: flex; align-items: center; gap: 8px; }

/* Barre de filtres */
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.filter-bar::-webkit-scrollbar { display: none; }

/* Progress bar */
.progress-bar { width: 100%; height: 8px; background: #f1f5f9; border-radius: 100px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--btn-primary); border-radius: 100px; transition: width 0.4s; }

/* Dashboard */
.dash-card {
    background: var(--bg-card); border-radius: 24px; padding: 20px;
    border: 1px solid var(--border-color); box-shadow: var(--shadow-premium);
}
.dash-score-badge { font-size: 1.8rem; font-weight: 900; }
.score-good { color: var(--alert-success); }
.score-avg { color: var(--alert-warning); }
.score-bad { color: var(--alert-critical); }
.dash-data-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-color); cursor: pointer; }
.dash-data-row:last-child { border: none; }
.dash-dtitle { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.dash-dval { font-size: 1rem; font-weight: 900; color: var(--text-main); }
.dash-dval.red { color: var(--alert-critical); }

/* Chips */
.audit-chip { display: inline-block; padding: 4px 10px; border-radius: 8px; font-size: 0.7rem; font-weight: 800; }
.tag-status { display: inline-block; padding: 4px 10px; border-radius: 8px; font-size: 0.7rem; font-weight: 800; }

/* Vue */
.view { padding-bottom: 24px; }

/* Lightbox */
.lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.lightbox-close { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.15); border: none; color: #fff; font-size: 1.4rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#lightbox-img { max-width: 92vw; max-height: 85vh; border-radius: 16px; object-fit: contain; }

/* Divers */
.photo-thumb { border-radius: 12px; }
.score-ring { font-size: 2rem; font-weight: 900; }

/* ========================================
   CLASSES MANQUANTES (audit, todo, layout)
   ======================================== */

/* Bouton / zone de capture photo dans les modales */
.photo-placeholder {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 16px; margin-bottom: 12px;
    background: #f8fafc; border: 2px dashed var(--border-color);
    border-radius: 16px; cursor: pointer; color: var(--text-muted);
    font-weight: 700; font-size: 0.9rem; transition: all 0.2s;
}
.photo-placeholder:active { background: #f1f5f9; }
.photo-placeholder.mandatory { border-color: var(--alert-warning); color: var(--alert-warning); }
.photo-placeholder.has-photo { border-color: var(--alert-success); background: #f0fdf4; color: var(--alert-success); border-style: solid; }

/* Barre de progression dans les audits et to-do actifs */
.checklist-progress {
    background: var(--bg-card); border-radius: 20px;
    padding: 16px 20px; margin-bottom: 20px;
    border: 1px solid var(--border-color); box-shadow: var(--shadow-premium);
}

/* Texte de la question d'audit */
.question-text {
    font-size: 1.15rem; font-weight: 700; color: var(--text-main);
    line-height: 1.5; margin: 20px 0;
}

/* Espaceur générique */
.spacer-16 { height: 16px; }

/* Masqué sur desktop, visible mobile */
@media (min-width: 768px) {
    .mobile-only { display: none !important; }
}
@media (max-width: 1023px) {
    .desktop-only { display: none !important; }
}

/* En-tête d'une carte de tâche */
.task-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}

/* ========================================
   PWA / MOBILE OPTIMISATIONS
   ======================================== */

/* Safe area insets pour les appareils avec notch / Dynamic Island */
@supports (padding-top: env(safe-area-inset-top)) {
    #app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }
    #bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    }
    #main-content {
        padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
    }
}

/* Boutons plus tactiles sur mobile */
@media (max-width: 1023px) {
    .btn-primary {
        min-height: 48px;
    }
    .btn-large-primary {
        min-height: 54px;
    }
    .btn-yes, .btn-no {
        min-height: 72px;
    }
    /* Inputs plus grands au toucher */
    .input-primary, .input-light {
        min-height: 48px;
        font-size: 1rem;
    }
    /* Cards avec padding confortable */
    .card {
        padding: 18px;
    }
    /* Filtre bar avec scroll doux */
    .filter-bar {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding: 4px 0 10px;
    }
    .filter-btn {
        scroll-snap-align: start;
        flex-shrink: 0;
    }
}

/* Splash screen PWA — transition douce au démarrage */
@media (display-mode: standalone) {
    /* En mode app installée, retire les artefacts navigateur */
    body {
        overscroll-behavior: none;
    }
    /* Header légèrement plus haut pour le status bar */
    #app-header {
        background: rgba(255,255,255,0.95);
    }
}
