/* ═══════════════════════════════════════════════════════════
   TrustQuick — Theme System (source: login.html)
   Fichier partage par TOUTES les pages du dashboard.
   Dark mode par defaut, toggle light/dark.
   ═══════════════════════════════════════════════════════════ */

/* ─── Tokens Dark (defaut) ─── */
:root {
    --bg: #000000;
    --bg-2: #0A0A0A;
    --bg-card: #111113;
    --bg-card-hover: #19191B;
    --text: #F5F5F7;
    --text-2: rgba(245, 245, 247, 0.72);
    --text-3: rgba(245, 245, 247, 0.48);
    --text-4: rgba(245, 245, 247, 0.32);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.18);
    --btn-bg: #F5F5F7;
    --btn-bg-hover: #FFFFFF;
    --btn-fg: #000000;
    --blue: #4A8BF5;
    --blue-hover: #6BA1F7;
    --blue-glow: rgba(74, 139, 245, 0.5);
    --blue-light: rgba(74, 139, 245, 0.12);
    --red: #FF6B6B;
    --red-light: rgba(255, 107, 107, 0.12);
    --green: #34D399;
    --green-light: rgba(52, 211, 153, 0.12);
    --orange: #FBBF24;
    --orange-light: rgba(251, 191, 36, 0.12);
    --purple: #A78BFA;
    --purple-light: rgba(167, 139, 250, 0.12);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 999px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    --sidebar-bg: #09090B;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: rgba(245, 245, 247, 0.48);
    --sidebar-text-hover: #F5F5F7;
    --sidebar-active-bg: rgba(74, 139, 245, 0.12);
    --sidebar-active-text: #F5F5F7;
}

/* ─── Tokens Light ─── */
[data-theme="light"] {
    --bg: #FFFFFF;
    --bg-2: #F5F5F7;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FAFAFA;
    --text: #09090B;
    --text-2: rgba(9, 9, 11, 0.72);
    --text-3: rgba(9, 9, 11, 0.52);
    --text-4: rgba(9, 9, 11, 0.36);
    --line: rgba(9, 9, 11, 0.08);
    --line-strong: rgba(9, 9, 11, 0.18);
    --btn-bg: #09090B;
    --btn-bg-hover: #1A1A1D;
    --btn-fg: #FFFFFF;
    --blue: #2563EB;
    --blue-hover: #3B82F6;
    --blue-glow: rgba(37, 99, 235, 0.3);
    --blue-light: rgba(37, 99, 235, 0.08);
    --red: #EF4444;
    --red-light: rgba(239, 68, 68, 0.08);
    --green: #10B981;
    --green-light: rgba(16, 185, 129, 0.08);
    --orange: #F59E0B;
    --orange-light: rgba(245, 158, 11, 0.08);
    --purple: #8B5CF6;
    --purple-light: rgba(139, 92, 246, 0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
    --sidebar-bg: #FAFAFA;
    --sidebar-border: rgba(9, 9, 11, 0.08);
    --sidebar-text: rgba(9, 9, 11, 0.52);
    --sidebar-text-hover: #09090B;
    --sidebar-active-bg: rgba(74, 139, 245, 0.08);
    --sidebar-active-text: #09090B;
}

/* ─── Reset ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.015em;
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ─── Theme Toggle (top-right) ─── */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--line);
    color: var(--text-2);
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}
[data-theme="light"] .theme-toggle {
    background: rgba(0,0,0,0.04);
}
.theme-toggle:hover {
    color: var(--text);
    border-color: var(--line-strong);
    transform: scale(1.05);
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ─── Dashboard Layout ─── */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: background 0.4s ease, border-color 0.4s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 24px 20px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--text);
    text-transform: uppercase;
}
.sidebar-brand svg { flex-shrink: 0; }
.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s ease;
}
.sidebar-nav-item:hover {
    color: var(--sidebar-text-hover);
    background: var(--line);
}
.sidebar-nav-item.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    font-weight: 600;
}
.sidebar-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 2;
}
.sidebar-bottom {
    padding: 12px;
    border-top: 1px solid var(--line);
    margin-top: auto;
}
.sidebar-nav-item.danger { color: var(--red); }
.sidebar-nav-item.danger:hover { background: var(--red-light); }

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    min-width: 0;
}
.page-header {
    margin-bottom: 32px;
}
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.page-subtitle {
    font-size: 14px;
    color: var(--text-3);
    margin-top: 6px;
    font-weight: 400;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all 0.25s ease;
}
.card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1;
}

/* ─── KPI Cards ─── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.kpi-card:hover {
    border-color: var(--line-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ─── Badges / Pills ─── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }

/* ─── Buttons ─── */
.btn-primary {
    height: 44px;
    padding: 0 24px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    border: none;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}
.btn-primary:hover {
    background: var(--btn-bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px -4px rgba(0,0,0,0.2);
}

.btn-ghost {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--line-strong); color: var(--text); }
.btn-ghost.active { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }

/* ─── Chart Cards ─── */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all 0.25s ease;
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.10s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.20s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.30s; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .dashboard-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; }
    .main-content { padding: 20px; }
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ─── Theme Toggle JS (inline dans chaque page) ─── */
/*
<script>
(function(){
    var root = document.documentElement;
    var btn = document.getElementById('theme-toggle');
    var saved = localStorage.getItem('trustquick_theme') || 'dark';
    if (saved === 'light') root.setAttribute('data-theme', 'light');
    if (btn) btn.addEventListener('click', function() {
        var isLight = root.getAttribute('data-theme') === 'light';
        if (isLight) {
            root.removeAttribute('data-theme');
            localStorage.setItem('trustquick_theme', 'dark');
        } else {
            root.setAttribute('data-theme', 'light');
            localStorage.setItem('trustquick_theme', 'light');
        }
    });
})();
</script>
*/
