/**
 * POE Chat - Complete Stylesheet
 */

/* Design Tokens */
:root {
    /* Primary */
    --primary: #667eea;
    --primary-hover: #5a6fd6;
    
    /* Semantic */
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Background */
    --bg-primary: #ffffff;
    --bg-secondary: var(--gray-50);
    --bg-sidebar: var(--gray-100);
    --bg-hover: var(--gray-100);
    
    /* Text */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);
    
    /* Border */
    --border-color: var(--gray-200);
    --border-radius: 8px;
    --border-radius-sm: 4px;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', 'Monaco', monospace;
    
    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Animations */
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s var(--ease-out);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Sidebar Components */
.sidebar-branding {
    padding: var(--space-5) var(--space-4);
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header button {
    width: 100%;
}

.search-wrapper {
    position: relative;
    margin-top: var(--space-3);
}

.search-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    padding-left: calc(var(--space-3) + 20px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.15s, background-color 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-4);
    padding-top: var(--space-2);
}

.chat-item {
    position: relative;
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.15s;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--primary);
    color: white;
}

.chat-item-title {
    font-weight: 500;
    margin-bottom: var(--space-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 64px; /* Space for action buttons */
}

.chat-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.chat-item.active .chat-item-meta {
    color: rgba(255, 255, 255, 0.8);
}

.chat-item-actions {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    display: flex;
    gap: var(--space-1);
    opacity: 0;
    transition: opacity 0.15s;
}

.chat-item:hover .chat-item-actions {
    opacity: 1;
}

/* Better visibility for buttons inside chat items */
.chat-item-actions .btn-ghost {
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-700);
    box-shadow: var(--shadow-sm);
}

.chat-item-actions .btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    color: var(--gray-900);
}

.chat-item.active .chat-item-actions .btn-ghost {
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
}

.chat-item.active .chat-item-actions .btn-ghost:hover:not(:disabled) {
    background: white;
    color: var(--primary-hover);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

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

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

/* Chat Header */
.chat-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-primary);
}

.header-model-select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    cursor: pointer;
    min-width: 180px;
    outline: none;
    transition: border-color 0.15s;
    margin-left: var(--space-2);
    margin-right: var(--space-1);
}

.header-model-select:hover {
    border-color: var(--primary);
}

.header-model-select:focus {
    border-color: var(--primary);
}

.chat-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

.message {
    margin-bottom: var(--space-6);
    max-width: 800px;
}

.message-user {
    margin-left: auto;
}

.message-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: 12px;
    color: var(--text-secondary);
}

.message-role {
    font-weight: 600;
}

.message-content {
    position: relative;
    padding: var(--space-4);
    border-radius: var(--border-radius);
    background: #f0f4f8;
    line-height: 1.6;
}

.message-user .message-content {
    background: #e8f0fe;
    color: #1f2937;
}

.message-actions {
    position: absolute;
    bottom: var(--space-2);
    right: var(--space-2);
    display: flex;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity 0.15s;
}

.message:hover .message-actions {
    opacity: 1;
}

/* Better visibility for buttons inside message content */
.message-actions .btn-ghost {
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-700);
    box-shadow: var(--shadow-sm);
}

.message-actions .btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    color: var(--gray-900);
}

.message-user .message-actions .btn-ghost {
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
}

.message-user .message-actions .btn-ghost:hover:not(:disabled) {
    background: white;
    color: var(--primary-hover);
}

