/* ==========================================================================
   TLE AI — Main Stylesheet
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --color-header: #cfe2f3;
    --color-primary: #4a90a4;
    --color-primary-dark: #2c5f7c;
    --color-primary-light: #e8f4f8;
    --color-bg: #ffffff;
    --color-bg-alt: #f9fafb;
    --color-bg-hover: #f3f4f6;
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-border: #e5e7eb;
    --color-focus-ring: #bfdbfe;
    --color-focus-border: #60a5fa;

    --color-success: #059669;
    --color-success-bg: #d1fae5;
    --color-success-text: #065f46;
    --color-warning: #d97706;
    --color-warning-bg: #fef3c7;
    --color-warning-text: #92400e;
    --color-danger: #dc2626;
    --color-danger-bg: #fee2e2;
    --color-danger-text: #991b1b;
    --color-info: #2563eb;
    --color-info-bg: #dbeafe;
    --color-info-text: #1e40af;

    --sidebar-width: 256px;
    --sidebar-collapsed-width: 64px;
    --transition-speed: 0.2s;
}

/* --- Base --- */
body {
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--color-header);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width var(--transition-speed) ease;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar header (logo + toggle) */
.sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--color-text);
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--color-primary-dark);
    transition: opacity var(--transition-speed) ease;
}

.sidebar-logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-speed) ease;
}

.sidebar-logo-subtitle {
    font-size: 0.6875rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-speed) ease;
}

body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .sidebar-logo-subtitle {
    display: none;
}

/* When collapsed, shrink logo to just the icon */
body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0.75rem 0.5rem;
    position: relative;
}

body.sidebar-collapsed .sidebar-logo {
    justify-content: center;
}

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-item:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--color-text);
}

.sidebar-nav-item.active {
    background-color: rgba(74, 144, 164, 0.15);
    color: var(--color-primary-dark);
    font-weight: 500;
}

/* Sidebar conversation item with delete icon */
.sidebar-conv-item {
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    transition: background-color 0.15s;
    overflow: hidden;
}

.sidebar-conv-item:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.sidebar-conv-item.active {
    background-color: rgba(74, 144, 164, 0.15);
}

.sidebar-conv-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    flex: 1;
    min-width: 0;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
}

.sidebar-conv-item.active .sidebar-conv-link {
    color: var(--color-primary-dark);
    font-weight: 500;
}

/* Sidebar 3-dot menu */
.sidebar-conv-menu {
    position: relative;
    flex-shrink: 0;
    padding-right: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.sidebar-conv-item:hover .sidebar-conv-menu {
    opacity: 1;
}

.sidebar-menu-dropdown {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 200;
    min-width: 130px;
    padding: 0.25rem 0;
}

.sidebar-menu-dropdown.show {
    display: block;
}

.sidebar-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.875rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    transition: background-color 0.15s;
}

.sidebar-menu-dropdown button:hover {
    background-color: var(--color-bg-alt);
    color: var(--color-text);
}

.sidebar-menu-dropdown button.text-danger:hover {
    color: #ef4444;
    background-color: #fef2f2;
}

.sidebar-rename-input {
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    margin: 0.15rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--color-primary);
    border-radius: 0.375rem;
    outline: none;
    background: #fff;
}

body.sidebar-collapsed .sidebar-conv-menu {
    display: none;
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity var(--transition-speed) ease;
}

body.sidebar-collapsed .sidebar-label {
    display: none;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 0.75rem 0.75rem 0.25rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 0.5rem 0;
}

/* New conversation button in sidebar */
.sidebar-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s;
    margin-bottom: 0.5rem;
}

.sidebar-new-chat:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1rem;
    flex-shrink: 0;
}

.sidebar-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible;
}

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

.sidebar-user-email {
    font-size: 0.9em;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* 3-dot menu button & dropdown */
.sidebar-user-menu {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}

.sidebar-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: color 0.15s, background-color 0.15s;
}

