/* Modern Professional Design System */
:root {
    --sidebar-width: 280px;
    --sidebar-slim-width: 80px;

    /* Transitions */
    --transition-snappy: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* --- Dark Theme (Default) — Professional Slate --- */
[data-theme="dark"],
:root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary-bg: linear-gradient(145deg, #0f1117 0%, #161921 50%, #111318 100%);
    --sidebar-bg: rgba(18, 21, 30, 0.92);
    --message-bg: rgba(255, 255, 255, 0.04);
    --user-message-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.22) 0%, rgba(79, 70, 229, 0.22) 100%);
    --text-primary: #e8eaed;
    --text-secondary: rgba(232, 234, 237, 0.6);
    --text-tertiary: rgba(232, 234, 237, 0.38);
    --accent-blue: #6366f1;
    --accent-cyan: #818cf8;
    --accent-green: #34d399;
    --border-color: rgba(148, 163, 184, 0.12);
    --particle-color: rgba(99, 102, 241, 0.25);
    --glass-border: 1px solid rgba(148, 163, 184, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.45);
    --bot-glow: 0 4px 20px rgba(99, 102, 241, 0.2);
}

/* --- Light Theme — Clean Professional --- */
[data-theme="light"] {
    color-scheme: light;
    --primary-bg: linear-gradient(145deg, #f8f9fb 0%, #ffffff 50%, #f1f3f8 100%);
    --sidebar-bg: rgba(255, 255, 255, 0.97);
    --message-bg: rgba(99, 102, 241, 0.06);
    --user-message-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.85) 0%, rgba(79, 70, 229, 0.85) 100%);
    --text-primary: #1e1e2e;
    --text-secondary: rgba(30, 30, 46, 0.65);
    --text-tertiary: rgba(30, 30, 46, 0.45);
    --accent-blue: #6366f1;
    --accent-cyan: #818cf8;
    --accent-green: #34d399;
    --border-color: rgba(30, 30, 46, 0.1);
    --particle-color: rgba(99, 102, 241, 0.12);
    --glass-border: 1px solid rgba(30, 30, 46, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.06);
    --bot-glow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

/* --- Global Styles --- */
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    transition: background var(--transition-smooth);
}

/* Background Particles Container */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Geometric Blobs */
.bg-blob {
    position: fixed;
    width: 400px;
    height: 400px;
    background: var(--accent-blue);
    filter: blur(80px);
    opacity: 0.03;
    border-radius: 50%;
    z-index: -2;
    animation: rotate-blob 30s linear infinite;
}

.blob-1 {
    top: -100px;
    right: -100px;
}

.blob-2 {
    bottom: -100px;
    left: -100px;
    background: var(--accent-cyan);
}

@keyframes rotate-blob {
    from {
        transform: rotate(0deg) scale(1);
    }

    33% {
        transform: rotate(120deg) scale(1.1);
    }

    66% {
        transform: rotate(240deg) scale(0.9);
    }

    to {
        transform: rotate(360deg) scale(1);
    }
}

/* --- Animations --- */
@keyframes float-bot {

    0%,
    100% {
        transform: translateY(0) rotate(0);
    }

    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: var(--bot-glow);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 48px rgba(59, 130, 246, 0.6);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) skewX(-30deg);
    }

    100% {
        transform: translateX(200%) skewX(-30deg);
    }
}

@keyframes glow {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Shimmer Overlay Utility */
.shimmer-effect {
    position: relative;
    overflow: hidden;
}

.shimmer-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
    pointer-events: none;
}

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

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-snappy), transform var(--transition-snappy), box-shadow var(--transition-snappy);
    z-index: 1000;
    position: relative;
    flex-shrink: 0;
}

.sidebar.slim {
    width: var(--sidebar-slim-width);
}

/* Expansion Overlay */
.sidebar.expanded {
    position: absolute;
    height: 100%;
    width: var(--sidebar-width) !important;
    z-index: 1100;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
}

/* Visibility Control */
.sidebar.slim:not(.expanded) .brand-text,
.sidebar.slim:not(.expanded) .new-chat-btn span,
.sidebar.slim:not(.expanded) .thread-title,
.sidebar.slim:not(.expanded) .thread-actions,
.sidebar.slim:not(.expanded) .user-info {
    display: none !important;
}

.sidebar.slim:not(.expanded) .thread-icon {
    margin-right: 0 !important;
    font-size: 18px;
}