/* Input Area */
.input-area {
    padding: var(--space-4) var(--space-4) var(--space-2) var(--space-4);
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.input-container {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
}

.input-textarea {
    flex: 1;
    min-height: 40px;
    max-height: 200px;
    padding: 10px var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 20px;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
}

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

/* Buttons */
button {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    padding: var(--space-2) var(--space-4);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    transition: all 0.15s;
    outline: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn-icon {
    padding: var(--space-2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon-sm {
    padding: var(--space-1);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    padding: var(--space-1) var(--space-2);
    font-size: 12px;
}

/* Form Elements */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-label .btn-icon-sm {
    opacity: 0.7;
    transition: opacity 0.15s;
}

.form-label .btn-icon-sm:hover {
    opacity: 1;
}

.form-group {
    margin-bottom: var(--space-4);
}

/* Panels */
.settings-panel,
.knowledge-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s var(--ease-out);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.settings-panel.open,
.knowledge-panel.open {
    right: 0;
}

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

.panel-title {
    font-size: 16px;
    font-weight: 600;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    min-width: 300px;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--border-radius);
    background: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s var(--ease-out);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-loading {
    border-left: 4px solid var(--info);
}

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

.toast-loading .toast-icon svg {
    animation: spin 1s linear infinite;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    opacity: 1;
}

.modal {
    min-width: 400px;
    max-width: 600px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s var(--ease-out);
}

.modal.show {
    opacity: 1;
    transform: scale(1);
}

.modal-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: var(--space-4);
}

.modal-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Loading States */
.spinner-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.skeleton {
    height: 60px;
    margin-bottom: var(--space-2);
    border-radius: var(--border-radius);
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: var(--space-8);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: var(--space-6);
    text-align: center;
}

/* Markdown Styles */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: var(--space-4);
    margin-bottom: var(--space-2);
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }

.message-content p {
    margin-bottom: var(--space-3);
}

.message-content code {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.message-content pre {
    margin: var(--space-3) 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-content ul,
.message-content ol {
    margin-left: var(--space-6);
    margin-bottom: var(--space-3);
}

.message-content blockquote {
    border-left: 4px solid var(--gray-300);
    padding-left: var(--space-4);
    margin: var(--space-3) 0;
    color: var(--text-secondary);
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--space-3) 0;
}

.message-content table th,
.message-content table td {
    border: 1px solid var(--border-color);
    padding: var(--space-2) var(--space-3);
    text-align: left;
}

.message-content table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.message-content a {
    color: var(--primary);
    text-decoration: underline;
}

.message-content a:hover {
    color: var(--primary-hover);
}

/* Code Block Enhancements */
.code-block-wrapper {
    position: relative;
    margin: var(--space-3) 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--gray-900);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-block-language {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}

.copy-code-btn {
    padding: var(--space-1) var(--space-2);
    font-size: 11px;
    color: var(--gray-300);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.15s;
}

.copy-code-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.copy-code-btn.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.code-block-wrapper pre {
    margin: 0;
    padding: var(--space-4);
    background: var(--gray-900);
    overflow-x: auto;
}

.code-block-wrapper pre code {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--gray-100);
}

/* Highlight.js theme adjustments */
.code-block-wrapper .hljs {
    background: var(--gray-900);
    padding: 0;
}

/* Smooth scroll */
.messages-container {
    scroll-behavior: smooth;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        width: 100%;
        z-index: 200;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .settings-panel,
    .knowledge-panel {
        right: 0;
        top: auto;
        bottom: -100%;
        width: 100%;
        height: 80vh;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }
    
    .settings-panel.open,
    .knowledge-panel.open {
        bottom: 0;
    }
    
    .messages-container {
        padding: var(--space-4);
    }
    
    .message {
        max-width: 100%;
    }
}

/* Accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Error Log Modal */
.error-log-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.error-log-modal.show {
    opacity: 1;
}

.error-log-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.error-log-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.error-log-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.error-log-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.error-log-stats {
    display: flex;
    gap: var(--space-3);
    font-size: 12px;
}

.error-log-stats .error-count {
    color: var(--error);
    font-weight: 600;
}

.error-log-stats .warning-count {
    color: var(--warning);
    font-weight: 600;
}

.error-log-header .btn-icon {
    margin-left: auto;
}

.error-log-toolbar {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-secondary);
}

.error-log-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.error-log-empty {
    text-align: center;
    padding: var(--space-12);
    color: var(--text-muted);
    font-size: 16px;
}

.error-log-item {
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--border-color);
    background: var(--bg-secondary);
}

.error-log-item-error {
    border-left-color: var(--error);
    background: #fef2f2;
}

