/* ═══════════════════════════════════════════════════════════════════════
   app.css — Plateforme Épidémiologie · Design System (Light Mode)
   Stack: Tailwind CSS CDN + Alpine.js + GSAP
═══════════════════════════════════════════════════════════════════════ */

body { font-family: 'Inter', sans-serif; }

/* ─── CSS Custom Properties (Light Theme) ───────────────────────────── */
:root {
    --sidebar-w:       240px;
    --sidebar-mini:    68px;
    --topbar-h:        60px;

    --accent:          #0284C7;   /* sky-600 */
    --accent-dark:     #0369A1;   /* sky-700 */
    --accent-2:        #7C3AED;   /* violet-700 */
    --accent-light:    #E0F2FE;   /* sky-100 */
    --accent-2-light:  #EDE9FE;   /* violet-100 */

    --bg-base:         #F1F5F9;   /* slate-100 */
    --bg-surface:      #FFFFFF;
    --bg-card:         #FFFFFF;
    --bg-elevated:     #F8FAFC;   /* slate-50 */

    --border:          #E2E8F0;   /* slate-200 */
    --border-hover:    #93C5FD;   /* blue-300 */

    --text-primary:    #0F172A;   /* slate-900 */
    --text-muted:      #64748B;   /* slate-500 */

    --radius:          10px;
    --transition:      all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Custom Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: #F1F5F9; }
::-webkit-scrollbar-thumb  { background: #CBD5E1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ─── Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ─── Page Loader ────────────────────────────────────────────────────── */
#page-loader {
    position: fixed; inset: 0;
    background: #FFFFFF;
    display: flex; align-items: center; justify-content: center;
    z-index: 99999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
#page-loader.hidden { opacity: 0; visibility: hidden; }

.loader-ring {
    width: 44px; height: 44px;
    border: 3px solid #E2E8F0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── App Shell ──────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────────────── */
#sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 200;
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1),
                transform 0.3s cubic-bezier(0.4,0,0.2,1);
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(15,23,42,0.04);
}

#sidebar.collapsed  { width: var(--sidebar-mini); }
#sidebar.mobile-hidden { transform: translateX(-100%); }

.sidebar-brand {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; overflow: hidden; white-space: nowrap;
}

.sidebar-brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff; flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(2,132,199,0.28);
}

.sidebar-brand-text { font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.2; transition: opacity 0.2s; }
.sidebar-brand-text small { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-muted); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.sidebar-section-label {
    font-size: 10px; font-weight: 600; letter-spacing: 1px;
    text-transform: uppercase; color: #94A3B8;
    padding: 4px 10px; margin-bottom: 4px;
    transition: opacity 0.2s; white-space: nowrap; overflow: hidden;
}

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; border-radius: 8px;
    color: var(--text-muted); text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    transition: var(--transition);
    white-space: nowrap; overflow: hidden;
    margin-bottom: 2px; position: relative;
}
.nav-link:hover { background: var(--accent-light); color: var(--accent); }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-link.active::before {
    content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}

.nav-link-icon {
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0; transition: var(--transition);
    background: #F1F5F9;
}
.nav-link:hover .nav-link-icon,
.nav-link.active .nav-link-icon { background: #DBEAFE; color: var(--accent); }

.nav-link-label { flex: 1; transition: opacity 0.2s; }

#sidebar.collapsed .nav-link-label,
#sidebar.collapsed .sidebar-brand-text,
#sidebar.collapsed .sidebar-section-label { opacity: 0; pointer-events: none; }
#sidebar.collapsed .nav-link      { justify-content: center; }
#sidebar.collapsed .sidebar-brand { justify-content: center; padding: 0; }

.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ─── Main Content ───────────────────────────────────────────────────── */
#main-wrap {
    flex: 1; margin-left: var(--sidebar-w);
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
    min-height: 100vh; display: flex; flex-direction: column;
}
#main-wrap.sidebar-collapsed { margin-left: var(--sidebar-mini); }

/* ─── Top Navbar ─────────────────────────────────────────────────────── */
#topbar {
    height: var(--topbar-h);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px; position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
}

.topbar-btn {
    width: 36px; height: 36px; border-radius: 8px;
    background: #F8FAFC; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 14px;
    cursor: pointer; transition: var(--transition);
}
.topbar-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--border-hover); }

.dropdown { position: relative; }

.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius); min-width: 230px; padding: 6px;
    box-shadow: 0 12px 40px rgba(15,23,42,0.12), 0 2px 8px rgba(15,23,42,0.05);
    z-index: 300;
}

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 7px;
    font-size: 13.5px; color: var(--text-muted);
    text-decoration: none; transition: var(--transition);
    cursor: pointer; background: none; border: none; width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--accent-light); color: var(--accent); }
.dropdown-item.danger:hover { background: #FEF2F2; color: #DC2626; }

.dropdown-separator { height: 1px; background: var(--border); margin: 6px 0; }

/* ─── Page Content ───────────────────────────────────────────────────── */
.page-content { flex: 1; padding: 28px; }
.page-header  { margin-bottom: 24px; }
.page-title   { font-size: 1.375rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.page-subtitle{ font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
    transition: var(--transition); overflow: hidden;
}
.card:hover { border-color: var(--border-hover); box-shadow: 0 4px 16px rgba(15,23,42,0.08); }

.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--bg-elevated);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-body  { padding: 20px; }

/* Stat cards */
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px;
    display: flex; flex-direction: column; gap: 12px;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
}
.stat-card:hover {
    border-color: var(--border-hover); transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15,23,42,0.09);
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -1px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