.sidebar.slim:not(.expanded) .brand-toggle-wrapper {
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.sidebar.slim:not(.expanded) .brand {
    flex-direction: column;
    gap: 0;
}

.sidebar.slim:not(.expanded) .brand-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.sidebar.slim:not(.expanded) .sidebar-header {
    justify-content: center;
    padding: 32px 0 20px 0;
    height: auto;
}

.sidebar.slim:not(.expanded) .sidebar-nav {
    padding: 0;
    align-items: center;
}

.sidebar.slim:not(.expanded) .new-chat-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 12px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar.slim:not(.expanded) .thread-item {
    justify-content: center;
    padding: 12px;
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 12px;
    border-left: 1px solid transparent;
    /* Match border-box sizing with other states */
}

.sidebar.slim:not(.expanded) .avatar-circle {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.sidebar.slim:not(.expanded) .user-profile {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sidebar.slim:not(.expanded) .sidebar-footer {
    padding: 16px 0;
}

.sidebar.slim:not(.expanded) .thread-content {
    justify-content: center;
}

.sidebar.slim:not(.expanded) .thread-icon {
    margin: 0;
}

.sidebar-header {
    padding: 24px;
    height: 100px;
    display: flex;
    align-items: center;
}

.brand-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.sidebar.slim .brand-toggle-wrapper {
    justify-content: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

/* Brand text handled by visibility control */

.brand-icon {
    width: 40px;
    height: 40px;
    background: transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.sidebar.slim:not(.expanded) .brand-icon {
    width: 44px;
    height: 44px;
}

.brand-text {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #e8eaed, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

[data-theme="light"] .brand-text {
    background: linear-gradient(135deg, #1e1e2e, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Sidebar Toggle Buttons */
.sidebar-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.sidebar.slim:not(.expanded) .sidebar-toggle-btn {
    width: 40px;
    height: 40px;
}

/* Scrollbar Layout fixes */

.sidebar.pinned .sidebar-toggle-btn {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-blue);
}

.mobile-toggle-btn {
    display: none;
    /* Hidden on desktop */
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--bot-glow);
}

.mobile-toggle-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Scrollbar Layout fixes */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    transition: margin-left var(--transition-snappy);
    position: relative;
    min-width: 0;
    /* Prevent flex overflow */
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
}

.new-chat-btn {
    width: 100%;
    height: 50px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3);
    transition: var(--transition-fast);
}

.sidebar.slim .new-chat-btn span {
    display: none;
}

.new-chat-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.5);
}

/* Chat Items */
.threads-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thread-item {
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid transparent;
    color: var(--text-secondary);
    position: relative;
}

.thread-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

.thread-icon {
    font-size: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}

.thread-title {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 14px;
}

.thread-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transform: translateX(5px);
    border-left: 3px solid var(--accent-blue);
}

.thread-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(6, 182, 212, 0.1));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.sidebar.slim:not(.expanded) .thread-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.15));
    border: 2px solid var(--accent-blue);
    border-radius: 12px;
}

.sidebar.slim:not(.expanded) .thread-item {
    padding: 12px;
    justify-content: center;
}

.sidebar.slim:not(.expanded) .thread-item.active .thread-icon {
    color: var(--accent-blue);
}

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

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

.action-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.action-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: translateY(-1px);
}

.action-icon:nth-child(2):hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.action-icon i {
    font-size: 12px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 28px;
    border-top: var(--glass-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    width: 100%;
    overflow: hidden;
}

.avatar-circle {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 12px var(--shadow-color);
    font-size: 14px;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #10b981, #34d399);
    border: 2px solid var(--sidebar-bg);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    font-size: 13px;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
    transform: translateY(-1px);
}

.sidebar.slim:not(.expanded) .logout-btn,
.sidebar.slim:not(.expanded) .theme-toggle-btn {
    width: 40px;
    height: 40px;
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* User info handled by visibility control */

.user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.user-email {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* --- Main Chat Area --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    height: 80px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: var(--glass-border);
    backdrop-filter: blur(10px);
}

.currentThreadTitle {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: slideIn 0.8s ease-out;
}

.floating-bot {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    box-shadow: var(--bot-glow);
    margin-bottom: 32px;
    animation: float-bot 4s ease-in-out infinite, pulse 3s ease-in-out infinite;
}

.welcome-title {
    font-size: 38px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #e8eaed, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .welcome-title {
    background: linear-gradient(135deg, #1e1e2e, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Message Bubbles */
.message-row {
    display: flex;
    gap: 16px;
    max-width: 80%;
    animation: slideIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

.message-bubble {
    padding: 18px 24px;
    font-size: 15px;
    line-height: 1.6;
    backdrop-filter: blur(20px);
    transition: var(--transition-fast);
}

.message-bubble:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px var(--shadow-color);
}

.bot-bubble {
    background: var(--message-bg);
    border: var(--glass-border);
    border-radius: 24px 24px 24px 6px;
    color: var(--text-primary);
}

.user-bubble {
    background: var(--user-message-bg);
    border-radius: 24px 24px 6px 24px;
    color: white;
}

/* --- Input Area --- */
.chat-input-area {
    padding: 24px 32px;
    background: transparent;
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border: 2px solid var(--border-color);
    border-radius: 28px;
    padding: 8px 8px 8px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 10px 0;
    outline: none;
    resize: none;
    max-height: 150px;
}

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1) rotate(20deg);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

/* Modal Buttons */
.btn-saas-primary,
.btn-saas-secondary {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-saas-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: white;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.btn-saas-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4);
}

.btn-saas-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

.btn-saas-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3) !important;
}