.sidebar-menu-btn:hover {
    color: var(--color-text);
    background-color: rgba(0, 0, 0, 0.06);
}

.sidebar-dropdown {
    display: none;
    position: fixed;
    min-width: 160px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 0.25rem;
    z-index: 200;
}

.sidebar-dropdown.open {
    display: block;
}

.sidebar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}

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

.sidebar-dropdown-item .sidebar-icon {
    width: 16px;
    height: 16px;
}

/* Toggle button — always visible when expanded, hover-only when collapsed */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s, opacity 0.15s;
    border-radius: 0.375rem;
    flex-shrink: 0;
    opacity: 1;
}

/* When collapsed: hide toggle by default, show on hover in place of logo */
body.sidebar-collapsed .sidebar-toggle {
    display: none;
}

body.sidebar-collapsed .sidebar:hover .sidebar-toggle {
    display: flex;
}

body.sidebar-collapsed .sidebar:hover .sidebar-logo-icon {
    display: none;
}

.sidebar-toggle:hover {
    color: var(--color-text);
    background-color: rgba(0, 0, 0, 0.06);
}

.sidebar-toggle .toggle-icon {
    width: 25px;
    height: 25px;
    transition: transform var(--transition-speed) ease;
}

body.sidebar-collapsed .sidebar-toggle .toggle-icon {
    transform: rotate(180deg);
}

