/* === BASE: Variables, Reset, Typography, Icons === */

/* Fonts are loaded via Google Fonts in index.html */

/* Variables */
:root {
    /* Colors (RGB for rgba() usage) */
    --c-primary: 26, 28, 30;
    --c-second: 100, 106, 115;
    --c-accent: 37, 99, 235;
    --c-inverse: 255, 255, 255;
    --c-error: 220, 38, 38;
    --c-gray: 248, 250, 252;

    /* Text */
    --txt-primary: rgba(var(--c-primary), 1);
    --txt-second: rgba(var(--c-second), 1);
    --txt-tertiary: rgba(var(--c-second), 0.6);
    --txt-accent: rgba(var(--c-accent), 1);
    --txt-inverse: rgba(var(--c-inverse), 1);
    --txt-error: rgba(var(--c-error), 1);

    /* Backgrounds */
    --bg-primary: rgba(var(--c-inverse), 1);
    --bg-second: #f4f6f8;
    --bg-hover: #eef1f5;
    --bg-dark: rgba(var(--c-primary), 1);

    /* Borders */
    --bd-default: rgba(15, 23, 42, 0.08);
    --bd-divider: rgba(15, 23, 42, 0.04);
    --bd-hover: rgba(15, 23, 42, 0.16);

    /* Buttons */
    --btn-primary: rgba(var(--c-primary), 1);
    --btn-brand: rgba(var(--c-accent), 1);
    --btn-second: rgba(15, 23, 42, 0.05);
    --btn-disabled: rgba(var(--c-primary), 0.06);

    /* Status */
    --green: #16a34a;
    --green-bg: rgba(22, 163, 74, 0.08);
    --yellow: #d97706;
    --yellow-bg: rgba(217, 119, 6, 0.08);
    --red: #dc2626;
    --red-bg: rgba(220, 38, 38, 0.08);
    --blue: #2563eb;
    --blue-bg: rgba(37, 99, 235, 0.08);

    /* Shadows — tinted to slate, not pure black */
    --shadow-block: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-btn: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-light: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
    --shadow-card-hover: 0 8px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -3px rgba(15, 23, 42, 0.04);
    --shadow-elevated: 0 20px 40px -12px rgba(15, 23, 42, 0.12), 0 8px 20px -8px rgba(15, 23, 42, 0.06);

    /* Shape */
    --radius-card: 0.875rem;
    --radius-lg: 1.125rem;
    --radius-xl: 1.5rem;
    --radius-btn: 0.5rem;
    --radius-input: 0.5rem;
    --radius-sm: 0.375rem;

    /* Transitions */
    --trans-fast: 0.15s ease;
    --trans-base: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --trans-long: 0.35s cubic-bezier(0.16, 1, 0.3, 1);

    /* Layout */
    --sidebar-width: 260px;
    --max-width: 1280px;
    --font-heading: 'Outfit', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
}

/* Dark Theme — deep, rich dark with subtle warmth */
[data-theme="dark"] {
    --c-primary: 237, 237, 240;
    --c-second: 148, 150, 160;
    --c-inverse: 16, 16, 20;
    --c-gray: 10, 10, 13;

    --bg-primary: #161618;
    --bg-second: #0e0e10;
    --bg-hover: #222226;
    --bg-dark: rgba(var(--c-primary), 1);

    --bd-default: rgba(255, 255, 255, 0.07);
    --bd-divider: rgba(255, 255, 255, 0.04);
    --bd-hover: rgba(255, 255, 255, 0.14);

    --btn-primary: #ededed;
    --btn-second: rgba(255, 255, 255, 0.06);
    --btn-disabled: rgba(255, 255, 255, 0.04);

    --shadow-block: 0 4px 12px -2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-btn: 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-card-hover: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-elevated: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 20px 40px rgba(0, 0, 0, 0.4);

    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, 0.12);

    color-scheme: dark;
}

[data-theme="dark"] .select-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23a0a0a0'/%3E%3C/svg%3E");
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    background: var(--bg-second);
    color: var(--txt-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    color: var(--txt-primary);
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.035em;
}

h2 {
    font-size: 1.1875rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.015em;
}

h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

a {
    color: var(--txt-accent);
    text-decoration: none;
    transition: color var(--trans-base);
}

a:hover {
    opacity: 0.8;
}

.text-muted {
    color: var(--txt-second);
}

.hidden {
    display: none !important;
}

::selection {
    background: rgba(var(--c-accent), 0.2);
    color: var(--txt-primary);
}

/* Focus visible — accessibility */
:focus-visible {
    outline: 2px solid rgba(var(--c-accent), 0.5);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid rgba(var(--c-accent), 0.5);
    outline-offset: 2px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bd-default);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bd-hover);
}

/* SVG Icons */
.icn {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: currentColor;
}

.icn--sm {
    width: 16px;
    height: 16px;
}

.icn--lg {
    width: 24px;
    height: 24px;
}

.icn--xl {
    width: 32px;
    height: 32px;
}

/* Loading spinner — refined */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem;
}

.loading-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 2.5px solid var(--bd-default);
    border-top-color: rgba(var(--c-accent), 1);
    border-radius: 50%;
    animation: spin 0.65s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton shimmer loader */
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-second) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.error-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--txt-second);
}