/* SIDIKTI Index.php (Chat) Specific Styles */

/* Global Thin Scrollbar Styling - Ultra-thin 2px scrollbars for all elements */
/* For Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 2px;
    height: 2px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color, #dee2e6);
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted, #6c757d);
}

/* For Firefox */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color, #dee2e6) var(--bg-secondary, #f8f9fa);
}

/* Additional thin scrollbar styling for all elements */
* {
    scrollbar-width: thin; /* Firefox */
}

/* Base HTML and Body styling for sticky positioning */
html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--bg-primary);
    margin: 0;
    padding: 0;
}

a {
    text-decoration: none;
}

.small, small {
  font-size: 1rem;
}

/* Layout Utilities */
.min-h-screen {
    min-height: 100vh;
}

/* Navbar height reduction */
.navbar {
    min-height: 46px !important;
    height: 46px;
}

/* Navbar sticky positioning - extends under sidebar */
.navbar.sticky-top {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 1000; /* Lower than sidebar (1020) so sidebar appears above */
    background: var(--bg-primary);
    /* Extend full width so it goes under sidebar */
    width: 100%;
    left: 0;
    right: 0;
}

/* Remove border on brand logo hover */
.navbar-brand:hover,
.navbar-brand:focus,
.navbar-brand:active,
.navbar-brand:focus-visible {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Also apply to button version of brand logo */
button.navbar-brand:hover,
button.navbar-brand:focus,
button.navbar-brand:active,
button.navbar-brand:focus-visible {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
}

/* Brand Logo - No Border Class */
.brand-logo,
.brand-logo:hover,
.brand-logo:focus,
.brand-logo:active,
.brand-logo:focus-visible,
.brand-logo:visited {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
    text-decoration: none !important;
}

/* Apply to button version of brand logo with higher specificity */
button.btn.brand-logo,
button.btn.brand-logo:hover,
button.btn.brand-logo:focus,
button.btn.brand-logo:active,
button.btn.brand-logo:focus-visible,
button.btn.brand-logo:focus-within {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
    text-decoration: none !important;
}

/* Even more specific for navbar brand buttons */
.navbar-brand.brand-logo,
.navbar-brand.brand-logo:hover,
.navbar-brand.brand-logo:focus,
.navbar-brand.brand-logo:active,
.navbar-brand.brand-logo:focus-visible {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
    text-decoration: none !important;
}

/* Most specific: button + btn + navbar-brand + brand-logo */
button.btn.navbar-brand.brand-logo,
button.btn.navbar-brand.brand-logo:hover,
button.btn.navbar-brand.brand-logo:focus,
button.btn.navbar-brand.brand-logo:active,
button.btn.navbar-brand.brand-logo:focus-visible {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
    text-decoration: none !important;
}

/* Header Button Styling */
.header-btn {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.header-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Language switcher button specific styling */
#languageDropdown {
    min-width: 48px;
    text-align: center;
}

#languageDropdown span {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Ensure language and theme dropdown menus appear above sidebar */
#languageDropdown + .dropdown-menu,
.theme-dropdown .dropdown-menu,
.navbar .dropdown-menu {
    z-index: 1060; /* Higher than right sidebar (1040) */
}

/* Force all Bootstrap dropdowns to appear above sidebar */
.dropdown-menu.show {
    z-index: 1060;
}

/* Sidebar transparent outline buttons */
.sidebar .btn-outline-secondary {
    border-color: transparent;
    color: var(--text-muted);
    background: transparent;
}

.sidebar .btn-outline-secondary:hover {
    background-color: var(--bg-hover);
    border-color: transparent;
    color: var(--text-primary);
}

.sidebar .btn-outline-secondary.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Active Features Styling */
.activeFeatures-desktop {
    flex-wrap: wrap;
    max-width: 500px;
}

.activeFeatures-mobile {
    display: none;
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Desktop shows above 540px, Mobile shows below 540px */
@media (min-width: 541px) {
    .activeFeatures-desktop {
        display: flex !important;
    }
    
    .activeFeatures-mobile {
        display: none !important;
    }
}

@media (max-width: 540px) {
    .activeFeatures-desktop {
        display: none !important;
    }
    
    .activeFeatures-mobile {
        display: block !important;
    }
}

/* Text Utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Popover Styles - Theme Aware */
.popover-overlay,
.custom-popover-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 1055;
    display: none;
}

.custom-popover {
    position: fixed;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1056;
    max-width: 250px;
    padding: 12px 0;
}

[data-theme="dark"] .custom-popover {
    background-color: #2d2d2d;
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="warm"] .custom-popover {
    background-color: #3d2f20;
    border-color: #5a4332;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.popover-item {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

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

.popover-item i {
    width: 16px;
    margin-right: 8px;
}

/* Logo Styles */
.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-img {
    height: 32px;
    width: auto;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0;
}

/* Avatar Styles */
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.user-avatar:hover {
    border-color: var(--primary-color);
}

/* Enhanced Dropdown Styles */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: var(--bg-primary);
    margin-top: 8px;
    z-index: 1060; /* Higher than right sidebar (1040) */
}

[data-theme="dark"] .dropdown-menu {
    background-color: #2d2d2d;
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="warm"] .dropdown-menu {
    background-color: #3d2f20;
    border-color: #5a4332;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dropdown-item {
    color: var(--text-primary);
    padding: 8px 16px;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin: 2px 4px;
}

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

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

.dropdown-item i {
    width: 16px;
    margin-right: 8px;
    text-align: center;
}

/* Chat Actions Dropdown Styles */
.chat-session .dropdown-toggle {
    border: none;
    background: transparent !important;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    color: inherit;
}

.chat-session .dropdown-toggle:hover,
.chat-session .dropdown-toggle:focus,
.chat-session .dropdown-toggle:active,
.chat-session .dropdown-toggle.show {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    box-shadow: none !important;
    color: inherit;
}

.chat-session .dropdown-toggle::after {
    display: none;
}

.chat-session .dropdown-menu {
    min-width: 160px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1050;
}

.chat-session .dropdown-item {
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 4px;
    margin: 2px 4px;
    transition: all 0.2s ease;
}

.chat-session .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.chat-session .dropdown-item.text-danger:hover {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

/* Prevent dropdown from closing the sidebar */
.chat-session .dropdown-menu {
    position: absolute;
    left: auto;
    right: 0;
}

@media (max-width: 768px) {
    .chat-session .dropdown-menu {
        position: fixed;
        right: 10px;
        left: auto;
        transform: none;
    }
}

/* Modal Chat Actions Styles */
.chat-actions-modal .chat-action-trigger {
    border: none;
    background: transparent;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    color: inherit;
    text-decoration: none;
}

.chat-actions-modal .chat-action-trigger:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
}

.modal-chat-actions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1055;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.modal-chat-actions-menu {
    position: fixed;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 150px;
    z-index: 1056;
}

[data-theme="dark"] .modal-chat-actions-menu {
    background: #2d3748;
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

[data-theme="warm"] .modal-chat-actions-menu {
    background: #2d1810;
    border-color: rgba(245, 230, 211, 0.2);
    color: #f5e6d3;
}

.modal-chat-actions-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.9rem;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.modal-chat-actions-item:hover {
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: inherit;
}

[data-theme="dark"] .modal-chat-actions-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="warm"] .modal-chat-actions-item:hover {
    background: rgba(245, 230, 211, 0.1);
}

.modal-chat-actions-item.text-danger {
    color: #dc3545;
}

.modal-chat-actions-item.text-danger:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.modal-chat-actions-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 4px 0;
}