/* Masquerade banner */
.sidebar-masquerade {
    background-color: var(--color-warning-bg);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: var(--color-warning-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-masquerade a {
    color: var(--color-warning-text);
    text-decoration: underline;
    font-weight: 500;
    white-space: nowrap;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--color-bg);
    transition: margin-left var(--transition-speed) ease;
    overflow-x: hidden;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* --- Auth Layout (no sidebar) --- */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

/* --- Toast Messages --- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 400px;
}

.toast-success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
}

.toast-error {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.toast-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.toast-info {
    background-color: var(--color-info-bg);
    color: var(--color-info-text);
}

/* --- Buttons --- */
.btn-primary {
    background-color: var(--color-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-primary:hover {
    opacity: 0.9;
}

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

.btn-danger {
    background-color: var(--color-danger);
    color: white;
    border: none;
    cursor: pointer;
}

.btn-danger:hover {
    background-color: var(--color-danger-text);
}

/* Outlined small action buttons */
.btn-outline-sm {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    background: transparent;
}

.btn-outline-primary {
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

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

.btn-outline-danger {
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

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

.btn-outline-warning {
    color: #d97706;
    border: 1px solid #d97706;
}

.btn-outline-warning:hover {
    background-color: #d97706;
    color: white;
}

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

.btn-secondary:hover {
    background-color: var(--color-bg-alt);
}

/* --- Form Inputs --- */
.form-input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    outline: none;
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
    border-color: var(--color-focus-border);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* --- Badges --- */
.badge-assistant {
    background-color: var(--color-header);
    color: var(--color-primary-dark);
}

.badge-status-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.badge-status-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-status-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-status-default {
    background-color: var(--color-bg-hover);
    color: var(--color-text-secondary);
}

/* --- Chat --- */
.chat-layout {
    display: flex;
    height: 100vh;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.chat-input-area {
    border-top: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 0.625rem 1rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input:focus {
    border-color: var(--color-focus-border);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.chat-send-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 0.75rem;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.chat-send-btn:hover {
    opacity: 0.9;
}

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

.chat-bubble-user {
    background-color: var(--color-bg-hover);
    border-radius: 1rem;
    border-top-right-radius: 0.25rem;
    padding: 0.75rem 1rem;
}

.chat-bubble-assistant {
    background-color: var(--color-primary-light);
    border-radius: 1rem;
    border-top-left-radius: 0.25rem;
    padding: 0.75rem 1rem;
}

/* Citations bar inside assistant bubbles */
.citations-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.625rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.citations-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.citation-tag {
    display: inline-block;
    font-size: 0.6875rem;
    color: var(--color-primary-dark);
    background-color: rgba(74, 144, 164, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
}

.data-table thead {
    background-color: var(--color-bg-alt);
}

.data-table th {
    padding: 0.5rem 0.625rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: none;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.data-table tbody tr {
    border-top: 1px solid var(--color-border);
}

.data-table tbody tr:hover {
    background-color: var(--color-bg-alt);
}

.data-table td {
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Cards --- */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

/* --- Prose (markdown content inside assistant bubbles) --- */
.prose {
    line-height: 1.6;
    word-wrap: break-word;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.prose h1 { font-size: 1.25rem; }
.prose h2 { font-size: 1.125rem; }
.prose h3 { font-size: 1rem; }
.prose h4 { font-size: 0.9375rem; }

.prose h1:first-child,
.prose h2:first-child,
.prose h3:first-child,
.prose h4:first-child {
    margin-top: 0;
}

.prose p {
    margin: 0.5rem 0;
}

.prose p:first-child {
    margin-top: 0;
}

.prose p:last-child {
    margin-bottom: 0;
}

.prose ul, .prose ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.prose ul {
    list-style-type: disc;
}

.prose ol {
    list-style-type: decimal;
}

.prose li {
    margin: 0.25rem 0;
}

.prose li > ul, .prose li > ol {
    margin: 0.125rem 0;
}

.prose strong {
    font-weight: 600;
    color: var(--color-text);
}

.prose em {
    font-style: italic;
}

.prose blockquote {
    border-left: 3px solid var(--color-primary);
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    color: var(--color-text-secondary);
    font-style: italic;
}

.prose hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 0.75rem 0;
}

.prose pre {
    background: var(--color-bg-hover);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
}

.prose code {
    background: var(--color-bg-hover);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.prose pre code {
    background: none;
    padding: 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.8125rem;
}

.prose th, .prose td {
    border: 1px solid var(--color-border);
    padding: 0.375rem 0.625rem;
    text-align: left;
}

.prose th {
    background: var(--color-bg-alt);
    font-weight: 600;
}

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

/* --- Typing indicator (three bouncing dots) --- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-text-muted);
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Links --- */
.link-primary {
    color: var(--color-primary);
    text-decoration: none;
}

.link-primary:hover {
    text-decoration: underline;
}

.link-danger {
    color: var(--color-danger);
    font-size: 0.75rem;
}

.link-danger:hover {
    text-decoration: underline;
}

/* --- Chat error toast --- */
.chat-error-toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
}

.chat-error-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Delete Confirmation Popup --- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: confirmFadeIn 0.15s ease;
}

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

.confirm-popup {
    background: var(--color-bg);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    animation: confirmSlideUp 0.15s ease;
}

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

.confirm-popup h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.confirm-popup p {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.confirm-popup-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.confirm-popup-actions button {
    padding: 0.5rem 1.125rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}

.confirm-popup-actions button:hover {
    opacity: 0.85;
}

.confirm-btn-cancel {
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border) !important;
}

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

/* --- Utility --- */
.text-primary { color: var(--color-primary); }
.text-primary-dark { color: var(--color-primary-dark); }
.bg-primary { background-color: var(--color-primary); }

/* --- Mobile hamburger button (hidden on desktop) --- */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: 0.375rem;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background-color: var(--color-bg-hover);
}

/* --- Mobile overlay (behind sidebar) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
}

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

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        z-index: 50;
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    body.sidebar-collapsed.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar-toggle {
        display: flex !important;
    }

    .chat-header {
        padding: 0.5rem 0.75rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .chat-input-area {
        padding: 0.75rem;
    }

    .chat-bubble-user,
    .chat-bubble-assistant {
        max-width: 95% !important;
    }

    .chat-input {
        font-size: 16px; /* Prevents iOS zoom */
    }

    .citation-tag {
        max-width: 150px;
    }
}
