/* unified_frontend/css/styles.css - REPLACEMENT */

/* --- UTILITY CLASSES --- */
.hidden {
    display: none !important;
}


/* --- THEME & GLOBAL VARIABLES --- */
:root {
    /* === PRIMARY & SECONDARY PALETTE (Dark Gray Theme) === */
    --primary-color: #3f3f46;      /* Dark gray - matching icon black */
    --primary-dark: #27272a;       /* Almost black - for emphasis */
    --primary-light: #a1a1aa;      /* Light gray - matching icon secondary */


    --secondary-bg: #e6e6e7;       /* Very light gray background - 10% darker */
    --secondary-text: #71717a;     /* Medium gray text */
    --secondary-border: #d6d6d9;   /* Light gray border - 10% darker */
    --secondary-hover-bg: #ececec; /* Hover background - 10% darker */
    --secondary-disabled-bg: #eaeaeb;
    --secondary-disabled-text: #bdc1c6;
    --secondary-disabled-border: #dadce0;

    /* === SEMANTIC & STATUS COLORS === */
    --success-color: #1e8e3e;
    --success-dark: #0d652d;
    --error-color: #d93025;
    --error-dark: #b3261e;
    --warning-color: #f9ab00;
    --info-color: #3f3f46; /* Dark gray instead of blue */

    /* Icon Colors (following duotone standards - matching SVG colors) */
    --icon-primary: #000000;       /* Black - matches stroke="#000000" */
    --icon-secondary: #737373;     /* Gray - matches stroke="#737373" */
    --primary-rgb: 63, 63, 70;     /* RGB for primary-color */


    /* === TEXT COLORS === */
    --text-primary: #18181b;       /* Very dark gray, almost black */
    --text-secondary: #71717a;     /* Medium gray */
    --text-muted: #a1a1aa;         /* Light gray */
    --text-light: #ffffff;
    --text-placeholder: #a1a1aa;   /* Light gray */
    --text-link: var(--primary-color);
    --text-black: #000000;
    --text-info-dark: #3f3f46;     /* Dark gray instead of blue */
    --text-warning-dark: #e37400;

    /* === BACKGROUND COLORS === */
    --bg-canvas: #ececec;          /* Very light gray canvas - 10% darker */
    --bg-body: var(--bg-canvas);
    --bg-surface: #ffffff;
    --bg-surface-alt: #e6e6e7;     /* Light gray surface - 10% darker */
    --bg-surface-hover: #ececec;   /* Hover state - 10% darker */
    --bg-input: #ffffff;
    --bg-backdrop: rgba(32, 33, 36, 0.6);

    /* Panel-specific backgrounds (5% darker for left panel sections) */
    --bg-panel-alt: #f0f0f1;       /* Light gray for panel sections - 5% darker */
    --bg-panel-canvas: #f5f5f5;    /* Very light gray for panel canvas - 5% darker */

    /* NEW: Light status backgrounds for panels/badges */
    --bg-success-light: #d8eedc;   /* 10% darker */
    --bg-error-light: rgba(219, 48, 37, 0.15);
    --bg-error-subtle: #f8dad8;    /* 10% darker */
    --bg-warning-light: #f6efd2;   /* 10% darker */
    --bg-info-light: #e6e6e7;      /* Light gray instead of blue - 10% darker */

    /* NEW: Transparent overlays */
    --bg-white-t20: rgba(255, 255, 255, 0.2); /* from chat.css */
    --bg-white-t50: rgba(255, 255, 255, 0.5); /* from chat.css */
    --bg-white-t90: rgba(255, 255, 255, 0.9); /* from chat.css */
    --bg-black-t10: rgba(0, 0, 0, 0.1); /* from chat.css */

    /* === ELEVATION LAYERS (Semantic Depth System) ===
       Use these for consistent visual hierarchy across themes.
       Layer 0 = deepest (canvas), Layer 3 = highest (tooltips) */
    --bg-layer-0: var(--bg-canvas);        /* App background / Canvas */
    --bg-layer-1: var(--bg-surface);       /* Cards, Panels, Primary surfaces */
    --bg-layer-2: var(--bg-surface-alt);   /* Modals, Dropdowns, Nested cards */
    --bg-layer-3: var(--primary-dark);     /* Tooltips, Toasts (highest elevation) */

    /* === BORDER COLORS === */
    --border-light: #dadce0;       /* 10% darker */
    --border-medium: #cccfd3;      /* 10% darker */
    --border-dark: #aaafb3;        /* 10% darker */
    --border-white-t30: rgba(255, 255, 255, 0.3); /* from chat.css */

    /* === LAYOUT DIMENSIONS === */
    --header-height: 64px;
    --panel-width-default: 280px;
    --panel-width-collapsed: 64px;
    --panel-width-expanded: 320px;
    --icon-bar-width: 56px;
    --login-form-max-width: 360px;

    /* === COMPONENT-SPECIFIC DIMENSIONS === */
    --icon-button-size: 40px; /* For main nav icon buttons */
    --chat-preview-size: 80px;
    --search-results-max-height: 300px;
    --chat-image-min-width: 120px;
    --thinking-indicator-width: 250px;

    
    --icon-stroke-width: 1.5px;


    /* Icon Sizes (following your spacing system) */
    --icon-size-xs: 16px;
    --icon-size-sm: 20px;
    --icon-size-md: 24px;    /* Default size */
    --icon-size-lg: 32px;
    --icon-size-xl: 48px;

    /* === FONT SIZES (T-shirt sizing) === */
    --font-size-xxxs: 0.5625rem; /* 9px */
    --font-size-xxs: 0.6875rem;  /* 11px */
    --font-size-xs: 0.75rem;     /* 12px */
    --font-size-sm: 0.875rem;    /* 14px */
    --font-size-base: 1rem;       /* 16px */
    --font-size-lg: 1.125rem;    /* 18px */
    --font-size-xl: 1.25rem;      /* 20px */
    --font-size-xxl: 1.5rem;     /* 24px */
    --font-size-xxxl: 3rem;      /* 48px */

    /* === TYPOGRAPHY  === */
    --font-size-button: 0.9375rem; /* 15px, if needed */
    --border-width-sm: 1px;
    --border-width-md: 2px;
    --letter-spacing-sm: 0.5px;
        
    /* === SHAPES & RADII === */
    --border-radius-xs: 2px;
    --border-radius-sm: 4px;
    --border-radius-md: 7px;
    --border-radius-ml: 11px;
    --border-radius-lg: 14px;
    --border-radius-xl: 22px;
    --border-radius-pill: 9999px;
    --border-radius-circle: 50%;

    /* === SHADOWS & ELEVATIONS === */
    --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    --shadow-md: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
    --shadow-lg: 0 2px 6px 2px rgba(60, 64, 67, 0.15), 0 6px 16px 4px rgba(60, 64, 67, 0.15);
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.08); /* NEW: from layout.css */
    
    /* === FOCUS RINGS === */
    --focus-ring-primary: 0 0 0 3px rgba(161, 161, 170, 0.3); /* Light gray with transparency */
    --focus-ring-error: 0 0 0 3px var(--bg-error-light);

    /* === AGENT AVATAR ACCENT COLORS === */
    --color-accent-red: #e74c3c;
    --color-accent-blue: #3498db;
    --color-accent-green: #2ecc71;
    --color-accent-orange: #f39c12;


    /* Spacing Scale (use powers of 2 for consistency) */
    --spacing-xxxs: 2px;
    --spacing-xxs: 4px;
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    --spacing-xxxl: 64px; 

    /* === OFFSETS & SPECIFIC DIMENSIONS === */
    --spacing-offset-sm: -6px;
    --icon-size-md: 22px;

    /* Opacity */
    --opacity-disabled: 0.38;

    /* === Z-INDEX LAYERS === */
    /* Zentralisierte z-index Werte für konsistente Stacking-Kontexte.
       WICHTIG: Nur diese Variablen verwenden, keine hardcoded Werte! */
    --z-layer-base: 1;            /* Basis-Elemente (z.B. Buttons in Containern) */
    --z-layer-elevated: 20;       /* Leicht erhöhte Elemente (Drag-Overlays) */
    --z-layer-panel: 50;          /* Panels (RAG, Agent) */
    --z-layer-panel-controls: 60; /* Panel-Steuerelemente (Toggle-Buttons, aktive Panels) */
    --z-layer-header: 100;        /* Header und View-Controls */
    --z-layer-dropdown: 200;      /* Dropdowns und Menüs */
    --z-layer-tooltip: 500;       /* Tooltips und Hover-Infos */
    --z-layer-overlay: 900;       /* Hintergrund-Overlays für Modals */
    --z-layer-modal: 1000;        /* Modale Dialoge */
    --z-layer-toast: 2000;        /* Toast-Benachrichtigungen, Loading-Indicator */
}