/* URL Link Styles for Groq Response Messages */
.url-link {
    color: #0066cc;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
    word-break: break-word;
    display: inline;
}

.url-link:hover {
    color: #0052a3;
    text-decoration: underline;
    text-decoration-color: #0052a3;
}

.url-link:visited {
    color: #5B2C87;
}

/* Dark theme URL link styles */
[data-theme="dark"] .url-link {
    color: #4da6ff;
}

[data-theme="dark"] .url-link:hover {
    color: #66b3ff;
    text-decoration-color: #66b3ff;
}

[data-theme="dark"] .url-link:visited {
    color: #b366d9;
}

/* Warm theme URL link styles */
[data-theme="warm"] .url-link {
    color: #8BB8E8;
}

[data-theme="warm"] .url-link:hover {
    color: #a8c8ee;
    text-decoration-color: #a8c8ee;
}

[data-theme="warm"] .url-link:visited {
    color: #d4a574;
}

/* Ensure URLs in typewriter containers are properly styled */
.typewriter-container .url-link {
    color: inherit;
    animation: none;
}

[data-theme="dark"] .modal-chat-actions-divider {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="warm"] .modal-chat-actions-divider {
    background: rgba(245, 230, 211, 0.2);
}

/* Logo Sidebar Toggle Styles */
#logoSidebarToggle,
#sidebarLogoToggle {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

#logoSidebarToggle:hover,
#logoSidebarToggle:focus,
#logoSidebarToggle:active,
#sidebarLogoToggle:hover,
#sidebarLogoToggle:focus,
#sidebarLogoToggle:active {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    transform: none !important;
}

/* Sidebar Brand Header Styles */
.sidebar-brand-header {
    background-color: var(--bg-primary);
    position: relative;
}

.sidebar-brand-header .btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.sidebar-brand-header .btn:hover,
.sidebar-brand-header .btn:focus,
.sidebar-brand-header .btn:active {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    transform: none !important;
}

/* Remove underline from sidebar brand name */
.sidebar-brand-header .btn,
.sidebar-brand-header .btn:hover,
.sidebar-brand-header .btn:focus,
.sidebar-brand-header .btn:active {
    text-decoration: none !important;
}

.sidebar-brand-header h1 {
    text-decoration: none !important;
}

/* Chat Interface Styles */

/* Theme-aware User Status Modal */
.modal-content {
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
}

.modal-header {
    background-color: var(--bg-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 12px 12px 0 0 !important;
    padding: 1.5rem !important;
}

.modal-body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    padding: 1.5rem !important;
}

.modal-footer {
    background-color: var(--bg-primary) !important;
    border-top: 1px solid var(--border-color) !important;
    border-radius: 0 0 12px 12px !important;
    padding: 1.5rem !important;
}

/* User Status Modal Specific Styles */
#userStatusModal .modal-dialog-end {
    position: fixed;
    top: 46px;
    right: 20px;
    margin: 0;
    max-width: 400px;
    width: 100%;
    max-height: calc(100vh - 66px);
}

/* Mobile responsive positioning for user status modal */
@media (max-width: 768px) {
    #userStatusModal .modal-dialog-end {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        margin: 0;
        max-width: 90vw;
        width: 90vw;
        max-height: 80vh;
    }
}

#userStatusModal .modal-content {
    height: auto;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}

#userStatusModal .user-avatar {
    border: 2px solid var(--border-color) !important;
}

#userStatusModal .border-top {
    border-color: var(--border-color) !important;
}

/* User avatar placeholder styles */
#userStatusModal .avatar-placeholder {
    width: 60px;
    height: 60px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
}

#userStatusModal .avatar-placeholder i {
    font-size: 24px;
    color: var(--text-muted);
}

/* User preferences section styling */
#userStatusModal .mb-4 h6 {
    color: var(--text-primary) !important;
}

#userStatusModal .fw-bold {
    color: var(--text-primary) !important;
}

#userStatusModal .text-muted {
    color: var(--text-secondary) !important;
}

/* Theme-aware Form Controls in Modal */
.modal .form-control {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    padding: 0.75rem !important;
    transition: all 0.2s ease !important;
}

.modal .form-control:focus {
    background-color: var(--bg-secondary) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-color-rgb), 0.25) !important;
    color: var(--text-primary) !important;
    outline: none !important;
}

.modal .form-control::placeholder {
    color: var(--text-muted) !important;
}

.modal .form-label {
    color: var(--text-primary) !important;
    font-weight: 500 !important;
    margin-bottom: 0.5rem !important;
}

.modal .form-label i {
    color: var(--primary-color) !important;
}

.modal small.text-muted {
    color: var(--text-secondary) !important;
    font-size: 0.875rem !important;
}

