/* base.css - Design tokens, reset, and typography */

/* ===== CSS Variables / Design Tokens ===== */
:root {
    /* Typography */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", "Menlo", "Consolas", monospace;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 0.9375rem;
    --text-lg: 1.0625rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;

    /* Line heights */
    --line-height: 1.6;
    --line-height-tight: 1.3;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 56px;
    --content-max-width: 800px;
    --page-padding: 24px;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    /* Borders */
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Dark theme (default) */
[data-theme="dark"] {
    --bg-primary: #08090a;
    --bg-secondary: #131316;
    --bg-tertiary: #1c1c1f;
    --bg-hover: #232326;
    --bg-input: #1a1a1a;

    --text-primary: #f7f8f8;
    --text-secondary: #d0d6e0;
    --text-tertiary: #8a8f98;

    --border: #23252a;
    --border-strong: #33363d;

    --accent: #7170ff;
    --accent-hover: #8585ff;
    --accent-muted: rgba(113, 112, 255, 0.2);

    --success: #10a37f;
    --success-muted: rgba(16, 163, 127, 0.2);

    --error: #ff6464;
    --error-muted: rgba(255, 100, 100, 0.2);

    --warning: #ffb347;
    --warning-muted: rgba(255, 179, 71, 0.2);

    /* Message bubbles */
    --user-msg-bg: #2f2f2f;
    --assistant-msg-bg: transparent;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f8f9;
    --bg-tertiary: #f4f2f4;
    --bg-hover: #f0eef0;
    --bg-input: #ffffff;

    --text-primary: #282a30;
    --text-secondary: #3c4149;
    --text-tertiary: #6f6e77;

    --border: #e9e8ea;
    --border-strong: #d4d3d6;

    --accent: #7070ff;
    --accent-hover: #5c5ce6;
    --accent-muted: rgba(112, 112, 255, 0.15);

    --success: #0d8a6f;
    --success-muted: rgba(13, 138, 111, 0.15);

    --error: #dc3545;
    --error-muted: rgba(220, 53, 69, 0.15);

    --warning: #e69500;
    --warning-muted: rgba(230, 149, 0, 0.15);

    /* Message bubbles */
    --user-msg-bg: #f4f2f4;
    --assistant-msg-bg: transparent;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--line-height);
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight);
    font-weight: 600;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
    color: var(--text-secondary);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

pre {
    font-family: var(--font-mono);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    overflow-x: auto;
}

pre code {
    background: none;
    padding: 0;
    font-size: var(--text-sm);
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

/* ===== Icon Styles ===== */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

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

/* ===== Selection ===== */
::selection {
    background: var(--accent-muted);
    color: var(--text-primary);
}

/* ===== Focus Styles ===== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
