/* ============================================
   Restaurant Analytics Chat - Dark Theme
   ============================================ */

:root {
    /* Color Palette - Deep Ocean */
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --bg-hover: #374151;
    
    --accent-primary: #10b981;
    --accent-secondary: #06d6a0;
    --accent-glow: rgba(16, 185, 129, 0.3);
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --border-color: #374151;
    --border-light: #4b5563;
    
    --star-color: #fbbf24;
    --error-color: #ef4444;
    --success-color: #10b981;
    
    /* Typography */
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --sidebar-width: 280px;
    --header-height: 64px;
    --input-height: 80px;
    
    /* Transitions */
    --transition-fast: 100ms ease;
    --transition-normal: 250ms ease;
}

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

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

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================
   Lucide Icons
   ============================================ */

[data-lucide] {
    width: 1em;
    height: 1em;
    stroke-width: 2;
    vertical-align: middle;
}

.logo-icon [data-lucide] {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.btn-icon [data-lucide] {
    width: 18px;
    height: 18px;
}

.star-icon [data-lucide] {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.action-btn [data-lucide] {
    width: 16px;
    height: 16px;
}

.star-btn.active [data-lucide] {
    fill: var(--star-color);
}

.edit-title-btn [data-lucide] {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.edit-title-btn:hover [data-lucide] {
    color: var(--text-primary);
}

.context-btn [data-lucide] {
    width: 16px;
    height: 16px;
}

.welcome-icon {
    margin-bottom: 20px;
}

.welcome-icon [data-lucide] {
    width: 64px;
    height: 64px;
    color: var(--accent-primary);
    stroke-width: 1.5;
}

.message-avatar [data-lucide] {
    width: 20px;
    height: 20px;
}

.sql-query-toggle [data-lucide] {
    width: 14px;
    height: 14px;
}

.send-icon [data-lucide] {
    width: 20px;
    height: 20px;
}

.clear-context-btn [data-lucide] {
    width: 14px;
    height: 14px;
}

.modal-close [data-lucide] {
    width: 20px;
    height: 20px;
}

.favorite-checkbox [data-lucide] {
    width: 14px;
    height: 14px;
    opacity: 0;
}

.favorite-option.selected .favorite-checkbox [data-lucide] {
    opacity: 1;
    color: var(--bg-primary);
}

/* App Container */
.app-container {
    display: flex;
    max-height: 100vh;
    height: 100%;
    width: 100vw;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: start;
    justify-content: space-between;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 1.4rem;
}

.sync-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.last-sync {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.last-sync [data-lucide] {
    width: 12px;
    height: 12px;
    color: var(--accent-primary);
}

.last-sync.loading [data-lucide] {
    animation: spin 1s linear infinite;
}

.sync-btn {
    padding: 6px 10px;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.75rem;
    min-width: 32px;
    height: 28px;
}

.sync-btn:hover:not(:disabled) {
    background: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--accent-glow);
}

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

.sync-btn [data-lucide] {
    width: 14px;
    height: 14px;
}

.sync-btn.loading [data-lucide] {
    animation: spin 1s linear infinite;
}

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

/* New Chat Button */
.new-chat-btn {
    margin: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 10px;
    color: var(--bg-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-icon {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Sidebar Sections */
.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 16px 8px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.star-icon {
    color: var(--star-color);
}

/* Chat List */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item {
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all var(--transition-fast) ease-in-out;
    background: transparent;
}

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

.chat-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-primary);
}

.chat-title {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.active .chat-title,
.chat-item:hover .chat-title {
    color: var(--text-primary);
}

.chat-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--bg-hover);
    border-radius: 10px;
    color: var(--text-muted);
}

.chat-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.action-btn {
    padding: 4px 6px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-hover);
}

.star-btn {
    color: var(--text-muted);
}

.star-btn.active,
.star-btn:hover {
    color: var(--star-color);
}

.delete-btn:hover {
    color: var(--error-color);
}

.empty-state {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    height: 100%;
}

/* Chat Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    padding: 0 16px;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-btn,
.logout-btn {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-primary);
}

.admin-btn [data-lucide],
.logout-btn [data-lucide] {
    width: 16px;
    height: 16px;
}

.admin-btn:hover,
.logout-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.admin-btn:active,
.logout-btn:active {
    transform: translateY(0);
}

.chat-header {
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mobile menu button - hidden on desktop */
.menu-btn {
    display: none;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.menu-btn [data-lucide] {
    width: 24px;
    height: 24px;
}

.chat-name {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.edit-title-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.edit-title-btn:hover {
    opacity: 1;
}

.context-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

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

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100vw;
}


.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-content h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-content > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.example-questions h4 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.example-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.example-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* Messages */
.messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    width: 100%;
    min-width: 0;
    animation: messageIn 0.3s ease;
}

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

.message.human {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.message.human .message-avatar {
    background: var(--accent-glow);
    color: var(--accent-primary);
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.message-content {
    width: 100%;
    min-width: 0;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.7;
}

.message.human .message-content {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* Code blocks in messages */
.message-content pre {
    background: var(--bg-primary);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.message-content code {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

/* Tables in messages */
.message-content .table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.message-content .table-container::-webkit-scrollbar {
    height: 6px;
}

.message-content .table-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.message-content .table-container::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.message-content .table-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.message-content table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.message-content th,
.message-content td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 500;
    position: sticky;
    top: 0;
}

/* Highlight rows with largest segment changes */
.message-content table tr.highlight-max-change {
    background: rgba(251, 191, 36, 0.15); /* Light yellow/orange background */
    border-left: 3px solid rgba(251, 191, 36, 0.6); /* Left border accent */
    animation: highlightFadeIn 0.5s ease-in;
}

.message-content table tr.highlight-max-change:hover {
    background: rgba(251, 191, 36, 0.25);
}

.message-content table tr.highlight-max-change td,
.message-content table tr.highlight-max-change th {
    font-weight: 500;
}

@keyframes highlightFadeIn {
    from {
        background: transparent;
    }
    to {
        background: rgba(251, 191, 36, 0.15);
    }
}

/* Table wrapper with export buttons */
.message-content .table-wrapper {
    margin: 12px 0;
}

.message-content .table-wrapper .table-container {
    margin: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.table-export-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.table-export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.table-export-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.table-export-btn [data-lucide] {
    width: 14px;
    height: 14px;
}

/* SQL query display */
.sql-query {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sql-query:hover {
    color: var(--text-secondary);
}

.sql-query-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sql-query-toggle [data-lucide] {
    width: 14px;
    height: 14px;
}

.sql-query-content {
    display: none;
}

/* Chart container */
.message-content .chart-container {
    width: 100%;
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    min-height: 400px;
    position: relative;
}

.message-content .chart-container canvas {
    max-width: 100%;
    height: 100% !important;
}

.message-content .chart-container .chart-error {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
    white-space: pre-wrap;
    color: var(--accent-primary);
}

.sql-query.expanded .sql-query-content {
    display: block;
}

/* Input Area */
.input-area {
    padding: 16px 24px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.selected-context {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.context-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.context-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.context-chip {
    padding: 4px 10px;
    background: var(--accent-glow);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.clear-context-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.9rem;
}

.clear-context-btn:hover {
    color: var(--error-color);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    resize: none;
    max-height: 150px;
    min-width: 0;
    transition: all var(--transition-fast);
}

#message-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#message-input::placeholder {
    color: var(--text-muted);
}

#message-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.refresh-btn {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.refresh-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.refresh-btn [data-lucide] {
    width: 20px;
    height: 20px;
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 12px;
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.send-icon {
    font-size: 1.2rem;
}

/* Input Loading */
.input-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-height: 48px;
}

.input-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.input-loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ============================================
   Modal
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

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

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

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

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

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

.modal-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.favorites-select {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.favorite-option {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
}

.favorite-option:hover {
    border-color: var(--accent-primary);
}

.favorite-option.selected {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
}

.favorite-option input {
    display: none;
}

.favorite-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.favorite-option.selected .favorite-checkbox {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.favorite-label {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.favorite-option.selected .favorite-label {
    color: var(--text-primary);
}

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

.modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-btn.cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.modal-btn.cancel:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-btn.confirm {
    background: var(--accent-primary);
    border: none;
    color: var(--bg-primary);
}

.modal-btn.confirm:hover {
    background: var(--accent-secondary);
}

/* ============================================
   Loading Overlay
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 26, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============================================
   Sidebar Overlay (mobile)
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        width: var(--sidebar-width);
        z-index: 100;
        transition: left var(--transition-normal);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .chat-header {
        padding: 0 16px;
    }
    
    .chat-name {
        font-size: 0.95rem;
        flex: 1;
        min-width: 0;
    }
    
    .chat-info {
        flex: 1;
        min-width: 0;
    }
    
    .messages-container {
        padding: 16px;
        height: 100%;
        min-height: 0;
    }
    
    .input-area {
        padding: 12px 16px 16px;
        position: sticky;
        bottom:0;
    }
    
    .message {
        max-width: 95%;
    }
    
    .welcome-content {
        padding: 0 16px;
    }
    
    .welcome-content h2 {
        font-size: 1.2rem;
    }
    
    .welcome-icon [data-lucide] {
        width: 48px;
        height: 48px;
    }
    
    .example-btn {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
    
    /* Hide text in context button on mobile, keep only icon */
    .context-btn {
        padding: 8px 12px;
        font-size: 0;
        gap: 0;
    }
    
    .context-btn [data-lucide] {
        font-size: 16px;
    }
    
    /* Hide chat-controls and user-info on mobile */
    .chat-controls,
    .user-info {
        display: none !important;
    }
    
    /* Show dropdown on mobile */
    .header-dropdown {
        display: block;
    }
}

/* Header Dropdown (mobile) */
.header-dropdown {
    position: relative;
    display: none;
}

.header-dropdown-toggle {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-dropdown-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.header-dropdown-toggle [data-lucide] {
    width: 20px;
    height: 20px;
}

.header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
}

.header-dropdown-menu.open {
    display: flex;
}

.header-dropdown-user {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.header-dropdown-user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.header-dropdown-user-role {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.header-dropdown-item {
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    width: 100%;
    font-family: var(--font-primary);
}

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

.header-dropdown-item [data-lucide] {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.header-dropdown-item span {
    text-wrap: nowrap;
}

.header-dropdown-item:hover [data-lucide] {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    /* Hide chat-controls and user-info on mobile */
    .chat-controls,
    .user-info {
        display: none !important;
    }
    
    /* Show dropdown on mobile */
    .header-dropdown {
        display: block;
    }
}

