/* ================================================================
   JOVAN AI — MAIN STYLESHEET (Zenith v3.0 Cosmos Design System)
   Unified design tokens, global resets, and shared components.
   ================================================================ */

:root {
    /* --- ZENITH v3.0 COSMOS DESIGN SYSTEM --- */
    
    /* 1. Base Colors (HSL for precise palette management) */
    --p-h: 242; /* Primary Hue — Elite Indigo */
    --p-s: 100%;
    --p-l: 70%;
    
    --accent-h: 160; /* Accent Hue — Menthol Mint */
    --accent-s: 80%;
    --accent-l: 50%;

    --primary:          hsl(var(--p-h), var(--p-s), var(--p-l));
    --primary-dark:     hsl(var(--p-h), var(--p-s), 60%);
    --primary-light:    hsla(var(--p-h), var(--p-s), var(--p-l), 0.15);
    
    --accent:           hsl(var(--accent-h), var(--accent-s), var(--accent-l));
    
    /* 2. Global Surface & Glass System */
    --bg-main:          hsl(220, 30%, 98%);
    --bg-card:          rgba(255, 255, 255, 0.55);
    --bg-surface:       rgba(255, 255, 255, 0.7);
    --glass-border:     rgba(255, 255, 255, 0.5);
    
    /* 3. Text Hierarchy */
    --text-header:      hsl(222, 47%, 11%);
    --text-main:        hsl(222, 30%, 20%);
    --text-muted:       hsl(215, 16%, 47%);
    --text-primary:     var(--text-header);
    --text-secondary:   var(--text-muted);
    
    /* 4. Typography */
    --font-main:        'Plus Jakarta Sans', sans-serif;
    --size-body:        1rem;
    --size-small:       0.875rem;
    --size-h3:          1.25rem;
    
    /* 5. Border System */
    --border-light:     rgba(0, 0, 0, 0.06);
    --border-base:      rgba(0, 0, 0, 0.08);
    
    /* 6. Semantic Colors */
    --success:          #10b981;
    --warning:          #f59e0b;
    --error:            #ef4444;
    --info:             #3b82f6;

    /* 7. Shadow System */
    --shadow-sm:        0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md:        0 8px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg:        0 16px 32px rgba(0, 0, 0, 0.08);
    --shadow-xl:        0 24px 48px rgba(0, 0, 0, 0.12);
    --shadow-premium:   0 12px 40px rgba(0, 0, 0, 0.06);
    
    /* 8. Glass / Blur */
    --zinc-blur:        blur(32px);
    --zinc-border:      1px solid rgba(255, 255, 255, 0.5);
    --blur-val:         var(--zinc-blur);
    
    /* 9. Dashboard-Specific Tokens */
    --db-card-bg:       rgba(255, 255, 255, 0.55);
    --db-text-main:     var(--text-header);
    --db-text-muted:    var(--text-muted);
    --db-primary:       var(--primary);
    --db-primary-glow:  hsla(var(--p-h), var(--p-s), var(--p-l), 0.25);
    --db-border:        var(--border-light);
    --db-shadow-sm:     var(--shadow-sm);
    --db-shadow-lg:     var(--shadow-lg);
    --db-shadow-xl:     var(--shadow-xl);
    --db-radius-sm:     16px;
    --db-radius-lg:     28px;
    
    /* 10. Transition */
    --transition:       all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* 11. Spacing Tokens */
    --space-2xl: 3rem;
    --space-xl:  2rem;
    --space-lg:  1.5rem;
    --space-md:  1rem;
    --space-sm:  0.5rem;
    --space-xs:  0.25rem;
    
    /* 12. Radius Tokens */
    --radius-xl:        32px;
    --radius-lg:        24px;
    --radius-md:        16px;
    --radius-sm:        12px;
    --radius-full:      999px;
    
    /* 13. Gradients */
    --grad-primary:     linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    --grad-surface:     linear-gradient(135deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.3) 100%);
    
    /* 14. Legacy Aliases (for old component compatibility) */
    --accent-glow:      hsla(var(--p-h), var(--p-s), var(--p-l), 0.4);
    --accent-muted:     hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
    --chat-accent:      var(--primary);
}

