/* ========================================
   BASE.CSS - Design System & Variables
   Core variables, reset, themes, aurora
   ======================================== */

/* Design System Variables */
:root {
    /* Pastel Indigo Professional Theme */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-translucent: rgba(15, 23, 42, 0.9);

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-accent: #818cf8;

    /* Accents */
    --accent-primary: #818cf8;
    --accent-secondary: #6366f1;
    --accent-hover: #4f46e5;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --gradient-gold: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    --gradient-glass: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);

    /* Status Colors */
    --status-active: #34d399;
    --status-pending: #fb923c;
    --status-closed: #f87171;
    --status-review: #60a5fa;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Typography */
    --font-primary: 'Inter', sans-serif;
    --font-display: 'Space Grotesk', sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    --font-size-3xl: 3rem;
    --font-size-4xl: 4rem;

    /* Borders & Shadows */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Aurora Colors */
    --aurora-1: rgba(139, 92, 246, 0.15);
    --aurora-2: rgba(59, 130, 246, 0.12);
    --aurora-3: rgba(16, 185, 129, 0.10);
    --aurora-4: rgba(236, 72, 153, 0.08);
    --aurora-5: rgba(245, 158, 11, 0.06);

    /* Animation Timing */
    --morph-duration: 0.5s;
    --morph-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --morph-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --morph-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Frosted Glass */
    --frost-blur: 24px;
    --frost-saturation: 180%;
    --frost-bg-dark: rgba(15, 23, 42, 0.75);
    --frost-bg-light: rgba(255, 255, 255, 0.65);

    /* Gradient Mesh */
    --mesh-primary: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --mesh-aurora: linear-gradient(45deg, #12c2e9, #c471ed, #f64f59);
    --mesh-ocean: linear-gradient(135deg, #667eea 0%, #0ea5e9 50%, #22d3ee 100%);

    /* Glow Effects */
    --glow-primary: 0 0 40px rgba(99, 102, 241, 0.15);
    --glow-accent: 0 0 60px rgba(139, 92, 246, 0.12);
    --glow-aurora: 0 0 80px rgba(59, 130, 246, 0.1);
}

/* Light Theme Variables */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #ffffff;
    --bg-translucent: rgba(255, 255, 255, 0.9);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(203, 213, 225, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-accent: #6366f1;
    --accent-primary: #818cf8;
    --accent-secondary: #6366f1;
    --gradient-primary: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    --gradient-gold: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    --gradient-glass: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.3) 100%);
}

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

html {
    box-sizing: border-box;
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

body.light-theme * {
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
    line-height: inherit;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
    touch-action: manipulation;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
    -webkit-appearance: none;
    appearance: none;
}

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
    border-style: none;
    padding: 0;
}

textarea {
    overflow: auto;
}

[type="search"] {
    -webkit-appearance: textfield;
    appearance: textfield;
}

[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
}

a,
button,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* Glassmorphism Fallbacks */
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {

    .top-nav,
    .case-header,
    .panel-nav,
    .modal-overlay,
    .profile-dropdown,
    .case-card,
    .landing-nav {
        background: var(--bg-secondary) !important;
    }

    body.light-theme .top-nav,
    body.light-theme .case-header,
    body.light-theme .panel-nav,
    body.light-theme .case-card {
        background: rgba(255, 255, 255, 0.95) !important;
    }
}

/* Body Styles */
body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(129, 140, 248, 0.05) 0px, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    position: relative;
    isolation: isolate;
}

body.light-theme {
    background-color: #f1f5f9;
    background-image: none;
}

/* Aurora Background System */
.bg-gradient {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: aurora-float 4.5s ease-in-out infinite;
    will-change: transform;
}

.aurora-blob-1 {
    width: 60vw;
    height: 60vw;
    max-width: 800px;
    max-height: 800px;
    background: radial-gradient(circle, var(--aurora-1), transparent 10%);
    top: -20%;
    left: -10%;
}

.aurora-blob-2 {
    width: 50vw;
    height: 50vw;
    max-width: 600px;
    max-height: 600px;
    background: radial-gradient(circle, var(--aurora-2), transparent 10%);
    top: 10%;
    right: -15%;
    animation-delay: -0.8s;
    animation-duration: 3.5s;
}

.aurora-blob-3 {
    width: 40vw;
    height: 40vw;
    max-width: 500px;
    max-height: 500px;
    background: radial-gradient(circle, var(--aurora-3), transparent 10%);
    top: 20%;
    left: 30%;
    animation-delay: -1.5s;
    animation-duration: 2.8s;
}

body.light-theme .bg-gradient {
    background: linear-gradient(135deg, rgba(248, 250, 252, 1) 0%, rgba(241, 245, 249, 1) 100%);
}

body.light-theme .aurora-blob {
    filter: blur(20px);
}

body.light-theme .aurora-blob-1 {
    background: radial-gradient(circle, rgba(99, 102, 241, 0.45), transparent 70%);
    opacity: 0.9;
}

body.light-theme .aurora-blob-2 {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4), transparent 70%);
    opacity: 0.85;
}

body.light-theme .aurora-blob-3 {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.35), transparent 70%);
    opacity: 0.8;
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    min-height: 1vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
}

.view {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: var(--spacing-lg);
}

.view.active {
    display: block;
    opacity: 1;
}

/* ========================================
   THREE.JS 3D CANVAS CONTAINERS
   ======================================== */

/* Background 3D Scene Container */
.threejs-bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.7;
}

.threejs-bg-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Hero Section 3D Container */
.threejs-hero-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

.threejs-hero-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Hero section needs relative positioning for 3D canvas */
.hero-section {
    position: relative;
    overflow: hidden;
}

.hero-section .hero-content {
    position: relative;
    z-index: 1;
}

/* ========================================
   CASE WORKSPACE LAYOUT
   Standard 2D functional layout
   ======================================== */

.case-workspace-layout {
    display: flex;
    gap: 20px;
}

/* Panel base styling */
.panel {
    position: relative;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    transition: box-shadow 0.4s ease;
}

/* Active panel */
.panel:not([style*="display: none"]) {
    box-shadow: var(--shadow-xl);
}

/* Panel header */
.panel .panel-header {
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
}

/* Panel content */
.panel .panel-content {
    padding: var(--spacing-md);
}

/* Light theme adjustments */
body.light-theme .panel {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
}

/* AI Panels get extra visual distinction */
#panel-knowledge-graph,
#panel-arguments,
#panel-casestage,
#panel-clerknotes {
    border-left: 4px solid var(--accent-primary);
}

/* ========================================
   SIDEBAR NAVIGATION
   Clean, accessible navigation
   ======================================== */

.panel-nav {
    width: 280px;
    flex-shrink: 0;
}

/* Sidebar tabs */
.panel-tab {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.panel-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.panel-tab.active {
    background: var(--accent-primary);
    color: white;
}

/* Reduced Motion - already simplified */
@media (prefers-reduced-motion: reduce) {

    .threejs-bg-container,
    .threejs-hero-container {
        display: none;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .case-workspace-layout {
        flex-direction: column;
    }

    .panel-nav {
        width: 100%;
    }
}