/* =========================================
   1. VARIABLES & THEME SYSTEM
   ========================================= */
:root {
    /* Core Brand Identity */
    --brand-primary: #f59e0b;      /* Neural Amber */
    --brand-bg:      #0f172a;      /* Deep Cosmos */
    --brand-user:    #4f46e5;      /* Human Indigo */

    /* Typography - Geometric Intelligence Stack */
    --font-title: 'Outfit', sans-serif;
    --font-body:  'Plus Jakarta Sans', sans-serif;
    --font-code:  'Fira Code', monospace;

    /* Surfaces (Dark Mode Default) */
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(30, 41, 59, 0.5);
    --input-focus-bg: rgba(30, 41, 59, 0.95);
    
    /* Text Colors */
    --text-primary: #f1f5f9;       /* Text High */
    --text-secondary: #94a3b8;     /* Text Medium */
    --text-placeholder: #64748b;   /* Text Muted */

    /* Misc */
    --panel-shadow: 0 0 40px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    --scroll-track: transparent;
    --scroll-thumb: rgba(255, 255, 255, 0.1);
    --scroll-thumb-hover: rgba(245, 158, 11, 0.5);
}

body.light-mode {
    --brand-bg: #f0f4f8;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-placeholder: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.06);
    --input-bg: #f1f5f9;
    --input-focus-bg: #ffffff;
    --panel-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
    --scroll-thumb: rgba(0, 0, 0, 0.2);
}

/* =========================================
   2. BASE STYLES & TYPOGRAPHY
   ========================================= */
body { 
    background-color: var(--brand-bg); 
    color: var(--text-secondary); 
    font-family: var(--font-body); /* Plus Jakarta Sans */
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .font-title {
    font-family: var(--font-title); /* Outfit */
}

code, pre, .font-mono {
    font-family: var(--font-code); /* Fira Code */
}

/* Texture de bruit commune */
#noise-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0; opacity: 0.035;
    background-image: 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)'/%3E%3C/svg%3E");
}

/* Canvas Background */
#canvas-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; }

/* Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: var(--panel-shadow);
    border: 1px solid var(--glass-border);
}

.text-brand-primary { color: var(--brand-primary); }
.text-brand-user { color: var(--brand-user); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* =========================================
   3. COMPONENTS (Inputs, Bubbles)
   ========================================= */
.input-field {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: var(--font-body);
}
.input-field:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1);
    background: var(--input-focus-bg);
}

/* Waveform Animation */
.waveform { display: flex; align-items: center; gap: 3px; height: 18px; padding: 0 4px; }
.waveform .bar { width: 3px; background-color: var(--brand-primary); border-radius: 2px; animation: wave 1s ease-in-out infinite; }
.waveform .bar:nth-child(1) { height: 40%; animation-delay: 0.0s; }
.waveform .bar:nth-child(2) { height: 70%; animation-delay: 0.1s; }
.waveform .bar:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.waveform .bar:nth-child(4) { height: 60%; animation-delay: 0.3s; }
.waveform .bar:nth-child(5) { height: 40%; animation-delay: 0.4s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.5); opacity: 0.5; } 50% { transform: scaleY(1.2); opacity: 1; } }

/* Chat Bubbles */
.user-bubble {
    background-color: var(--brand-user);
    color: #ffffff;
    padding: 0.8rem 1.2rem;
    border-radius: 1.2rem 0.2rem 1.2rem 1.2rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.markdown-body { font-size: 0.95rem; color: var(--text-secondary); }
.markdown-body p { margin-bottom: 0.75rem; }
.markdown-body code {
    background: rgba(245, 158, 11, 0.1);
    color: var(--brand-primary);
    padding: 0.2em 0.4em;
    border-radius: 0.3em;
    font-family: var(--font-code);
    font-size: 0.85em;
}

.code-block-wrapper {
    margin: 1rem 0;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #111827; /* Code bg stays dark */
    border: 1px solid var(--glass-border);
}

/* Animations Landing */
@keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-15px); } }
@keyframes fade-in-up { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.animate-float { animation: float 6s ease-in-out infinite; }
.animate-fade-in-up { animation: fade-in-up 0.5s ease-out forwards; }