/* --- BASIC RESET & BODY STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-body);
    color: var(--text-primary);
}


/* --- GLOBAL SCROLLBAR STYLES --- */
::-webkit-scrollbar {
    width: var(--spacing-xs);
    height: var(--spacing-xs);
}

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

::-webkit-scrollbar-thumb {
    background-color: var(--border-medium);
    border-radius: var(--border-radius-sm);
}

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


/* --- GLOBAL COMPONENT STYLES --- */
/* General Markdown Styling - Compact for chat */
.markdown-rendered-content h1,
.markdown-rendered-content h2,
.markdown-rendered-content h3,
.markdown-rendered-content h4 {
    margin-top: 0.6em;
    margin-bottom: 0.3em;
    font-weight: 600;
}
.markdown-rendered-content h1 { font-size: 1.15em; }
.markdown-rendered-content h2 { font-size: 1.1em; }
.markdown-rendered-content h3 { font-size: 1.05em; }
.markdown-rendered-content h4 { font-size: 1em; }
.markdown-rendered-content p { margin-bottom: 0.5em; }
.markdown-rendered-content ul,
.markdown-rendered-content ol { margin-left: 1.5em; margin-bottom: 0.5em; }
.markdown-rendered-content li { margin-bottom: 0.2em; }
.markdown-rendered-content code {
    background-color: var(--secondary-bg);
    padding: 0.2em 0.4em;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
}
.markdown-rendered-content pre {
    background-color: var(--secondary-bg);
    padding: 1em;
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    margin-bottom: 1em;
}
.markdown-rendered-content pre code {
    background-color: transparent;
    padding: 0;
}
.markdown-rendered-content blockquote {
    border-left: var(--spacing-xxs) solid var(--border-medium);
    padding-left: 1em;
    margin-left: 0;
    margin-bottom: 1em;
    color: var(--text-secondary);
}
.markdown-rendered-content table {
    border-collapse: collapse;
    margin-bottom: 1em;
    width: auto;
    border: var(--border-width-sm) solid var(--border-medium);
}
.markdown-rendered-content th,
.markdown-rendered-content td {
    border: var(--border-width-sm) solid var(--border-medium);
    padding: 0.6em 1em;
}
.markdown-rendered-content th {
    background-color: var(--secondary-bg);
    font-weight: 600;
    color: var(--text-primary);
}
.markdown-rendered-content td {
    background-color: #f9f9f9;
}
.markdown-rendered-content tr:hover td {
    background-color: var(--bg-surface-hover);
}