/* --- Premium Dark Mode Overrides (v3.0) --- */
[data-theme="dark"] {
    --bg-main:          #020617;
    --bg-card:          rgba(15, 23, 42, 0.65);
    --bg-surface:       rgba(15, 23, 42, 0.5);
    --text-main:        #f1f5f9;
    --text-header:      #ffffff;
    --text-muted:       #94a3b8;
    --text-primary:     #ffffff;
    --text-secondary:   #94a3b8;
    --glass-border:     rgba(255, 255, 255, 0.1);
    --zinc-border:      1px solid rgba(255, 255, 255, 0.1);
    --primary-light:    rgba(108, 99, 255, 0.25);
    --border-light:     rgba(255, 255, 255, 0.08);
    --border-base:      rgba(255, 255, 255, 0.1);
    
    --db-card-bg:       rgba(15, 23, 42, 0.65);
    --db-text-main:     #ffffff;
    --db-text-muted:    #94a3b8;
    --db-border:        rgba(255, 255, 255, 0.08);
    
    --shadow-sm:        0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md:        0 8px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg:        0 16px 32px rgba(0, 0, 0, 0.35);
    --shadow-xl:        0 24px 48px rgba(0, 0, 0, 0.4);
    --shadow-premium:   0 12px 40px rgba(0, 0, 0, 0.4);
}

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

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(108, 99, 255, 0.1) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(59, 130, 246, 0.05) 0, transparent 50%);
    font-family: var(--font-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app-root {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

#sidebar {
    height: 100%;
    display: contents;
}

.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-main);
}

/* ── Typography ── */
h1, h2, h3 {
    color: var(--text-header);
    font-weight: 800;
    margin-bottom: var(--space-xs);
}

p {
    color: var(--text-main);
    font-size: var(--size-body);
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    transition: var(--transition);
}

ul {
    padding-left: var(--space-lg);
}

li {
    margin-bottom: var(--space-xs);
}

a {
    text-decoration: none;
    color: inherit;
}

/* ── Global Utility Classes ── */
.text-title { font-weight: 800; color: var(--text-header); }
.text-muted { color: var(--text-muted); font-size: var(--size-small); }
.text-primary { color: var(--primary); }

.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.j-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.j-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

/* ── Coming Soon & Placeholder ── */
.coming-soon-wrapper {
    text-align: center;
    padding: 100px var(--space-lg);
}

.coming-soon-title {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.coming-soon-text {
    font-size: var(--size-h3);
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
}

/* ── App Loading ── */
.app-container {
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

.center-text {
    text-align: center;
}

/* ── Error UI ── */
.error-toast {
    display: none;
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    background: var(--error);
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
}

.error-close-btn {
    margin-left: var(--space-md);
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
}

/* ── Noscript ── */
.noscript-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--error);
    color: white;
    text-align: center;
    padding: var(--space-md);
    z-index: 10000;
}

/* ── Modal UI ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.modal-container {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-header);
}

.modal-close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-header);
    transform: rotate(90deg);
}

.modal-content {
    padding: var(--space-lg);
}

/* ── Notification UI ── */
.notification {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1100;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 280px;
    border-left: 4px solid var(--text-muted);
}

.notification.show {
    transform: translateX(0);
}

.notification.info { border-left-color: var(--info); }
.notification.success { border-left-color: var(--success); }
.notification.warning { border-left-color: var(--warning); }
.notification.error { border-left-color: var(--error); }

.notification-title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text-header);
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Zenith Input ── */
.zenith-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-base);
    font-size: var(--size-small);
    transition: var(--transition);
    background: var(--bg-main);
}

.zenith-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(108, 99, 255, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 99, 255, 0.4);
}

/* ── Selection ── */
::selection {
    background: rgba(108, 99, 255, 0.3);
    color: var(--text-header);
}

/* ── Typing Indicator ── */
.typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    width: fit-content;
    border: 1px solid var(--border-light);
}

.typing span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.4); opacity: 1; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}