/* ========================================
   JustSearch — Modern UI Theme System
   ======================================== */

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

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* --- Design Tokens --- */
:root {
    /* Primary */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.12);
    --primary-text: #1d4ed8;

    /* Surfaces */
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #6b7280;
    --text-inverse: #ffffff;

    /* Borders */
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --border-focus: var(--primary);

    /* Feedback */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Code */
    --code-bg: #f1f5f9;
    --code-text: #e11d48;

    /* AMC-style Messages */
    --amc-message-user-bg: #f3f4f6;
    --amc-message-user-text: #000000;
    --amc-message-model-bg: transparent;
    --amc-message-model-text: #000000;
    --amc-message-action-bg: transparent;
    --amc-message-action-hover-bg: #ececf1;
    --amc-message-action-text: #666666;
    --amc-message-action-danger: #df3434;
    --amc-message-code-bg: #f7f7f8;

    /* Scrollbar */
    --scrollbar-thumb: #d1d5db;
    --scrollbar-thumb-hover: #9ca3af;

    /* Misc */
    --sidebar-width: 272px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Glass */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-blur: 12px;
}

[data-theme="dark"] {
    /* Primary */
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --primary-light: rgba(96, 165, 250, 0.12);
    --primary-text: #93c5fd;

    /* Surfaces */
    --bg: #09090b;
    --bg-secondary: #111113;
    --bg-elevated: #18181b;
    --bg-input: #1c1c1f;

    /* Text */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #a1a1aa;
    --text-inverse: #09090b;

    /* Borders */
    --border: #27272a;
    --border-light: #1e1e21;
    --border-focus: var(--primary);

    /* Feedback */
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.1);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.1);
    --error: #f87171;
    --error-light: rgba(248, 113, 113, 0.1);
    --info: #60a5fa;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);

    /* Code */
    --code-bg: #1a1a2e;
    --code-text: #f472b6;

    /* AMC-style Messages */
    --amc-message-user-bg: #2563eb;
    --amc-message-user-text: #ffffff;
    --amc-message-model-bg: transparent;
    --amc-message-model-text: #e4e4e7;
    --amc-message-action-bg: transparent;
    --amc-message-action-hover-bg: #18181b;
    --amc-message-action-text: #a1a1aa;
    --amc-message-action-danger: #fca5a5;
    --amc-message-code-bg: #121214;

    /* Scrollbar */
    --scrollbar-thumb: #3f3f46;
    --scrollbar-thumb-hover: #52525b;

    /* Glass */
    --glass-bg: rgba(9, 9, 11, 0.72);
    --glass-border: rgba(39, 39, 42, 0.3);
}

/* --- Global Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    margin: 0;
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
    -webkit-font-smoothing: auto;
    -moz-osx-font-smoothing: auto;
    touch-action: manipulation;  /* Eliminate 300ms tap delay on mobile */
}

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

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

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

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

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}