/* Action cards */
.action-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    display: flex; flex-direction: column;
    transition: var(--transition); cursor: pointer;
    text-decoration: none; color: inherit;
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
}
.action-card:hover {
    border-color: var(--border-hover); transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(15,23,42,0.1); color: inherit;
}
.action-card-img { width: 100%; height: 200px; object-fit: cover; transition: transform 0.4s ease; }
.action-card:hover .action-card-img { transform: scale(1.03); }

.action-card-body { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.action-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.action-card-sub   { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 18px; border-radius: 8px;
    font-size: 13.5px; font-weight: 500; cursor: pointer;
    text-decoration: none; transition: var(--transition);
    border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(2,132,199,0.22); }
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 4px 16px rgba(2,132,199,0.3); transform: translateY(-1px); color: #fff; }

.btn-secondary { background: #F8FAFC; color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: #F1F5F9; border-color: #CBD5E1; color: var(--text-primary); }

.btn-danger { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; border-color: #FCA5A5; }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: #F1F5F9; color: var(--text-primary); }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: 10px; }

/* ─── Badges ─────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 50px; font-size: 11.5px; font-weight: 600; }
.badge-cyan   { background: #E0F2FE; color: #0369A1; }
.badge-purple { background: #EDE9FE; color: #6D28D9; }
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-amber  { background: #FEF3C7; color: #B45309; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-gray   { background: #F1F5F9; color: #475569; }

/* ─── Forms ──────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 18px; }
.form-label  { display: block; font-size: 12.5px; font-weight: 500; color: #475569; margin-bottom: 7px; }

.form-input, .form-select, .form-textarea {
    width: 100%; background: #fff;
    border: 1.5px solid #D1D5DB; border-radius: 8px;
    padding: 10px 14px; font-size: 14px; font-family: 'Inter', sans-serif;
    color: var(--text-primary); transition: var(--transition);
    outline: none; appearance: none; -webkit-appearance: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: #9CA3AF; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}
.form-input.error, .form-select.error { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }
.form-input.error:focus, .form-select.error:focus { box-shadow: 0 0 0 3px rgba(220,38,38,0.2); }

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%2364748B' 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 12px center;
    background-size: 16px; padding-right: 36px; cursor: pointer;
}
.form-select option { background: #fff; color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-hint     { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.input-wrap { position: relative; }
.input-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #9CA3AF; font-size: 14px; pointer-events: none; }
.input-wrap .form-input { padding-left: 38px; }
.input-wrap:focus-within .input-icon { color: var(--accent); }

.input-action { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #9CA3AF; font-size: 14px; cursor: pointer; transition: color 0.2s; }
.input-action:hover { color: var(--accent); }

.strength-track { height: 3px; background: #E2E8F0; border-radius: 2px; overflow: hidden; margin-top: 6px; }
.strength-fill  { height: 100%; border-radius: 2px; transition: width 0.4s ease, background 0.4s ease; }

/* ─── Alerts ─────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; }
.alert-error  { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.alert-success{ background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.alert-info   { background: #EFF6FF; border-color: #BFDBFE; color: #1D4ED8; }

/* ─── Tables ─────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.data-table thead th { padding: 10px 14px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); background: var(--bg-elevated); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 13px 14px; color: var(--text-primary); border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── Pagination ─────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn, .page-btn-active { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; border-radius: 7px; font-size: 13px; font-weight: 500; text-decoration: none; transition: var(--transition); padding: 0 8px; }
.page-btn { background: #fff; border: 1px solid var(--border); color: var(--text-muted); }
.page-btn:hover { border-color: var(--border-hover); color: var(--accent); background: var(--accent-light); }
.page-btn-active { background: var(--accent-light); border: 1px solid var(--border-hover); color: var(--accent); font-weight: 600; }

/* ─── Auth Pages ─────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 60%, #F5F3FF 100%);
    display: flex; align-items: stretch; position: relative; overflow: hidden;
}

.auth-grid {
    position: absolute; inset: 0;
    background-image: radial-gradient(circle, rgba(2,132,199,0.07) 1px, transparent 1px);
    background-size: 28px 28px; pointer-events: none;
}

.auth-glow { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; }

.auth-panel { width: 100%; max-width: 460px; margin: auto; padding: 40px 20px; position: relative; z-index: 2; }

.auth-card {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 16px; padding: 36px;
    box-shadow: 0 10px 40px rgba(15,23,42,0.1), 0 2px 8px rgba(15,23,42,0.05);
}

.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-logo-icon { width: 44px; height: 44px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; box-shadow: 0 4px 14px rgba(2,132,199,0.28); }
.auth-logo-text { font-size: 15px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.auth-logo-text small { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }

.auth-title    { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-muted); margin-bottom: 26px; line-height: 1.65; }

/* ─── Checkboxes ─────────────────────────────────────────────────────── */
.check-group { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.check-group input[type="checkbox"],
.check-group input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.check-group label { font-size: 13.5px; color: var(--text-muted); cursor: pointer; user-select: none; }

/* ─── Utilities ──────────────────────────────────────────────────────── */
.text-gradient { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.gsap-from { opacity: 0; transform: translateY(20px); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
    #sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
    #sidebar.mobile-open { transform: translateX(0); }
    #main-wrap { margin-left: 0 !important; }
    .page-content { padding: 20px 16px; }
}

#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.3); z-index: 150; backdrop-filter: blur(2px); }

@media (max-width: 640px) {
    .auth-card  { padding: 24px 18px; }
    .auth-panel { padding: 20px 16px; }
}

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
