/* ============================================ */
/* AgentDeck — Design System v2.0               */
/* Based on: redesign-skill audit + ui-ux-pro-max data */
/* Palette: Developer Tool/IDE (#81)            */
/* Typography: Tech Startup (#3)                */
/* NOTE: v2 tokens (--ink, --teal, --sb-*) are  */
/* in css/theme.css — do NOT duplicate here.    */
/* ============================================ */

/* ============================================ */
/* DESIGN TOKENS                                */
/* ============================================ */

:root {

    /* Type Scale (base 15px, 1.25 ratio) */
    --text-xs: 0.75rem;
    /* 11.25px — labels, badges */
    --text-sm: 0.8125rem;
    /* 12.19px — captions, meta */
    --text-base: 1rem;
    /* 15px — body text */
    --text-md: 1.125rem;
    /* 16.88px — card titles */
    --text-lg: 1.25rem;
    /* 18.75px — section titles */
    --text-xl: 1.5rem;
    /* 22.5px — page subtitles */
    --text-2xl: 1.75rem;
    /* 26.25px — page titles */
    --text-3xl: 2.25rem;
    /* 33.75px — hero subtitles */
    --text-4xl: 3rem;
    /* 45px — hero titles */
    --text-5xl: 4rem;
    /* 60px — landing hero */

    /* --- Spacing Scale (4px base) --- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;

    /* --- Border Radius Scale --- */
    --radius-sm: 4px;
    /* badges, chips */
    --radius-md: 6px;
    /* inputs, pills */
    --radius-lg: 10px;
    /* cards, dropdown */
    --radius-xl: 14px;
    /* containers, modals */
    --radius-2xl: 20px;
    /* hero cards, landing sections */
    --radius-full: 9999px;
    /* avatars, toggle */

    /* --- Z-Index Scale --- */
    --z-base: 1;
    --z-dropdown: 10;
    --z-sticky: 50;
    --z-nav: 100;
    --z-overlay: 500;
    --z-modal: 1000;
    --z-toast: 1500;
    --z-max: 2000;
}

/* ============================================ */
/* COLOR PALETTE — DARK THEME                   */
/* Inspired by: Vercel, Linear, Raycast         */
/* Accent: Emerald (#10b981) — NOT purple       */
/* ============================================ */

:root,
[data-theme="dark"] {
    /* Backgrounds — neutral slate, no color tint */
    --bg-primary: #0a0f13;
    --bg-secondary: #111820;
    --bg-tertiary: #18212b;
    --bg-card: rgba(17, 24, 32, 0.92);
    --bg-card-hover: rgba(24, 33, 43, 0.95);
    --bg-card-elevated: rgba(30, 40, 52, 0.95);
    --bg-sidebar: #0c1117;
    --bg-input: rgba(24, 33, 43, 0.7);
    --bg-input-focus: rgba(30, 40, 52, 0.9);

    /* Borders — neutral, no accent tint */
    --border: rgba(148, 163, 184, 0.08);
    --border-hover: rgba(148, 163, 184, 0.16);
    --border-focus: rgba(16, 185, 129, 0.4);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0a0f13;

    /* Accent — Emerald Green */
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-muted: rgba(16, 185, 129, 0.15);
    --accent-glow: rgba(16, 185, 129, 0.2);
    --accent-text: #34d399;

    /* Semantic colors */
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #0ea5e9;

    /* Surfaces */
    --glass-bg: rgba(17, 24, 32, 0.7);
    --glass-border: rgba(148, 163, 184, 0.06);

    /* Shadows — tinted to match dark bg, NOT pure black */
    --shadow-sm: 0 1px 3px rgba(0, 8, 16, 0.25);
    --shadow-md: 0 4px 16px rgba(0, 8, 16, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 8, 16, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 8, 16, 0.6);
    --shadow-accent: 0 4px 20px rgba(16, 185, 129, 0.25);

    /* Noise overlay (optional) */
    --noise-opacity: 0.03;
}

/* ============================================ */
/* COLOR PALETTE — LIGHT THEME                  */
/* ============================================ */

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: rgba(241, 245, 249, 0.98);
    --bg-card-elevated: rgba(255, 255, 255, 1);
    --bg-sidebar: #111820;
    --bg-input: rgba(241, 245, 249, 0.9);
    --bg-input-focus: rgba(255, 255, 255, 1);

    --border: rgba(15, 23, 42, 0.06);
    --border-hover: rgba(15, 23, 42, 0.12);
    --border-focus: rgba(16, 185, 129, 0.5);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #f1f5f9;

    --accent: #059669;
    --accent-hover: #047857;
    --accent-muted: rgba(5, 150, 105, 0.08);
    --accent-glow: rgba(5, 150, 105, 0.12);
    --accent-text: #059669;

    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.6);

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.08);
    --shadow-xl: 0 16px 48px rgba(15, 23, 42, 0.1);
    --shadow-accent: 0 4px 20px rgba(5, 150, 105, 0.15);
}

/* ============================================ */
/* BASE TYPOGRAPHY STYLES                       */
/* ============================================ */

html {
    font-size: 15px;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Tabular numbers for all data */
.stat-value,
.stat-tile,
.metric,
[data-numeric] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

code,
pre,
.mono {
    font-family: var(--font-mono);
}

/* Section labels (sidebar, groups) */
.section-label {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ============================================ */
/* COMPONENT: BUTTON                            */
/* ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    padding: var(--space-2) var(--space-4);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97) translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Primary — emerald solid */
.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
    box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

/* Secondary — ghost/outlined */
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Ghost — text only */
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--accent-muted);
}

/* ============================================ */
/* COMPONENT: CARD                              */
/* ============================================ */

.ds-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.ds-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

/* Elevated card — for primary CTAs */
.ds-card-elevated {
    background: var(--bg-card-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
}

.ds-card-elevated:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Accent card — for highlighted sections like Context Builder */
.ds-card-accent {
    background: var(--accent-muted);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
}

/* ============================================ */
/* COMPONENT: BADGE                             */
/* ============================================ */

.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

.ds-badge-success {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}

.ds-badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.ds-badge-error {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.ds-badge-info {
    background: rgba(14, 165, 233, 0.12);
    color: #38bdf8;
}

.ds-badge-neutral {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}

/* ============================================ */
/* COMPONENT: SIDEBAR ITEM                      */
/* ============================================ */

.ds-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    cursor: pointer;
    margin: 1px var(--space-2);
}

.ds-nav-item:hover {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.06);
}

.ds-nav-item.active {
    color: var(--accent-text);
    background: var(--accent-muted);
    font-weight: 600;
}

/* ============================================ */
/* COMPONENT: STAT TILE                         */
/* ============================================ */

.ds-stat-tile {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.ds-stat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.ds-stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ds-stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--text-primary);
}

.ds-stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================ */
/* COMPONENT: INPUT                             */
/* ============================================ */

.ds-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    transition: all 0.2s ease;
}

.ds-input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.ds-input::placeholder {
    color: var(--text-muted);
}

/* ============================================ */
/* UTILITY CLASSES                              */
/* ============================================ */

.text-accent {
    color: var(--accent-text);
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.bg-accent-muted {
    background: var(--accent-muted);
}

/* Noise texture overlay */
.noise-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Smooth transitions for interactive elements */
a,
button,
input,
select,
textarea {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}