.btn-danger:hover {
    box-shadow: 0 12px 32px rgba(239, 68, 68, 0.4) !important;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
    margin-bottom: 16px;
}
/* Select & Dropdown Option Styling for Dark Mode */
select,
select.form-control {
    background-color: #121826 !important;
    color: #ffffff !important;
    color-scheme: dark !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
}

select option,
option {
    background-color: #1a2234 !important;
    color: #ffffff !important;
    padding: 10px 14px;
}

select option:hover,
select option:focus,
select option:checked,
select option:active,
option:checked {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

/* Light theme overrides */
[data-theme="light"] select,
[data-theme="light"] select.form-control {
    background-color: #ffffff !important;
    color: #1e293b !important;
    color-scheme: light !important;
    border: 1px solid #cbd5e1 !important;
}

[data-theme="light"] select option,
[data-theme="light"] option {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

.form-control::file-selector-button,
.form-control::-webkit-file-upload-button {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue, #60a5fa);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    padding: 4px 12px;
    margin-right: 10px;
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.form-control::file-selector-button:hover,
.form-control::-webkit-file-upload-button:hover {
    background: rgba(59, 130, 246, 0.25);
    color: #ffffff;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

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

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--sidebar-bg);
    border: var(--glass-border);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform var(--transition-fast);
}

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

.modal h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--accent-blue), var(--accent-cyan));
    border-radius: 10px;
}

/* Responsive */
/* --- Mobile Overlay --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-snappy);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .mobile-toggle-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px !important;
        height: 100%;
        transition: transform var(--transition-snappy);
        pointer-events: all;
    }

    .sidebar.open {
        transform: translateX(280px);
    }

    /* Override slim mode on mobile - always show full sidebar */
    .sidebar.slim {
        width: 280px !important;
    }

    /* Force show all text and elements on mobile */
    .sidebar.slim:not(.expanded) .brand-text,
    .sidebar.slim:not(.expanded) .new-chat-btn span,
    .sidebar.slim:not(.expanded) .thread-title,
    .sidebar.slim:not(.expanded) .thread-actions,
    .sidebar.slim:not(.expanded) .user-info,
    .sidebar.slim:not(.expanded) .user-profile>button {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Reset sidebar header layout on mobile */
    .sidebar.slim:not(.expanded) .sidebar-header {
        padding: 24px;
        justify-content: space-between;
    }

    .sidebar.slim:not(.expanded) .brand-toggle-wrapper {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
    }

    .sidebar.slim:not(.expanded) .brand {
        flex-direction: row;
        gap: 12px;
    }

    /* Reset button and item sizes on mobile */
    .sidebar.slim:not(.expanded) .new-chat-btn {
        width: 100%;
        height: 50px;
        margin: 0 0 24px 0;
        padding: 0 16px;
        justify-content: center;
    }

    .sidebar.slim:not(.expanded) .thread-item {
        width: 100%;
        height: auto;
        padding: 12px 16px;
        margin: 0 0 8px 0;
        justify-content: space-between;
    }

    .sidebar.slim:not(.expanded) .sidebar-nav {
        padding: 0 16px;
    }

    .sidebar.slim:not(.expanded) .user-profile {
        justify-content: flex-start;
    }

    .sidebar-toggle-btn {
        display: none;
        /* Hide desktop toggle on mobile */
    }

    .message-row {
        max-width: 95%;
    }

    .welcome-title {
        font-size: 28px;
    }
}

/* --- Sleek AI Typing Animation (Dots Only) --- */
.typing-indicator-bubble {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 12px 20px !important;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    border-radius: 18px !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.18) !important;
    animation: typingPulse 2s infinite ease-in-out;
    min-height: 40px;
}

/* Light Theme Typing Bubble Overrides */
[data-theme="light"] .typing-indicator-bubble {
    background: rgba(243, 244, 246, 0.95) !important;
    border: 1px solid rgba(99, 102, 241, 0.25) !important;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12) !important;
}

@keyframes typingPulse {
    0%, 100% {
        border-color: rgba(59, 130, 246, 0.35);
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.18);
    }
    50% {
        border-color: rgba(6, 182, 212, 0.65);
        box-shadow: 0 6px 28px rgba(6, 182, 212, 0.35);
    }
}

.typing-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 18px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #38bdf8);
    display: inline-block;
    animation: waveBounce 1.4s infinite ease-in-out both;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.7);
}

/* Light Theme Typing Dots Overrides */
[data-theme="light"] .typing-dots .dot {
    background: linear-gradient(135deg, #4f46e5, #2563eb) !important;
    box-shadow: 0 0 6px rgba(79, 70, 229, 0.4) !important;
}

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

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

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

@keyframes waveBounce {
    0%, 80%, 100% {
        transform: scale(0.6) translateY(0);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.3) translateY(-6px);
        opacity: 1;
        box-shadow: 0 0 12px rgba(56, 189, 248, 0.95);
    }
}