/* Theme-aware Dropdown Menus */
.dropdown-menu {
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="warm"] .dropdown-menu {
    background-color: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.dropdown-item {
    color: var(--text-primary) !important;
    background: transparent !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Control Button Popovers - Remove Headers */
.popover-header {
    display: none !important;
}

/* Specifically target popovers from control buttons */
.control-btn + .popover .popover-header,
#settingsButton + .popover .popover-header,
button[onclick*="showProposalOptions"] + .popover .popover-header,
button[onclick*="showProposal2Options"] + .popover .popover-header,
button[onclick*="showAIModelOptions"] + .popover .popover-header {
    display: none !important;
}

/* More specific targeting for textarea control area popovers */
.textarea-controls-container .popover .popover-header,
.textarea-controls-container button + .popover .popover-header {
    display: none !important;
}

/* Style popover body to remove header spacing */
.control-btn + .popover .popover-body,
#settingsButton + .popover .popover-body,
button[onclick*="showProposalOptions"] + .popover .popover-body,
button[onclick*="showProposal2Options"] + .popover .popover-body,
button[onclick*="showAIModelOptions"] + .popover .popover-body,
.textarea-controls-container .popover .popover-body {
    padding-top: 0.75rem !important;
}

/* AI Model Popover Specific Styles */
.ai-model-popover-content {
    min-width: 200px;
    max-width: 250px;
    width: 100%;
}

.ai-model-popover-content .small {
    font-size: 1rem !important;
}

.ai-model-popover-content .form-label {
    font-size: 1rem !important;
    font-weight: 500;
    white-space: nowrap;
}

.ai-model-popover-content .form-check-input {
    width: 2rem;
    height: 1rem;
    margin-left: 0.5rem;
}

.ai-model-popover-content .d-flex {
    gap: 0.5rem;
    align-items: center;
}

.ai-model-popover-content .form-check.form-switch {
    margin-bottom: -10px;
    padding-left: 0;
}

.ai-model-popover-content .form-check-input {
    margin-top: 0;
    margin-left: 0;
}

/* Align settings popover content similarly */
.settings-popover-content .d-flex {
    gap: 0.5rem;
    align-items: center;
}

.settings-popover-content .form-check.form-switch {
    margin-bottom: -12px;
    padding-left: 0;
}

.settings-popover-content .form-check-input {
    margin-top: 0;
    margin-left: 0;
}

.ai-model-popover-content .mb-2 {
    margin-bottom: 0.75rem !important;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .ai-model-popover-content {
        min-width: 180px;
        max-width: 200px;
    }
    
    .ai-model-popover-content .form-label {
        font-size: 0.9rem !important;
    }
    
    .ai-model-popover-content .form-check-input {
        width: 1.8rem;
        height: 0.9rem;
    }
}

/* Ensure popover doesn't overflow on small screens */
button[onclick*="showAIModelOptions"] + .popover {
    max-width: 250px !important;
}

@media (max-width: 768px) {
    button[onclick*="showAIModelOptions"] + .popover {
        max-width: 200px !important;
    }
}

/* Theme-aware Quick Action Grid */
.quick-action-btn {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    transition: all 0.2s ease !important;
}

.quick-action-btn:hover {
    background-color: var(--bg-hover) !important;
    border-color: var(--primary-color) !important;
    color: var(--text-primary) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* Theme-aware Popover */
.popover {
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.popover-header {
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.popover-body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Theme-aware Settings Popover Content */
.settings-popover-content .form-label {
    color: var(--text-primary) !important;
}

.settings-popover-content .form-check-input {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.settings-popover-content .form-check-input:checked {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* Theme-aware Message Assistant */
.message-assistant {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.message-assistant .card {
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.message-assistant .card-body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Centered Scroll to Bottom Button and Thinking Animation */
.scroll-to-bottom-container {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 170px;
    z-index: 1000;
}

.scroll-to-bottom-btn {
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    font-size: 18px;
}

.scroll-to-bottom-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Responsive centering based on main content area */
@media (min-width: 1200px) {
    .scroll-to-bottom-container,
    .thinking-animation {
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (max-width: 1199px) and (min-width: 992px) {
    .scroll-to-bottom-container,
    .thinking-animation {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Sidebar behavior adjustments for smaller screens */
@media (max-width: 1000px) {
    .left-sidebar-col {
        z-index: 1050; /* Higher z-index for smaller screens */
    }
    
    .right-sidebar-col {
        z-index: 1050; /* Higher z-index for smaller screens */
    }
    
    .main-col {
        width: 100%;
        margin-left: 0;
    }
    
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-backdrop.show {
        display: block;
    }
}

@media (max-width: 991px) {
    .scroll-to-bottom-container,
    .thinking-animation {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Responsive Layout Structure */
.layout-row {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.left-sidebar-col {
    /* Desktop: Overlay positioning */
    position: fixed;
    top: 46px; /* Below header */
    left: 0;
    width: 300px;
    height: calc(100vh - 46px);
    z-index: 1040;
    background: var(--bg-secondary);
    box-shadow: 2px 0 10px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.left-sidebar-col.open {
    transform: translateX(0);
}

.main-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Independent Chat Main Area Styling */
.chat-main-area {
    /* Desktop: Dynamic width with overlay sidebars */
    width: calc(100% - 650px); /* 100% - (300px left + 350px right) */
    max-width: none;
    margin-left: 300px !important;
    margin-right: 350px !important;
    
    /* Layout properties */
    overflow: hidden; /* Prevent scrolling on container */
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    background: var(--bg-primary); /* Use CSS variable for theme consistency */
    /* Removed border-radius and box-shadow for seamless blend with background */
    /* Removed fixed height - use flex instead */
    min-height: calc(100vh - 100px); /* Minimum height for navbar */
    margin-bottom: 20px;
}

/* Mobile responsive adjustments for chat-main-area */
@media (max-width: 1000px) {
    .chat-main-area {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0;
        box-shadow: none;
        height: calc(100vh - 120px); /* Account for navbar and fixed input on mobile */
        margin-top: 0;
        margin-bottom: 0;
    }
}

/* Hide the old grid-based chat content column when using independent layout */
.content-row .chat-content-col {
    display: none !important;
}

.navbar-row {
    flex-shrink: 0;
}

.content-row {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.chat-content-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Center content when sidebars are closed */
    margin: 0 auto;
    max-width: 100%;
}

/* Legacy chat-content-col rules (kept for fallback) */
.sidebar-closed .chat-content-col {
    max-width: 800px; /* Limit width for better readability */
    margin: 0 auto;
}

/* Responsive behavior for sidebar states */
@media (max-width: 768px) {
    .chat-content-col {
        max-width: 100%;
        margin: 0;
    }
}

/* Mobile responsive adjustments - removed 765px restrictions */
@media (max-width: 765px) {
    /* User status modal and right sidebar now allowed on mobile */
}

.right-sidebar-col {
    /* Desktop: Overlay positioning */
    position: fixed;
    top: 46px; /* Below header */
    right: 0;
    width: 350px;
    height: calc(100vh - 46px);
    z-index: 1040;
    background: var(--bg-secondary);
    box-shadow: -2px 0 10px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.right-sidebar-col.open {
    transform: translateX(0);
}

@media (max-width: 992px) {
    .layout-row {
        flex-direction: column;
    }
    
    /* Left and right sidebars handled by 1000px floating overlay rules above */
    
    .main-col {
        order: 1;
        height: 100vh;
        width: 100%;
    }
    
    .content-row {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .left-sidebar-col,
    .right-sidebar-col {
        top: 0; /* Full height on mobile */
        height: 100vh;
    }
    
    .layout-row {
        flex-direction: column;
    }
    
    .main-col {
        width: 100%;
        height: 100vh;
    }
    
    /* Mobile navbar adjustments */
    .main-navbar .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* activeFeatures responsive behavior handled at 540px breakpoint */
}

/* Left Sidebar Styles */
.left-sidebar {
    height: 100%;
    overflow-y: auto; /* Allow scrolling in left sidebar */
    overflow-x: hidden;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

/* Custom scrollbar for left sidebar */
.left-sidebar::-webkit-scrollbar {
    width: 2px;
}

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

.left-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

.left-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Right Sidebar Styles */
.right-sidebar {
    height: 100vh; /* Full viewport height */
    overflow: hidden; /* Prevent parent from scrolling */
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Ensure right sidebar content is visible when opened */
.right-sidebar-col.open .right-sidebar {
    overflow: visible;
}

/* Navbar Styles */
.main-navbar {
    background-color: var(--bg-primary) !important;
    border-bottom: none !important;
    position: sticky;
    top: 0;
    z-index: 1050; /* Higher than right sidebar (1040) to ensure dropdowns appear above it */
}

/* Navbar icon-only buttons with no borders */
.main-navbar .header-btn,
.main-navbar .btn {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.main-navbar .header-btn:hover,
.main-navbar .btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
    transform: none !important;
    box-shadow: none !important;
}

.main-navbar .header-btn:focus,
.main-navbar .btn:focus,
.main-navbar .header-btn:active,
.main-navbar .btn:active {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Make sure brand logo buttons have no borders */
.main-navbar .brand-logo {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.main-navbar .brand-logo:hover,
.main-navbar .brand-logo:focus,
.main-navbar .brand-logo:active {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Navbar Brand Visibility - Show by default */
.navbar-brand-controls {
    display: flex !important; /* Show by default instead of hiding */
    align-items: center;
}

/* Mobile Active Features - Theme Aware */
.activeFeatures-mobile {
    display: none !important;
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* activeFeatures responsive behavior handled at 540px breakpoint above */

/* Chat Area Styles */
.chat-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-primary);
}

/* Scrollable Content */
.scrollable-content {
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Sidebar Content - Allow scrolling for chat sessions */
.left-sidebar .scrollable-content {
    overflow-y: auto; /* Allow vertical scrolling for chat sessions */
    overflow-x: hidden;
}

/* Reference Results Container - Direct approach for scrolling */
.reference-results-container {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* Show scrollbar for debugging */
    scrollbar-width: thin !important;
    scrollbar-color: #dee2e6 #f8f9fa !important;
}

/* Webkit scrollbar styling for reference container */
.reference-results-container::-webkit-scrollbar {
    width: 8px !important;
}

.reference-results-container::-webkit-scrollbar-track {
    background: #f8f9fa !important;
}

.reference-results-container::-webkit-scrollbar-thumb {
    background: #dee2e6 !important;
    border-radius: 4px !important;
}

.reference-results-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd !important;
}

/* Reference Results List - Remove conflicting styles */
.reference-results-list {
    /* Remove all flex and height constraints */
    display: block !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    overflow: visible !important;
}

#referenceSearchResults::-webkit-scrollbar {
    display: none; /* Webkit browsers */
}

/* Reference Search Card - Full height setup */
.right-sidebar .card.h-100 {
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.right-sidebar .card.h-100 .card-body {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Additional Theme Adaptations */
.card {
    background-color: var(--bg-primary) !important;
    /* border: 1px solid var(--border-color) !important; */
    color: var(--text-primary) !important;
}

.card-header {
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.card-body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

.border {
    border-color: var(--border-color) !important;
}

.border-top {
    border-top-color: var(--border-color) !important;
}

.border-bottom {
    border-bottom-color: var(--border-color) !important;
}

.border-start {
    border-left-color: var(--border-color) !important;
}

.border-end {
    border-right-color: var(--border-color) !important;
}

/* Theme-aware Text Colors */
.text-muted {
    color: var(--text-muted) !important;
}

/* Theme-aware Buttons */
.btn-close {
    filter: var(--bs-btn-close-white-filter, none);
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="warm"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
.chat-container {
    min-height: calc(100vh - 76px);
    overflow-y: auto;
}

/* Messages Area Wrapper - Flex container that grows */
.messages-area-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 860px;
    flex: 1; /* Take all available space */
    overflow-y: auto;
    padding: 0 0 65px 0; /* Add padding for better centering */
}

/* When sidebars are closed, limit message area width */
.sidebar-closed .messages-area-wrapper .messages-area {
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

/* Messages Area - Constrained width inside wrapper */
.messages-area {
    background-color: transparent;
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    flex: 1; /* Fill the wrapper height */
    display: flex;
    flex-direction: column;
    padding-bottom: 200px; /* Add padding to prevent overlap with fixed input area */
}

/* Desktop: 80% width for messages area */
@media (min-width: 768px) {
    .messages-area {
        width: 100%;
        max-width: 860px;
    }
}

/* Mobile: Full width for messages area */
@media (max-width: 767px) {
    .messages-area {
        width: 100%;
        max-width: 860px;
    }
}

/* Message Styles */
.message {
    margin-bottom: 6rem;
    position: relative;
}

.message.user {
    text-align: right;
}

.message.assistant {
    text-align: left;
}

.message-content {
    display: inline-block;
    max-width: 100%;
    padding: 6px 8px 0px 8px;
    border-radius: 18px;
    word-wrap: break-word;
}

.message.user .message-content {
    background-color: #62BBFA;
    color: white;
    border-bottom-right-radius: 6px;
    max-width: 80%; /* Keep user messages more compact */
}

.message.assistant .message-content {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    max-width: 100%; /* Allow assistant messages to take up more space */
    width: auto;
    display: block; /* Change to block to take full available width */
}

/* Analysis Message Styling */
.message.analysis-message .message-content {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border: 1px solid var(--primary-color);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.analysis-header {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 12px;
    margin: -12px -16px 12px -16px;
    border-radius: 14px 14px 8px 8px;
    font-size: 0.9rem;
}

.analysis-header .badge {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

/* AI Response List Styling - Minimal spacing without br tags */
.ai-response-list {
    margin: 0.5rem 0;
    padding-left: 1.2rem;
    list-style: none;
}

.ai-list-item {
    margin: 0.25rem 0;
    padding: 0;
    position: relative;
    line-height: 1.4;
}

.ai-list-item::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: -1rem;
    top: 0;
}

/* Nested list items with different indentation */
.ai-list-item[data-level="2"] {
    margin-left: 1rem;
}

.ai-list-item[data-level="2"]::before {
    content: "◦";
}

.ai-list-item[data-level="3"] {
    margin-left: 2rem;
}

.ai-list-item[data-level="3"]::before {
    content: "▪";
}

/* Ensure no extra spacing around lists */
.ai-response-list + p,
p + .ai-response-list {
    margin-top: 0.5rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Ideation Mode Tabbed Interface Styles */
.ideation-tabs-container {
    width: 100%;
}

.ideation-tabs-header {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
}

.ideation-tab-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ideation-tab-btn:hover:not(:disabled) {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.ideation-tab-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-bottom: 2px solid var(--primary-color);
}

.ideation-tab-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background-color: var(--bg-tertiary, #f1f3f4);
}

.ideation-tab-btn:disabled .processing-indicator {
    display: inline-block !important;
}

.processing-indicator {
    color: var(--primary-color);
    font-size: 0.9em;
}

.ideation-tabs-content {
    position: relative;
    min-height: 200px;
}

.ideation-tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.ideation-tab-pane.active {
    display: block;
}

.tab-loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: var(--text-muted);
}

.tab-loading-placeholder .spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .ideation-tabs-header {
        flex-direction: column;
    }
    
    .ideation-tab-btn {
        border-radius: 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .ideation-tab-btn:last-child {
        border-bottom: none;
    }
    
    .ideation-tab-btn.active {
        border-bottom: 2px solid var(--primary-color);
    }
}

/* Animation for tab switching */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* LaTeX/MathJax Equation Styles */
.math-display, .math-inline {
    font-family: "Computer Modern", "Times", serif;
    color: var(--text-primary);
}

.math-display {
    display: block;
    text-align: center;
    margin: 15px 0;
    overflow-x: auto;
    /* Removed background, border, and padding to prevent double-card effect */
}

.math-inline {
    display: inline;
    vertical-align: middle;
    /* Removed background and padding for cleaner inline appearance */
}

/* Legacy support for old class names */
.math-equation {
    font-family: "Computer Modern", "Times", serif;
    color: var(--text-primary);
}

.math-equation.math-display {
    display: block;
    text-align: center;
    margin: 15px 0;
    overflow-x: auto;
    /* Removed background, border, and padding to prevent double-card effect */
}

.math-equation.math-inline {
    display: inline;
    vertical-align: middle;
    /* Removed background and padding for cleaner inline appearance */
}

/* MathJax output styling */
.MathJax {
    color: var(--text-primary) !important;
}

.MathJax_Display {
    margin: 10px 0 !important;
}

/* Dark theme adjustments for equations */
[data-bs-theme="dark"] .math-equation {
    background: var(--bs-dark, #212529);
    border-color: var(--bs-secondary, #6c757d);
    color: var(--bs-light, #f8f9fa);
}

[data-bs-theme="dark"] .MathJax {
    color: var(--bs-light, #f8f9fa) !important;
}

/* Warm theme adjustments for equations */
[data-bs-theme="warm"] .math-equation {
    background: #3d251a;
    border-color: #5d3428;
    color: #f5e6d3;
}

[data-bs-theme="warm"] .MathJax {
    color: #f5e6d3 !important;
}

/* Markdown Table Styles - Fully responsive with word wrapping */
.markdown-table-container {
    margin: 15px 0;
    overflow-x: auto;
    border-radius: 8px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Enable smooth horizontal scrolling on mobile */
    -webkit-overflow-scrolling: touch;
}

.markdown-table {
    width: 100%;
    margin-bottom: 0;
    font-size: 0.9rem;
    border-collapse: collapse;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    /* Ensure table doesn't exceed container */
    max-width: 100%;
    table-layout: auto;
}

.markdown-table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 12px 8px;
    text-align: left;
    border: none;
    /* Enable word wrapping in headers */
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    /* Set reasonable minimum width */
    min-width: 80px;
    max-width: 200px;
}

.markdown-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    line-height: 1.4;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    /* Enable word wrapping in cells */
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    /* Set reasonable maximum width to force wrapping */
    max-width: 200px;
    min-width: 60px;
}

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

.markdown-table tbody tr:hover td {
    background-color: var(--bg-secondary);
}

/* Enhanced responsive table adjustments */
@media (max-width: 992px) {
    .markdown-table {
        font-size: 0.85rem;
    }
    
    .markdown-table th,
    .markdown-table td {
        max-width: 150px;
        padding: 10px 6px;
    }
}

@media (max-width: 768px) {
    .markdown-table {
        font-size: 0.8rem;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 8px 6px;
        max-width: 120px;
        min-width: 50px;
    }
}

@media (max-width: 576px) {
    .markdown-table {
        font-size: 0.75rem;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 6px 4px;
        max-width: 100px;
        min-width: 40px;
        /* More aggressive word breaking on very small screens */
        word-break: break-all;
    }
    
    .markdown-table-container {
        margin: 10px 0;
        border-radius: 6px;
    }
}

.message-actions {
    display: none;
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.message:hover .message-actions {
    display: flex;
    gap: 2px;
}

/* Typewriter Stop Button Styles */
.typewriter-stop-btn {
    background: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    animation: pulse 1.5s infinite;
}

.typewriter-stop-btn:hover {
    background: #c82333 !important;
    border-color: #bd2130 !important;
    color: white !important;
}

.typewriter-stop-btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

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

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

/* Chat Input Area - Fixed at Bottom with Same Constraints as Main Area */
.chat-input-area {
    /* Desktop: Same positioning as chat-main-area but fixed at bottom */
    position: fixed;
    bottom: 2px;
    left: 0;
    right: 0;
    z-index: 1050;
    
    /* Same width constraints as chat-main-area */
    width: calc(100% - 650px); /* 100% - (300px left + 350px right) */
    max-width: none;
    margin-left: 300px !important;
    margin-right: 350px !important;
    
    /* Styling - reduced padding to match smaller input */
    background-color: var(--bg-primary);
    padding: 8px;
}

/* Mobile responsive adjustments for chat-input-area */
@media (max-width: 1000px) {
    .chat-input-area {
        width: 100%;
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        left: 10px;
        right: 10px;
        bottom: 2px;
        /* Removed border-radius and box-shadow for seamless blend */
    }
}

/* Main content area - flex container without bottom padding */
.main-content-area {
    position: relative;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* Removed padding-bottom since chat-input-area is now positioned independently */
}

/* Message Input Container - Dynamic width and height */
.message-input-container {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    min-height: 110px; /* Minimum height */
    max-height: 400px; /* Maximum height */
}

/* Message Input Wrapper - Dynamic height that grows upward */
.message-input-wrapper {
    position: relative;
    min-height: 110px; /* Minimum height */
    max-height: 400px; /* Maximum height to prevent taking too much space */
    display: flex;
    flex-direction: column;
}

/* Textarea Controls Container - Fixed at bottom of wrapper */
.textarea-controls-container {
    position: relative; /* Changed from absolute to relative */
    height: 42px; /* Fixed height for controls */
    padding: 0px 5px 4px 5px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none; /* Remove top border to connect with textarea */
    border-radius: 0 0 12px 12px;
    z-index: 10;
    pointer-events: none; /* Allow clicks to pass through container */
    flex-shrink: 0; /* Don't shrink when textarea grows */
}

.textarea-controls-container .row {
    pointer-events: auto; /* Re-enable clicks on actual controls */
}

/* Control buttons styling */
.control-btn, .new-btn, .file-upload-btn, .send-btn {
    pointer-events: auto;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.control-btn:hover, .new-btn:hover, .file-upload-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-color);
}

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

.send-btn:hover {
    background-color: var(--primary-color-hover);
    border-color: var(--primary-color-hover);
}

/* Token Counter styling */
.token-counter-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    padding: 4px 8px;
    font-size: 11px;
}

.token-counter-text {
    color: var(--text-muted);
    margin-right: 4px;
}

.token-counter-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 2px;
    font-size: 10px;
    cursor: pointer;
}

.token-counter-btn:hover {
    color: var(--primary-color);
}

#messageInput {
    flex: 1; /* Take available space but leave room for controls */
    height: 60px; /* Default height */
    min-height: 60px; /* Minimum height for text input */
    max-height: 300px; /* Allow expansion up to 300px */
    transition: height 0.2s ease; /* Smooth resize animation */
    resize: none; /* Disable manual resize, use auto-resize instead */
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0; /* Rounded top, straight bottom to connect with controls */
    font-size: 14px;
    line-height: 1.5;
    overflow-y: hidden; /* Hide scrollbar, auto-resize instead */
    border-bottom: none; /* Remove bottom border to connect with controls */
}

#messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-color-rgb), 0.25);
    outline: none;
}

/* File Preview Styles - for both regular chat and multi-query */
#filePreview.file-preview-inside-textarea,
[id^="filePreview"].file-preview-inside-textarea {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 120px; /* Space for control buttons */
    z-index: 15; /* Increased from 5 to 15 to ensure it's above other elements */
    max-height: 70px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    background: transparent;
    pointer-events: none; /* Changed from 'all' to 'none' to prevent blocking textarea clicks */
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0;
}

#filePreview.file-preview-inside-textarea .file-preview-item,
[id^="filePreview"].file-preview-inside-textarea .file-preview-item {
    margin: 2px;
    flex-shrink: 0;
    pointer-events: all; /* Re-enable pointer events for individual file items */
    z-index: 20; /* Ensure file items are above other elements */
    position: relative; /* Required for z-index to work */
}

#filePreview.file-preview-inside-textarea .file-thumbnail,
[id^="filePreview"].file-preview-inside-textarea .file-thumbnail {
    width: 60px !important;
    height: 60px !important;
    position: relative;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.2s ease;
    pointer-events: all; /* Ensure thumbnail is clickable */
    z-index: 20; /* Match parent z-index */
}

#filePreview.file-preview-inside-textarea .thumbnail-image,
[id^="filePreview"].file-preview-inside-textarea .thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#filePreview.file-preview-inside-textarea .file-icon,
[id^="filePreview"].file-preview-inside-textarea .file-icon {
    width: 100%;
    height: 60px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-color);
    background: var(--code-bg);
}

#filePreview.file-preview-inside-textarea .btn-remove-file,
[id^="filePreview"].file-preview-inside-textarea .btn-remove-file {
    position: absolute;
    top: 0px;
    right: 38px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25; /* Increased to ensure it's clickable */
    transition: all 0.2s ease;
    pointer-events: all; /* Explicitly enable pointer events */
}

#filePreview.file-preview-inside-textarea .btn-remove-file:hover,
[id^="filePreview"].file-preview-inside-textarea .btn-remove-file:hover {
    background: #c82333;
    transform: scale(1.1);
}

#filePreview.file-preview-inside-textarea .file-name,
[id^="filePreview"].file-preview-inside-textarea .file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 8px;
    padding: 2px 4px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.file-preview-item {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 60px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.file-preview-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 7px;
}

.file-preview-item .file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-muted);
    background-color: var(--bg-secondary);
}

.file-preview-item .remove-file {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--danger-color, #dc3545);
    color: white;
    border: none;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.file-preview-item .remove-file:hover {
    background-color: var(--danger-color-hover, #c82333);
}

.file-preview-item .file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 8px;
    padding: 2px 4px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Adjust textarea padding when file preview is visible */
.textarea-with-controls.has-files {
    padding-top: 75px !important;
}

/* Quick Action Buttons */
.quick-action-btn {
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    transition: all 0.2s ease;
    box-shadow: var(--shadow) 0 2px 4px !important;
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 8px 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    font-size: 0.85rem !important;
    gap: 8px !important;
}

.quick-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg) 0 4px 8px !important;
    background: var(--bg-tertiary) !important;
    border-color: var(--primary-color) !important;
}

.quick-action-btn:active {
    transform: translateY(0);
}

.quick-action-btn i {
    transition: color 0.2s ease;
    color: var(--text-secondary);
    font-size: 1rem !important;
    flex-shrink: 0;
}

.quick-action-btn:hover i {
    color: var(--primary-color);
    transform: scale(1.05);
}

.quick-action-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    font-size: 0.8rem !important;
}

/* Enhanced Beautiful Control Buttons */
.control-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    background: transparent !important;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    transform-origin: center;
    box-shadow: none !important;
    position: relative;
    overflow: hidden;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.control-btn:hover {
    background: transparent !important;
    border: none !important;
    color: var(--primary-color);
    transform: scale(1.1);
    box-shadow: none !important;
}

.control-btn:hover::before {
    left: 100%;
}

.control-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.control-btn.btn-primary {
    background: transparent !important;
    border: none !important;
    color: var(--primary-color);
    box-shadow: none !important;
}

.control-btn.btn-primary:hover {
    background: transparent !important;
    border: none !important;
    color: var(--primary-color);
    transform: scale(1.1);
    box-shadow: none !important;
}

.control-btn i {
    font-size: 16px;
    transition: all 0.3s ease;
}

.control-btn:hover i {
    transform: scale(1.1);
}

/* Category Toggle Buttons (including Auto Chart) */
.category-toggle {
    transition: all 0.2s ease;
    border-width: 1px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.category-toggle:hover {
    background-color: rgba(84, 163, 255, 0.1);
    border-color: #54a3ff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-toggle[aria-expanded="true"] {
    background-color: rgba(84, 163, 255, 0.1);
    border-color: #54a3ff !important;
}

.category-toggle[aria-expanded="true"] .fa-chevron-right {
    transform: rotate(90deg);
    transition: transform 0.2s ease;
}

/* Enhanced Beautiful New Button */
.new-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #005a9a 100%) !important;
    border: 1px solid var(--primary-color) !important;
    color: white !important;
    transition: all 0.3s ease;
    transform-origin: center;
    box-shadow: 
        0 4px 12px rgba(0, 112, 192, 0.4),
        0 2px 6px var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.new-btn i {
    font-size: 16px !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.new-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.new-btn:hover {
    background: linear-gradient(135deg, #005a9a 0%, #003d6b 100%) !important;
    border-color: #005a9a !important;
    transform: scale(1.1) translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(0, 112, 192, 0.5),
        0 4px 12px var(--shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.new-btn:hover::before {
    left: 100%;
}

.new-btn:active {
    transform: scale(1.05) translateY(-1px);
    transition: transform 0.1s ease;
}

/* File Upload Button - Icon Only Style */
.file-upload-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    border-radius: 12px;
    border: none !important;
    background: transparent !important;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    transform-origin: center;
    box-shadow: none !important;
    position: relative;
    overflow: hidden;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.file-upload-btn i {
    font-size: 16px !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    transition: all 0.3s ease;
}

.file-upload-btn:hover {
    background: transparent !important;
    border: none !important;
    color: var(--primary-color);
    transform: scale(1.1);
    box-shadow: none !important;
}

.file-upload-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Enhanced Beautiful Send Button */
.send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #005a9a 100%) !important;
    border: 1px solid var(--primary-color) !important;
    color: white !important;
    transition: all 0.3s ease;
    transform-origin: center;
    box-shadow: 
        0 4px 12px rgba(0, 112, 192, 0.4),
        0 2px 6px var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.send-btn i {
    font-size: 16px !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.send-btn:hover {
    background: linear-gradient(135deg, #005a9a 0%, #003d6b 100%) !important;
    border-color: #005a9a !important;
    transform: scale(1.1) translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(0, 112, 192, 0.5),
        0 4px 12px var(--shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.send-btn:hover::before {
    left: 100%;
}

.send-btn:active {
    transform: scale(1.05) translateY(-1px);
    transition: transform 0.1s ease;
}

/* Chat Sessions in Sidebar - No scrolling, users can manage via modal */

.chat-session {
    transition: all 0.2s ease;
    border-radius: 6px;
    margin-bottom: 4px;
}

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

.chat-session.active {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.chat-session.active .card {
    background-color: transparent;
    border-color: transparent;
}

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

/* Compact chat session styling */
.chat-session .card-body {
    padding: 0.5rem !important;
}

.chat-session .card-title {
    font-size: 0.75rem !important;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.chat-session .card-text {
    font-size: 0.65rem !important;
    line-height: 1.1;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    margin-bottom: 1rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

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

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

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

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

@keyframes typing-animation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Code Blocks in Messages */
.message-content pre {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.4;
}

.message-content code {
    background-color: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Horizontal dividers in AI responses */
.response-divider {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 20px 0;
    opacity: 0.6;
}

/* Reference Sources in Sidebar */
.reference-sources {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 16px;
}

.reference-item {
    padding: 8px 12px;
    margin-bottom: 8px;
    background-color: var(--bg-primary);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    transition: all 0.2s ease;
}

.reference-item:hover {
    background-color: var(--bg-hover);
    transform: translateX(2px);
}

.reference-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.reference-url {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}

/* Scholar Search Results */
.scholar-item {
    border-left: 3px solid #28a745;
    padding-left: 12px;
    margin-bottom: 16px;
    background-color: var(--bg-primary);
    border-radius: 0 8px 8px 0;
    padding: 12px;
}

.scholar-item:last-child {
    margin-bottom: 0;
}

.scholar-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.scholar-authors {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 4px;
}

.scholar-snippet {
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.scholar-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.scholar-metadata .badge {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Scholar Context in Main Chat */
.scholar-context-main-chat {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

[data-theme="dark"] .scholar-context-main-chat {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

.scholar-context-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.scholar-context-item {
    background-color: var(--bg-primary);
    border-left: 3px solid var(--primary-color, #0d6efd);
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 0 6px 6px 0;
    transition: all 0.2s ease;
}

.scholar-context-item:hover {
    background-color: var(--bg-hover, #f8f9fa);
    transform: translateX(2px);
}

[data-theme="dark"] .scholar-context-item {
    background-color: rgba(255, 255, 255, 0.02);
    border-left-color: var(--primary-color, #0d6efd);
}

[data-theme="dark"] .scholar-context-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.scholar-item-title a {
    color: var(--primary-color, #0d6efd);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.scholar-item-title a:hover {
    color: var(--primary-hover, #0a58ca);
    text-decoration: underline;
}

.scholar-item-authors {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.scholar-item-snippet {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
    margin-top: 6px;
}

.scholar-context-more {
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

/* Chat Menu Popover Styles */
.chat-menu-popover {
    position: absolute;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1056;
    min-width: 150px;
    padding: 8px 0;
}

[data-theme="dark"] .chat-menu-popover {
    background-color: #2d2d2d;
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="warm"] .chat-menu-popover {
    background-color: #3d2f20;
    border-color: #5a4332;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-menu-item {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

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

.chat-menu-item.danger:hover {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.chat-menu-item i {
    width: 16px;
    margin-right: 8px;
}

/* RAG Toast Styles */
.rag-toast {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1060;
    max-width: 300px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.rag-toast.show {
    opacity: 1;
    transform: translateY(0);
}

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

.rag-toast .toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.rag-toast .toast-close {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.rag-toast .toast-body {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Welcome Screen for Chat */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    text-align: center;
    padding: 40px 20px;
}

.chat-welcome h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 300;
}

.chat-welcome p {
    color: var(--text-muted);
    margin-bottom: 32px;
    max-width: 500px;
}

.chat-welcome .btn {
    margin: 8px;
}

/* Responsive Chat Styles */
@media (max-width: 768px) {
    .messages-area {
        padding: 12px;
        padding-bottom: 180px; /* Smaller padding on mobile */
    }
    
    .message-content {
        padding: 6px 8px 0px 8px;
    }
    
    .message.user .message-content {
        max-width: 85%;
    }
    
    .message.assistant .message-content {
        max-width: 100%;
    }
    
    .message-input-area {
        padding: 12px;
    }
    
    .message-input-container {
        max-width: 100%;
        min-height: 110px; /* Minimum height on mobile */
        max-height: none; /* Remove max height constraint to allow expansion */
        display: flex;
        flex-direction: column;
    }
    
    .message-input-wrapper {
        min-height: 110px; /* Same minimum height on mobile */
        max-height: none; /* Remove max height constraint */
        display: flex;
        flex-direction: column;
        position: relative;
    }
    
    #messageInput {
        flex: 1;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 5px; /* Reduced padding to match desktop */
        height: 60px; /* Default height */
        min-height: 60px; /* Fixed minimum height */
        max-height: 300px; /* Allow expansion up to 300px */
        border-radius: 12px 12px 0 0;
        border-bottom: none;
        resize: none; /* Disable manual resize on mobile */
        overflow-y: hidden; /* Auto-resize instead of scroll */
        transition: height 0.2s ease;
    }
    
    /* Fixed chat input area for mobile - Allow height to expand with input */
    .chat-input-area {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        height: auto !important; /* Allow height to expand */
        min-height: 90px !important; /* Reduced from 150px since input starts smaller */
        max-height: none !important; /* Remove max height constraint to allow expansion */
    }
    
    /* Mobile textarea controls positioning - relative to allow upward expansion */
    .textarea-controls-container {
        position: relative; /* Change from absolute positioning */
        height: 42px; /* Keep fixed height for controls */
        margin: 0; /* Add margin instead of left/right positioning */
        bottom: auto; /* Remove absolute positioning */
    }
    
    /* Ensure mobile input area has reduced padding */
    .message-input-area {
        padding: 8px;
        /* Allow the area to expand upward by removing height constraints */
        height: auto !important;
        min-height: auto !important;
    }
    
    /* Make sure the wrapper allows upward expansion */
    .message-input-wrapper {
        position: relative;
        display: flex;
        flex-direction: column;
        /* Remove any height constraints that prevent upward expansion */
    }
    
    /* Ensure parent container doesn't constrain height */
    .chat-input-area {
        /* Keep fixed positioning but allow content to expand upward */
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-end !important; /* Align to bottom, expand upward */
    }
    
    .control-btn, .new-btn, .file-upload-btn, .send-btn {
        font-size: 12px;
        padding: 4px 6px;
    }
    
    /* Typewriter effect styles */
.typewriter-cursor {
    display: inline-block;
    background-color: var(--text-primary);
    width: 2px;
    height: 1.2em;
    margin-left: 2px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.typewriter-container {
    position: relative;
}

/* Chat sessions list - scrollable */
    .chat-sessions-list {
        max-height: 400px; /* Limit height to make it scrollable */
        overflow-y: auto; /* Enable vertical scrolling */
        overflow-x: hidden; /* Hide horizontal scrolling */
        padding-right: 5px; /* Add padding for scrollbar */
    }
    
    /* Custom scrollbar for chat sessions */
    .chat-sessions-list::-webkit-scrollbar {
        width: 6px;
    }
    
    .chat-sessions-list::-webkit-scrollbar-track {
        background: var(--bg-secondary);
        border-radius: 3px;
    }
    
    .chat-sessions-list::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    
    .chat-sessions-list::-webkit-scrollbar-thumb:hover {
        background: var(--text-muted);
    }
    
    /* Removed chat-sessions-list max-height - no scrolling needed */
    
    .rag-toast {
        right: 12px;
        left: 12px;
        max-width: none;
        bottom: 80px;
    }
}

/* Code Block Enhancement Styles */
.code-header {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0.5rem 0.5rem 0 0;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    height: 40px;
    min-height: 40px;
}

.code-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

pre.code-block:hover .code-buttons {
    opacity: 1;
}

.code-language {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

pre.code-block .code-buttons .btn {
    background-color: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
    margin: 0 !important;
    height: 28px !important;
    min-height: 28px !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    min-width: 28px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    transform: none !important;
}

pre.code-block .code-buttons .btn:hover {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    transform: none !important;
    box-shadow: none !important;
}

pre.code-block .code-buttons .btn.btn-success {
    background-color: var(--success-color) !important;
    color: white !important;
}

/* Enhanced pre/code styling */
pre.code-block {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    margin: 1rem 0;
    position: relative;
    box-shadow: 0 2px 4px var(--shadow);
}

pre.code-block code {
    background: var(--bg-primary);
    border: none;
    padding: 1rem;
    color: var(--text-primary);
    display: block;
    overflow-x: auto;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
}

/* Mobile responsive adjustments for code blocks */
@media (max-width: 576px) {
    .code-header {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
        height: 36px;
        min-height: 36px;
    }
    
    .code-language {
        font-size: 0.7rem;
    }
    
    pre.code-block .code-buttons .btn {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.7rem !important;
        height: 24px !important;
        min-height: 24px !important;
        min-width: 24px !important;
    }
}

/* Code Preview Modal Styles */
#codePreviewModal .modal-dialog {
    max-width: 95vw;
}

#codePreviewModal .modal-body {
    padding: 0;
}

#codePreviewFrame {
    border: none;
    width: 100%;
    height: 600px;
    background: white;
}

/* Run button styling */
pre.code-block .code-buttons .btn.btn-success {
    background-color: var(--success-color) !important;
    color: white !important;
    border: 1px solid var(--success-color) !important;
}

pre.code-block .code-buttons .btn.btn-success:hover {
    background-color: #218838 !important;
    border-color: #1e7e34 !important;
}

/* Enhanced code block buttons spacing */
pre.code-block .code-buttons {
    gap: 0.25rem;
}

/* Preview modal responsive */
@media (max-width: 768px) {
    #codePreviewModal .modal-dialog {
        max-width: 98vw;
        margin: 0.5rem;
    }
    
    #codePreviewFrame {
        height: 400px;
    }
}

/* Code block preview during typewriter effect */
.code-block-preview {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    margin: 0.5rem 0;
    position: relative;
    box-shadow: 0 2px 4px var(--shadow);
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
}

.code-language-preview {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.code-content-preview {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Think Block Section Styling - Theme Aware (for <think> tags) */
.think-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 1rem;
    background-color: var(--bg-secondary);
    overflow: hidden;
    box-shadow: 0 2px 4px var(--shadow);
}

.think-header {
    background-color: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.think-header .think-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.think-header i.fa-brain {
    color: var(--primary-color);
}

.think-toggle {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.think-toggle:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.think-content {
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.think-text {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    opacity: 0.9; /* Slightly different from main content */
}

/* SIDIKTI Thinking Animation - Floating Animation */
.thinking-animation {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 200px;
    z-index: 1001;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    pointer-events: none;
    transition: all 0.3s ease;
}

.thinking-animation .thinking-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.thinking-animation .thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-animation .thinking-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: thinking-bounce 1.4s infinite ease-in-out;
}

.thinking-animation .thinking-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-animation .thinking-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.thinking-animation .thinking-text {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Enhanced In-Depth Review thinking animation styles */
.thinking-animation .in-depth-thinking {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thinking-animation .thinking-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-animation .progress-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
}

.thinking-animation .progress-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.thinking-animation .progress-bar {
    flex: 1;
    height: 8px;
    background-color: var(--background-secondary);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.thinking-animation .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 3px;
    transition: width 0.3s ease;
    animation: progress-pulse 2s ease-in-out infinite;
}

.thinking-animation .progress-percentage {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 35px;
    text-align: right;
}

.thinking-animation .current-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.thinking-animation .current-step i {
    color: #007bff;
}

.thinking-animation .step-counter {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.thinking-animation .thinking-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-primary);
}

.thinking-animation .thinking-warning i {
    color: #ffc107;
    font-size: 12px;
}

@keyframes progress-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes thinking-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* SIDIKTI Go To Result Button - Floating Action Button */
.typewriter-stop-animation {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 180px; /* Slightly higher than thinking animation */
    z-index: 1002; /* Higher than thinking animation */
    background: linear-gradient(135deg, #0070C0, #005A9E);
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 112, 192, 0.3);
    color: white;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: typewriter-stop-pulse 2s infinite;
    display: none; /* Hidden by default */
}

.typewriter-stop-animation:hover {
    background: linear-gradient(135deg, #005A9E, #004D85);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 112, 192, 0.4);
}

.typewriter-stop-animation .stop-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typewriter-stop-animation .stop-icon {
    font-size: 12px;
}

.typewriter-stop-animation .stop-text {
    font-size: 14px;
    font-weight: 500;
}

@keyframes typewriter-stop-pulse {
    0% { 
        transform: translateX(-50%) scale(1);
        box-shadow: 0 4px 12px rgba(0, 112, 192, 0.3);
    }
    50% { 
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 6px 16px rgba(0, 112, 192, 0.4);
    }
    100% { 
        transform: translateX(-50%) scale(1);
        box-shadow: 0 4px 12px rgba(0, 112, 192, 0.3);
    }
}

/* Responsive typewriter stop button positioning */
@media (max-width: 1000px) {
    .typewriter-stop-animation {
        bottom: 150px; /* Adjust for mobile */
    }
}

/* Ideation Mode Disabled Elements - Persistent State */
.ideation-disabled {
    opacity: 0.5 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    background-color: #f8f9fa !important;
    color: #6c757d !important;
}

/* Specific disabled state for form elements in ideation mode */
#sinceInput.ideation-disabled,
#styleSelect.ideation-disabled,
#reasoningToggle.ideation-disabled {
    opacity: 0.5 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
}

/* Disabled state for select elements */
select.ideation-disabled {
    background-image: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Disabled state for toggles and buttons */
.toggle.ideation-disabled,
.btn.ideation-disabled {
    opacity: 0.5 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    background-color: #e9ecef !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}

/* Presentation Slide Progress Overlay - Theme-aware styling */
.presentation-slide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.presentation-slide-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.presentation-slide-modal {
    position: relative;
    z-index: 10000;
    max-width: 500px;
    width: 90%;
    margin: 0 auto;
}

.presentation-slide-content {
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.presentation-slide-content .thinking-header {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.presentation-slide-content .thinking-dots span {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: thinking-bounce 1.4s infinite ease-in-out;
}

.presentation-slide-content .thinking-text {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

.presentation-slide-content .presentation-slide-icon {
    color: var(--primary-color);
    font-size: 18px;
    margin-left: 8px;
}

.presentation-slide-content .presentation-description {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

.presentation-slide-content .progress-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.presentation-slide-content .progress-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.presentation-slide-content .progress-bar {
    flex: 1;
    height: 10px;
    background-color: var(--background-secondary);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.presentation-slide-content .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-color-dark, #0056b3));
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: progress-pulse 2s ease-in-out infinite;
}

.presentation-slide-content .progress-percentage {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
    text-align: right;
}

.presentation-slide-content .current-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    justify-content: center;
}

.presentation-slide-content .current-step i {
    color: var(--primary-color);
}

.presentation-slide-content .step-counter {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    font-weight: 500;
}

.presentation-slide-content .stage-indicators {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.presentation-slide-content .stage-indicator {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    border-radius: 8px;
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.presentation-slide-content .stage-indicator.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.presentation-slide-content .stage-indicator:not(.active) {
    color: var(--text-muted);
}

.presentation-slide-content .stage-number {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.presentation-slide-content .stage-label {
    font-size: 11px;
    font-weight: 500;
}

.presentation-slide-content .thinking-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
}

.presentation-slide-content .thinking-warning i {
    color: #ffc107;
    font-size: 14px;
    flex-shrink: 0;
}

/* Dark theme adjustments for presentation overlay */
[data-theme="dark"] .presentation-slide-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .presentation-slide-content .thinking-warning {
    background-color: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.4);
}

/* Progress pulse animation */
@keyframes progress-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}