/* Message/Error text */
.error-message {
    color: var(--error-color);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-xxs);
}

.message {
    color: var(--success-color);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-xxs);
}


/* Legacy fallback - now defined as .rag-section__actions in panel.css */
.rag-section__actions {
    display: flex;
    gap: var(--spacing-xs);
}

.btn:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    background-color: var(--bg-surface);
    color: var(--text-tertiary);
}

.btn:disabled:hover {
    background-color: var(--bg-surface);
    color: var(--text-tertiary);
}

/* --- DYNAMIC & UTILITY CLASSES --- */

/* Display */
.d-flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

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

.justify-between {
    justify-content: space-between;
}

/* Gap utilities */
.gap-xs {
    gap: var(--spacing-xs);
}

.gap-sm {
    gap: var(--spacing-sm);
}

.gap-md {
    gap: var(--spacing-md);
}

/* Sizing */
.w-100 {
    width: 100%;
}
.h-60vh {
    height: 60vh;
}
.max-h-60vh {
    max-height: 60vh;
}

.flex-grow {
    flex-grow: 1;
}

/* Spacing */
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mr-xs { margin-right: var(--spacing-xs); }
.p-xs { padding: var(--spacing-xs); }

/* Typography */
.font-mono { font-family: 'Roboto Mono', monospace; }
.fs-sm { font-size: var(--font-size-sm); }
.fs-base { font-size: var(--font-size-base); }
.lh-1-6 { line-height: 1.6; }
.text-error { color: var(--error-color); }

/* Layout */
.overflow-y-auto {
    overflow-y: auto;
}