.error-log-item-warning {
    border-left-color: var(--warning);
    background: #fffbeb;
}

.error-log-item-info {
    border-left-color: var(--info);
    background: #eff6ff;
}

.error-log-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.error-log-level {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.error-log-time {
    font-size: 11px;
    color: var(--text-muted);
}

.error-log-message {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
    word-break: break-word;
}

.error-log-source {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-bottom: var(--space-2);
}

.error-log-url {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.error-log-stack {
    margin-top: var(--space-2);
    font-size: 12px;
}

.error-log-stack summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
    user-select: none;
}

.error-log-stack summary:hover {
    color: var(--primary-hover);
}

.error-log-stack pre {
    margin-top: var(--space-2);
    padding: var(--space-3);
    background: var(--gray-900);
    color: var(--gray-100);
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-2) 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Stats Bar - Unified Container */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-1) 0 0 0;
    gap: var(--space-3);
}

/* Stats Text - Shared Style */
.stats-text {
    font-size: 11px;
    opacity: 0.7;
    color: var(--text-muted);
    transition: opacity 0.2s var(--ease-out);
    white-space: nowrap;
    user-select: none;
}

.stats-text:not(:empty):hover {
    opacity: 1;
    cursor: default;
}

#context-stats {
    text-align: right;
}

/* Warning indicator for truncated context */
.stats-text .warning-icon {
    color: var(--warning);
}

/* Custom Tooltips */
.tooltip-wrapper {
    position: relative;
    display: inline-flex;
}

.tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-2) var(--space-3);
    background: var(--gray-900);
    color: white;
    font-size: 12px;
    line-height: 1.4;
    border-radius: var(--border-radius);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s var(--ease-out);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 32px);
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-bottom-color: var(--gray-900);
}

.tooltip-wrapper:hover .tooltip {
    opacity: 1;
}

/* Prevent tooltip from overflowing viewport */
.chat-header .tooltip-wrapper:first-of-type .tooltip,
.chat-header .tooltip-wrapper:nth-of-type(1) .tooltip {
    left: 0;
    transform: translateX(0);
}

.chat-header .tooltip-wrapper:first-of-type .tooltip::after,
.chat-header .tooltip-wrapper:nth-of-type(1) .tooltip::after {
    left: 20px;
}

.chat-header .tooltip-wrapper:last-of-type .tooltip {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.chat-header .tooltip-wrapper:last-of-type .tooltip::after {
    left: auto;
    right: 20px;
    transform: translateX(0);
}

/* Multi-line tooltip */
.tooltip.tooltip-multiline {
    white-space: normal;
    max-width: 280px;
    text-align: left;
}

.tooltip-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
    font-size: 13px;
}

.tooltip-desc {
    font-size: 11px;
    opacity: 0.9;
    line-height: 1.5;
}

/* Multi-select Dropdown */
.multi-select {
    position: relative;
    width: 100%;
    min-height: 32px;
    padding: 4px var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.multi-select:focus-within {
    border-color: var(--primary);
    background: var(--bg-primary);
}

.multi-select-placeholder {
    color: var(--text-muted);
    padding: 2px 4px;
}

.multi-select-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.multi-select-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1;
}

.multi-select-tag-remove {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 10px;
    transition: background 0.15s;
}

.multi-select-tag-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.multi-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-height: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    overflow-y: auto;
    display: none;
}

.multi-select-dropdown.show {
    display: block;
}

.multi-select-search-container {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.multi-select-search {
    width: 100%;
    padding: 4px var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    outline: none;
}

.multi-select-search:focus {
    border-color: var(--primary);
}

.multi-select-option {
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.multi-select-option:hover {
    background: var(--bg-hover);
}

.multi-select-option.selected {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.multi-select-option.selected::after {
    content: '✓';
    font-size: 10px;
}

.multi-select-option.hidden {
    display: none;
}

/* Disabled state tooltip - appears for disabled buttons */
.btn-icon:disabled + .tooltip {
    display: none;
}

.btn-icon:disabled .tooltip-disabled {
    display: block;
}
