/* =============================================================
   AMSTOCK — DESIGN TOKENS + BASE
   Variables CSS, fonts, body, scrollbars, dark mode tokens.
   ============================================================= */

:root {
    /* Brand */
    --brand-50:  #eef0ff;
    --brand-100: #e0e3ff;
    --brand-200: #c7ccff;
    --brand-300: #a5acff;
    --brand-400: #828cf5;
    --brand-500: #667eea;
    --brand-600: #5b6ee0;
    --brand-700: #4f5fc7;
    --brand-800: #3f4c9c;
    --brand-900: #2e3878;

    --accent-500: #8b5cf6;
    --accent-600: #7c3aed;

    --surface-app: #f5f7fb;
    --surface-card: #ffffff;
    --surface-soft: #f8fafc;
    --surface-hover: #f1f5f9;
    --surface-elev: #ffffff;

    --text-strong: #0f172a;
    --text-base:   #1e293b;
    --text-muted:  #475569;
    --text-soft:   #64748b;
    --text-faint:  #94a3b8;

    --border-soft:   #eef0f4;
    --border-base:   #e5e7eb;
    --border-strong: #d1d5db;

    --success-500: #10b981;
    --success-600: #059669;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --danger-500:  #ef4444;
    --danger-600:  #dc2626;
    --info-500:    #3b82f6;
    --info-600:    #2563eb;

    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 22px;
    --radius-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 20px -8px rgba(15, 23, 42, 0.12), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
    --shadow-xl: 0 20px 35px -12px rgba(15, 23, 42, 0.18), 0 8px 16px -8px rgba(15, 23, 42, 0.08);
    --shadow-2xl: 0 30px 60px -20px rgba(15, 23, 42, 0.25);
    --shadow-brand: 0 8px 20px -6px rgba(102, 126, 234, 0.45);
    --shadow-brand-sm: 0 4px 10px -2px rgba(102, 126, 234, 0.35);
    --shadow-success: 0 8px 20px -6px rgba(16, 185, 129, 0.40);
    --shadow-danger:  0 8px 20px -6px rgba(239, 68, 68, 0.40);

    --focus-ring: 0 0 0 3px rgba(102, 126, 234, 0.30);
    --focus-ring-danger: 0 0 0 3px rgba(239, 68, 68, 0.25);

    --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --easing-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Base body — n'écrase pas les styles existants si déjà set en inline */
body {
    background:
        radial-gradient(1200px 800px at 0% -10%, rgba(102, 126, 234, 0.07), transparent 60%),
        radial-gradient(1000px 700px at 100% 0%, rgba(139, 92, 246, 0.06), transparent 55%),
        var(--surface-app) !important;
    color: var(--text-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    text-rendering: optimizeLegibility;
    letter-spacing: -0.005em;
}

::selection { background: rgba(102, 126, 234, 0.22); color: var(--text-strong); }

/* Scrollbars premium */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.30);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.55); background-clip: padding-box; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 6px;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    letter-spacing: -0.02em;
}

/* ========================================================
   DARK MODE TOKENS (à activer via [data-theme="dark"])
   ======================================================== */
[data-theme="dark"] {
    --surface-app:   #0a0f1c;
    --surface-card:  #141a2d;
    --surface-soft:  #0f1525;
    --surface-hover: #1c2340;
    --surface-elev:  #1a2138;

    --text-strong: #f1f5f9;
    --text-base:   #e2e8f0;
    --text-muted:  #a1afc5;
    --text-soft:   #8794ad;
    --text-faint:  #556179;

    --border-soft:   #1e2638;
    --border-base:   #2a334a;
    --border-strong: #3b4866;

    --brand-50:  rgba(129, 140, 248, 0.10);
    --brand-100: rgba(129, 140, 248, 0.18);
    --brand-200: rgba(129, 140, 248, 0.28);
    --brand-300: #7986f1;
    --brand-700: #a5b4fc;
    --brand-800: #c7d2fe;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.40);
    --shadow-md: 0 6px 10px -2px rgba(0, 0, 0, 0.50);
    --shadow-lg: 0 14px 28px -10px rgba(0, 0, 0, 0.55);
    --shadow-xl: 0 24px 44px -12px rgba(0, 0, 0, 0.65);
    --shadow-2xl: 0 30px 60px -16px rgba(0, 0, 0, 0.75);

    color-scheme: dark;
}
[data-theme="dark"] body {
    background:
        radial-gradient(1400px 900px at -5% -5%, rgba(99, 102, 241, 0.18), transparent 55%),
        radial-gradient(1100px 800px at 100% 0%, rgba(168, 85, 247, 0.14), transparent 50%),
        var(--surface-app) !important;
    color: var(--text-base);
}

/* AG Grid alpine variables */
.ag-theme-alpine {
    --ag-foreground-color: var(--text-base);
    --ag-background-color: var(--surface-card);
    --ag-header-background-color: #f4f6fb;
    --ag-header-foreground-color: var(--text-strong);
    --ag-odd-row-background-color: #fafbfd;
    --ag-row-hover-color: var(--brand-50);
    --ag-selected-row-background-color: rgba(102, 126, 234, 0.10);
    --ag-border-color: var(--border-soft);
    --ag-row-border-color: var(--border-soft);
    --ag-control-panel-background-color: var(--surface-soft);
    --ag-input-focus-border-color: var(--brand-500);
    --ag-input-focus-box-shadow: var(--focus-ring);
    --ag-borders: solid 1px;
    --ag-border-radius: 12px;
    --ag-cell-horizontal-padding: 14px;
    --ag-grid-size: 6px;
    --ag-list-item-height: 30px;
    --ag-font-family: inherit;
    --ag-font-size: 13px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-soft);
}
.ag-theme-alpine .ag-row { transition: background-color var(--t-fast); }
.ag-theme-alpine .ag-cell { display: flex; align-items: center; }

[data-theme="dark"] .ag-theme-alpine {
    --ag-foreground-color: var(--text-base);
    --ag-background-color: var(--surface-card);
    --ag-header-background-color: #1a2138;
    --ag-header-foreground-color: var(--text-strong);
    --ag-odd-row-background-color: #121828;
    --ag-row-hover-color: rgba(129, 140, 248, 0.12);
    --ag-selected-row-background-color: rgba(129, 140, 248, 0.18);
    --ag-border-color: var(--border-soft);
    --ag-row-border-color: var(--border-soft);
    --ag-control-panel-background-color: var(--surface-soft);
    --ag-subheader-background-color: var(--surface-soft);
    --ag-panel-background-color: var(--surface-card);
    --ag-menu-background-color: var(--surface-card);
    --ag-modal-overlay-background-color: rgba(10, 15, 28, 0.6);
    --ag-input-background-color: var(--surface-soft);
    --ag-input-border-color: var(--border-base);
}

/* Cards & containers (override partial des classes existantes AMSTOCK) */
[data-theme="dark"] .hub-content,
[data-theme="dark"] .page-container,
[data-theme="dark"] .config-card,
[data-theme="dark"] .hub-card {
    background: transparent;
    color: var(--text-base);
}
[data-theme="dark"] .hub-card,
[data-theme="dark"] .config-card {
    background: var(--surface-card) !important;
    border-color: var(--border-soft) !important;
    color: var(--text-base) !important;
}

/* Boutons admin existants AMSTOCK : adapter en dark */
[data-theme="dark"] .btn-logout {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}