/* Effects */
.opacity-50 {
    opacity: 0.5;
}

/* === DARK MODE THEME === */
/* Applied via data-theme="dark" on html element */
[data-theme="dark"] {
    /* === PRIMARY & SECONDARY PALETTE (Dark Theme) === */
    --primary-color: #a1a1aa;      /* Light gray */
    --primary-dark: #d4d4d8;       /* Lighter gray */
    --primary-light: #52525b;      /* Medium gray */

    --secondary-bg: #27272a;       /* Dark background */
    --secondary-text: #a1a1aa;     /* Light gray text */
    --secondary-border: #3f3f46;   /* Dark gray border */
    --secondary-hover-bg: #3f3f46; /* Hover background */
    --secondary-disabled-bg: #27272a;
    --secondary-disabled-text: #52525b;
    --secondary-disabled-border: #3f3f46;

    /* === TEXT COLORS === */
    --text-primary: #f4f4f5;       /* Almost white */
    --text-secondary: #a1a1aa;     /* Light gray */
    --text-muted: #71717a;         /* Medium gray */
    --text-light: #ffffff;
    --text-placeholder: #71717a;   /* Medium gray */
    --text-link: var(--primary-color);
    --text-black: #ffffff;
    --text-info-dark: #a1a1aa;
    --text-warning-dark: #fbbf24;

    /* === BACKGROUND COLORS === */
    --bg-canvas: #18181b;          /* Very dark */
    --bg-body: var(--bg-canvas);
    --bg-surface: #27272a;         /* Dark surface */
    --bg-surface-alt: #3f3f46;     /* Slightly lighter */
    --bg-surface-hover: #3f3f46;   /* Hover state */
    --bg-input: #27272a;
    --bg-backdrop: rgba(0, 0, 0, 0.7);

    /* Panel-specific backgrounds */
    --bg-panel-alt: #27272a;
    --bg-panel-canvas: #1f1f23;

    /* Status backgrounds */
    --bg-success-light: rgba(30, 142, 62, 0.2);
    --bg-error-light: rgba(219, 48, 37, 0.2);
    --bg-error-subtle: rgba(219, 48, 37, 0.15);
    --bg-warning-light: rgba(249, 171, 0, 0.2);
    --bg-info-light: #3f3f46;

    /* Transparent overlays */
    --bg-white-t20: rgba(255, 255, 255, 0.1);
    --bg-white-t50: rgba(255, 255, 255, 0.2);
    --bg-white-t90: rgba(39, 39, 42, 0.9);
    --bg-black-t10: rgba(255, 255, 255, 0.1);

    /* Elevation Layers (Dark Mode - progressively lighter) */
    --bg-layer-0: var(--bg-canvas);        /* #18181b - Deepest */
    --bg-layer-1: var(--bg-surface);       /* #27272a - Cards, Panels */
    --bg-layer-2: var(--bg-surface-alt);   /* #3f3f46 - Modals, Dropdowns */
    --bg-layer-3: #52525b;                 /* Tooltips, Toasts (highest) */

    /* === BORDER COLORS === */
    --border-light: #3f3f46;
    --border-medium: #52525b;
    --border-dark: #71717a;
    --border-white-t30: rgba(255, 255, 255, 0.15);

    /* === SHADOWS & ELEVATIONS === */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 4px 8px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 2px 6px 2px rgba(0, 0, 0, 0.3), 0 6px 16px 4px rgba(0, 0, 0, 0.3);
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.3);

    /* === FOCUS RINGS === */
    --focus-ring-primary: 0 0 0 3px rgba(161, 161, 170, 0.4);

    /* Icon Colors */
    --icon-primary: #ffffff;
    --icon-secondary: #a1a1aa;
}

/* Dark mode table cells */
[data-theme="dark"] .markdown-rendered-content td {
    background-color: #27272a;
}

[data-theme="dark"] .markdown-rendered-content tr:hover td {
    background-color: var(--bg-surface-hover);
}

/* Theme toggle button styling */
.theme-toggle-btn {
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-top: auto;
}

.theme-toggle-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.theme-toggle-btn svg {
    width: var(--icon-size-md);
    height: var(--icon-size-md);
}

/* Hide appropriate icon based on theme */
.theme-toggle-btn .icon-sun {
    display: none;
}

.theme-toggle-btn .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle-btn .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle-btn .icon-moon {
    display: none;
}