/* ============================================
   Apple Liquid Glass 2026 Design System
   ============================================ */

:root {
    /* Colors - Light Mode (Spatial) */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-bg-solid: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: rgba(0, 0, 0, 0.06);
    --glass-subtle: rgba(255, 255, 255, 0.35);
    --glass-frost: rgba(255, 255, 255, 0.5);

    --text-primary: #111111;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;

    /* Liquid Gradients */
    --accent-primary: #007AFF;
    --accent-secondary: #5856D6;
    --accent-gradient: linear-gradient(135deg, #007AFF 0%, #5E5CE6 50%, #5856D6 100%);
    --accent-glow: rgba(0, 122, 255, 0.2);
    --accent-glow-strong: rgba(0, 122, 255, 0.4);

    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    /* Spatial Background with Depth */
    --bg-chat: url("../assets/bg-liquid.png") no-repeat center center fixed;

    --user-bubble: linear-gradient(135deg, #007AFF 0%, #0062CC 100%);
    --ai-bubble: rgba(255, 255, 255, 0.75);

    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;

    /* Spacing (Spatial Grid) */
    --space-2xs: 2px;
    --space-xs: 6px;
    --space-sm: 10px;
    --space-md: 18px;
    --space-lg: 26px;
    --space-xl: 36px;
    --space-2xl: 52px;

    /* Border Radius (Squircle-ish) */
    --radius-xs: 8px;
    --radius-sm: 14px;
    --radius-md: 20px;
    --radius-lg: 26px;
    --radius-xl: 34px;
    --radius-full: 9999px;

    /* Typography (Human Interface) */
    --font-family: 'SF Pro Display', 'SF Pro Text', 'Inter', system-ui, -apple-system, sans-serif;
    --font-size-2xs: 10px;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-md: 18px;
    --font-size-lg: 22px;
    --font-size-xl: 30px;
    --font-size-2xl: 38px;

    /* Effects (Liquid Glass) */
    --blur-xs: blur(10px);
    --blur-sm: blur(25px);
    --blur-md: blur(45px);
    --blur-lg: blur(70px);
    --saturate: saturate(190%);
    --noise-texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");

    /* Physics (Springs) */
    --transition-fast: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition-normal: 350ms cubic-bezier(0.3, 0.8, 0.2, 1);
    /* Apple-like ease */
    --transition-slow: 500ms cubic-bezier(0.3, 0.8, 0.2, 1);
    --transition-spring: 600ms cubic-bezier(0.34, 1.3, 0.64, 1);
    /* Bouncy */

    /* Layering (Depth) */
    --z-base: 1;
    --z-floating: 50;
    --z-elevated: 100;
    --z-modal: 1000;
    --z-toast: 2000;

    /* Safe areas */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    --header-height: 60px;
    --input-height: 80px;
}

/* Dark Mode (Deep Space) */
[data-theme="dark"] {
    --glass-bg: rgba(22, 22, 24, 0.75);
    --glass-bg-solid: rgba(28, 28, 30, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.4);
    --glass-subtle: rgba(255, 255, 255, 0.06);
    --glass-frost: rgba(255, 255, 255, 0.12);

    --text-primary: #FFFFFF;
    --text-secondary: #98989F;
    --text-tertiary: #636366;

    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-chat: radial-gradient(circle at 50% 0%, #1a1a1c 0%, #000000 100%);

    --ai-bubble: rgba(30, 30, 32, 0.85);

    --accent-glow: rgba(10, 132, 255, 0.3);
}

/* Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    background-image: url('../assets/bg-liquid.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    /* Ensure content padding for fixed header/footer */
    padding-top: 80px;
    padding-bottom: 100px;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--blur-md) var(--saturate);
    -webkit-backdrop-filter: var(--blur-md) var(--saturate);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 4px 24px var(--glass-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.glass-subtle {
    background: var(--glass-subtle);
    backdrop-filter: var(--blur-sm) var(--saturate);
    -webkit-backdrop-filter: var(--blur-sm) var(--saturate);
}

.glass-pill {
    background: var(--glass-bg);
    backdrop-filter: var(--blur-sm) var(--saturate);
    -webkit-backdrop-filter: var(--blur-sm) var(--saturate);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: var(--space-sm) var(--space-md);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
}

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

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

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

/* Buttons Base */
button {
    font-family: inherit;
    font-size: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Links */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

a:hover {
    opacity: 0.8;
}

/* Utility Classes */
.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-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}