/*
 * Copyright (c) 2026 Sohrab Modi. All rights reserved.
 * No parts of this code can be copied or reused in other environments
 * without the explicit written permission of Sohrab Modi (smodi@i20.io).
 */

/* ============================================================
   MAIN STYLESHEET — Domain Specific Models UI
   ============================================================
   Color palette: Indigo-violet gradient primary, dark slate BG
   Typography: Inter (UI), JetBrains Mono (code)
   ============================================================ */

/* ---------- CSS Custom Properties (Theme) ---------- */
:root {
    /* Primary palette */
    --primary-50:  #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-800: #3730a3;
    --primary-900: #312e81;

    /* Violet accent */
    --accent-400: #a78bfa;
    --accent-500: #8b5cf6;
    --accent-600: #7c3aed;

    /* Neutrals */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --gray-950: #020617;

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --danger:  #ef4444;
    --info:    #3b82f6;

    /* Surfaces */
    --bg-page:    #0c0f1a;
    --bg-surface: #131726;
    --bg-card:    #1a1f35;
    --bg-card-hover: #222845;
    --bg-input:   #0f1320;
    --border:     #2a3050;
    --border-light: #363d5e;

    /* Text */
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-glow:    linear-gradient(135deg, #6366f130, #8b5cf630);
    --gradient-card-documents: linear-gradient(135deg, #6366f115, #6366f105);
    --gradient-card-chat:      linear-gradient(135deg, #3b82f615, #3b82f605);
    --gradient-card-ai:        linear-gradient(135deg, #8b5cf615, #8b5cf605);
    --gradient-card-kg:        linear-gradient(135deg, #10b98115, #10b98105);
    --gradient-card-mcp:       linear-gradient(135deg, #f59e0b15, #f59e0b05);
    --gradient-card-users:     linear-gradient(135deg, #ef444415, #ef444405);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 64px;
    --topbar-height: 56px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(99,102,241,0.15);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

a { color: var(--primary-400); text-decoration: none; }
a:hover { color: var(--primary-300); }

code, pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ---------- Respect hidden attribute even when display is set ---------- */
[hidden] {
    display: none !important;
}

/* ---------- LOGIN SCREEN ---------- */
.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    z-index: 1000;
}

.login-bg-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.floating-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px; height: 400px;
    background: var(--primary-600);
    top: -100px; left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px; height: 300px;
    background: var(--accent-600);
    bottom: -50px; right: -50px;
    animation-delay: -7s;
}

.orb-3 {
    width: 250px; height: 250px;
    background: var(--primary-500);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(50px, -30px) scale(1.1); }
    50% { transform: translate(-30px, 50px) scale(0.9); }
    75% { transform: translate(40px, 20px) scale(1.05); }
}

.login-container {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-brand {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--text-secondary);
}

.eye-icon {
    width: 20px;
    height: 20px;
}

.login-error {
    padding: 10px 14px;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.8125rem;
    text-align: center;
}

.btn-login {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
}

.arrow-icon {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

.btn-login:hover .arrow-icon {
    transform: translateX(4px);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.login-footer .sep {
    margin: 0 8px;
}

/* ---------- APP LAYOUT ---------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
    height: 100vh;
    overflow: hidden;
}

.app.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

/* ---------- TOP BAR ---------- */
.top-bar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    height: var(--topbar-height);
}

.top-bar-left, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-center {
    display: flex;
    align-items: center;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.brand-mini {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo-sm {
    width: 28px;
    height: 28px;
}

.brand-name {
    font-size: 0.9375rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Provider selector */
.provider-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.provider-selector select {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.provider-selector select:focus {
    border-color: var(--primary-500);
}

/* Initialize LLM button (top bar) */
.btn-init-llm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-init-llm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-init-llm .spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* LLM status indicator (top bar, next to init button) */
.llm-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

.llm-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.llm-status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.llm-status-dot.loading {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.llm-status-dot.error {
    background: var(--danger);
}

.llm-status-label {
    color: var(--text-secondary);
}

.llm-status-label.success {
    color: var(--success);
}

.llm-status-label.error {
    color: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* User menu */
.user-menu {
    position: relative;
}

.user-avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.user-avatar-btn:hover {
    background: var(--bg-card);
    border-color: var(--border);
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-name {
    font-weight: 500;
}

.chevron {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.user-avatar-btn[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

/* Dropdown */
.dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 200;
    animation: dropdownIn 0.15s ease-out;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.dropdown-item.text-danger {
    color: var(--danger);
}

.dropdown-item.text-danger:hover {
    background: rgba(239,68,68,0.1);
}

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-normal);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section {
    margin-bottom: 16px;
}

.nav-section-title {
    display: block;
    padding: 8px 12px 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-glow);
    color: var(--primary-300);
    border: 1px solid rgba(99,102,241,0.2);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.pipeline-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--gray-500); }
.status-dot.loading { background: var(--warning); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Sidebar collapse toggle button */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    width: 100%;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--primary-500);
}

.sidebar-collapse-btn svg {
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

/* Collapsed sidebar */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .nav-item span,
.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .sidebar-footer .status-text,
.sidebar-collapsed .brand-name {
    display: none;
}

/* Collapse button in collapsed state */
.sidebar-collapsed .sidebar-collapse-btn {
    justify-content: center;
    padding: 8px;
    border: none;
}

.sidebar-collapsed .sidebar-collapse-btn span {
    display: none;
}

.sidebar-collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

/* Center icons in collapsed state */
.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

.sidebar-collapsed .sidebar-nav {
    padding: 16px 8px;
}

.sidebar-collapsed .sidebar-footer {
    padding: 12px 8px;
}

.sidebar-collapsed .pipeline-status {
    justify-content: center;
}

/* Tooltip on hover for collapsed nav items */
.sidebar-collapsed .nav-item {
    position: relative;
}

.sidebar-collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 1000;
}

.sidebar-collapsed .nav-item:hover::after {
    opacity: 1;
}

/* ---------- MAIN CONTENT ---------- */
.main-content {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: var(--bg-page);
}

.panel {
    display: none;
    padding: 32px;
    min-height: 100%;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.panel-header {
    margin-bottom: 24px;
}

.panel-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.panel-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary, .btn-login {
    background: var(--gradient-primary);
    color: white;
    border: none;
}

.btn-primary:hover, .btn-login:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--danger);
    border-color: rgba(239,68,68,0.3);
}

.btn-danger:hover {
    background: rgba(239,68,68,0.25);
}

.btn:disabled, .btn[disabled] {
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.45;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ---------- INPUTS ---------- */
.input-full, .input-lg, .select-full {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.input-full:focus, .input-lg:focus, .select-full:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.input-lg {
    padding: 12px 16px;
    resize: vertical;
}

.input-sm {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8125rem;
    outline: none;
    width: 80px;
}

.input-sm:focus {
    border-color: var(--primary-500);
}

.select-sm {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
    outline: none;
}

/* ---------- TOOLBAR ---------- */
.panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 260px;
}

.search-box svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    width: 100%;
}

/* ---------- MODALS ---------- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.25s ease-out;
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* About modal specifics */
.about-content {
    text-align: center;
}

.about-logo {
    width: 80px;
    margin: 0 auto 16px;
}

.about-logo svg {
    width: 100%;
    height: auto;
}

.about-content h3 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.version-tag {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.about-sections {
    text-align: left;
}

.about-section {
    margin-bottom: 20px;
}

.about-section h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary-300);
}

.about-section ul {
    padding-left: 20px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.modal-footer .contact-info {
    flex: 1;
    text-align: left;
}

.contact-info h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.contact-info p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.contact-info code {
    background: var(--bg-input);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

/* ---------- TOAST NOTIFICATIONS ---------- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    animation: toastIn 0.3s ease-out;
    max-width: 400px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-exit {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        bottom: 0;
        width: var(--sidebar-width);
        z-index: 90;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .panel {
        padding: 20px;
    }

    .brand-name { display: none; }
}

@media (max-width: 640px) {
    .panel { padding: 16px; }
    .top-bar-center { display: none; }
    .user-name { display: none; }
    .llm-status { display: none; }
    .search-box { width: 180px; }
}
