/* ==========================================================================
   Third Mind AI Chat Application - Main Stylesheet
   ========================================================================== */

/* ==========================================================================
   CSS Variables & Root Styles
   ========================================================================== */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --border-color: #dee2e6;
    --chat-bg: #f8f9fa;
    --user-message-bg: var(--primary-color);
    --ai-message-bg: white;
    --sidebar-bg: #ffffff;
    --scrollbar-color: #c1c1c1;
    --scrollbar-hover-color: #a8a8a8;
}

/* ==========================================================================
   Base Styles & Typography
   ========================================================================== */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--chat-bg);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================================================
   Three-Row Layout: Header, Body, Footer
   ========================================================================== */

.app-header {
    flex-shrink: 0;
    background: white;
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.app-footer {
    flex-shrink: 0;
    background: #f8f9fa;
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
}

/* ==========================================================================
   Navigation & Header
   ========================================================================== */

.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

.navbar-brand i {
    margin-right: 0.5rem;
}

/* ==========================================================================
   Chat Layout - Two Column Body
   ========================================================================== */

.chat-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* First Column: Sidebar (30% of screen) */
.chat-sidebar {
    width: 30%;
    min-width: 300px;
    max-width: 400px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

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

.sidebar-search {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.sidebar-search .search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-search .search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.1);
}

.sidebar-search .search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 0.25rem;
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    font-weight: 500;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.conversation-item.active {
    background-color: rgba(13, 110, 253, 0.1);
    border-left-color: var(--primary-color);
}

.conversation-content {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.conversation-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--dark-color);
}

.conversation-meta {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

.conversation-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.conversation-edit-btn {
    color: var(--primary-color);
    padding: 0.25rem;
    transition: all 0.2s ease;
}

.conversation-edit-btn:hover {
    color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
    border-radius: 4px;
}

.conversation-delete-btn {
    color: var(--danger-color);
    padding: 0.25rem;
    transition: all 0.2s ease;
}

.conversation-delete-btn:hover {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
    border-radius: 4px;
}

.title-edit-input {
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    background: white;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.title-edit-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

/* Second Column: Main Chat Area (70% of screen) */
.chat-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    overflow: hidden;
    position: relative;
}

.model-selector {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: white;
}

.model-selector .form-select {
    max-width: 200px;
}

/* Conversation Container */
.conversation-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Messages Area - Centered with scrollbar */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--chat-bg);
}

/* Center the conversation content */
.chat-messages > * {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Input Area - Fixed at bottom */
.chat-input {
    flex-shrink: 0;
    background: white;
    padding: 1.5rem 2rem;
    position: relative;
    z-index: 10;
}

.message-input-container {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    max-width: 900px;
    margin: 0 auto;
}

.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-end;
}

.attachment-btn {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 10;
    background: none;
    border: none;
    color: var(--secondary-color);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    line-height: 1;
    min-width: auto;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
    transform: scale(1.05);
}

.attachment-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
    background-color: rgba(0, 0, 0, 0.05);
}

.attachment-btn:active {
    transform: scale(0.95);
}

.attachment-btn.clicked {
    animation: attachmentClick 0.2s ease;
}

@keyframes attachmentClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.attachment-btn.has-attachment {
    color: var(--success-color);
    background-color: rgba(25, 135, 84, 0.1);
}

.attachment-btn.has-attachment:hover {
    background-color: rgba(25, 135, 84, 0.15);
}

.send-btn {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 10;
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    line-height: 1;
    min-width: auto;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.send-btn:hover:not(:disabled) {
    background-color: #0b5ed7;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

.send-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn.clicked {
    animation: sendClick 0.2s ease;
}

@keyframes sendClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.send-btn:disabled {
    background-color: var(--secondary-color);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.conversation-settings-btn {
    position: absolute;
    right: 4.5rem;
    bottom: 1rem;
    z-index: 10;
    background: none;
    border: none;
    color: var(--secondary-color);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    line-height: 1;
    min-width: auto;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-settings-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
    transform: scale(1.05);
}

.conversation-settings-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
    background-color: rgba(0, 0, 0, 0.05);
}

.conversation-settings-btn:active {
    transform: scale(0.95);
}

.conversation-settings-btn.clicked {
    animation: settingsClick 0.2s ease;
}

@keyframes settingsClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.conversation-settings-btn.has-instruction {
    color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
}

.message-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 7rem;
    font-size: 1.5rem;
    line-height: 1.5;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* ==========================================================================
   Message Bubbles & Content
   ========================================================================== */

.message {
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-start;
    width: 100%;
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.message.error .message-bubble {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb !important;
}

.message-bubble {
    max-width: 75%;
    padding: 1.25rem 1.5rem;
    border-radius: 22px;
    position: relative;
    word-wrap: break-word;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message.user .message-bubble {
    background: var(--user-message-bg);
    color: white;
    border-bottom-right-radius: 8px;
}

.message.ai .message-bubble {
    background: var(--ai-message-bg);
    color: var(--dark-color);
    border-bottom-left-radius: 8px;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    text-align: right;
}

.message.ai .message-time {
    text-align: left;
}

.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.message.user .message-footer {
    flex-direction: row-reverse;
}

.message-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.copy-btn {
    color: var(--secondary-color);
    padding: 0.25rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
}

.copy-btn.copied {
    color: var(--success-color);
    background-color: rgba(25, 135, 84, 0.1);
}

.message-content {
    margin-bottom: 0.5rem;
}

.message.ai .message-content {
    color: var(--dark-color);
}

.message.user .message-content {
    color: white;
}

/* Download buttons in messages */
.message-content .download-btn {
    margin: 0.5rem 0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.message-content .download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.message-content .download-btn::before {
    content: "📥";
    font-size: 1em;
}

/* Ensure buttons work in dark/light message bubbles */
.message.user .download-btn {
    background-color: rgba(255,255,255,0.2) !important;
    border-color: rgba(255,255,255,0.3) !important;
    color: white !important;
}

.message.user .download-btn:hover {
    background-color: rgba(255,255,255,0.3) !important;
}

/* Code formatting */
pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

code {
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.message-bubble pre {
    background: rgba(0,0,0,0.05);
    border: none;
    margin: 0.5rem 0;
}

.message.user .message-bubble pre {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Enhanced Markdown Styling */
.message-content h1, .message-content h2, .message-content h3, 
.message-content h4, .message-content h5, .message-content h6 {
    margin: 1.5rem 0 0.8rem 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.5rem; color: var(--primary-color); }
.message-content h2 { font-size: 1.3rem; color: var(--primary-color); }
.message-content h3 { font-size: 1.15rem; color: var(--dark-color); }
.message-content h4 { font-size: 1.1rem; color: var(--dark-color); }
.message-content h5 { font-size: 1.05rem; color: var(--dark-color); }
.message-content h6 { font-size: 1rem; color: var(--secondary-color); }

/* First heading has no top margin */
.message-content h1:first-child, .message-content h2:first-child, 
.message-content h3:first-child, .message-content h4:first-child,
.message-content h5:first-child, .message-content h6:first-child {
    margin-top: 0;
}

.message-content ul, .message-content ol {
    margin: 1rem 0;
    padding-left: 1.8rem;
}

.message-content li {
    margin-bottom: 0.4rem;
    line-height: 1.5;
}

.message-content li > p {
    margin: 0.2rem 0;
}

.message-content blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 1.2rem 0;
    padding: 0.8rem 1.2rem;
    background: rgba(13, 110, 253, 0.05);
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

.message.user .message-content blockquote {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.7);
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.2rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-content th, .message-content td {
    border: 1px solid #e0e0e0;
    padding: 0.75rem;
    text-align: left;
    vertical-align: top;
}

.message-content th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--dark-color);
}

.message-content tbody tr:nth-child(even) {
    background-color: rgba(0,0,0,0.02);
}

.message-content tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.message.user .message-content table {
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content th {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

.message.user .message-content th, .message.user .message-content td {
    border-color: rgba(255, 255, 255, 0.2);
}

.message-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 2rem 0;
}

.message.user .message-content hr {
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
}

/* Enhanced syntax highlighting for code blocks */
.message-content pre code {
    background: none;
    padding: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

.message-content .hljs {
    background: #f8f9fa !important;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.message.user .message-content .hljs {
    background: rgba(255,255,255,0.1) !important;
    color: white;
}

/* Link styling */
.message-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

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

.message.user .message-content a {
    color: rgba(255,255,255,0.9);
}

.message.user .message-content a:hover {
    border-bottom-color: rgba(255,255,255,0.9);
}

/* Paragraph spacing */
.message-content p {
    margin: 0.8rem 0;
    line-height: 1.6;
}

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

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

/* ==========================================================================
   Welcome Message & UI Elements
   ========================================================================== */

.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--secondary-color);
}

.welcome-message h2 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.suggestion-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--ai-message-bg);
    border-radius: 22px;
    border-bottom-left-radius: 8px;
    max-width: 75%;
    margin-bottom: 2rem;
}

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

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

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

/* ==========================================================================
   Utility Classes
   ========================================================================== */

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

.cursor-pointer {
    cursor: pointer;
}

/* ==========================================================================
   Custom Scrollbar - Subtle and Minimal
   ========================================================================== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover-color);
    background-clip: content-box;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-color) transparent;
}

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

@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
    }
    
    .chat-sidebar {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .chat-main-area {
        width: 100%;
        height: calc(100vh - 300px);
    }
    
    .message-bubble {
        max-width: 90%;
        font-size: 1.2rem;
    }
    
    .welcome-message h2 {
        font-size: 1.5rem;
    }
    
    .message-input-container {
        gap: 0.5rem;
    }
    
    .attachment-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
        left: 0.75rem;
        bottom: 0.75rem;
    }
    
    .send-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
        right: 0.75rem;
        bottom: 0.75rem;
    }
    
    .conversation-settings-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
        right: 4.25rem;
        bottom: 0.75rem;
    }
    
    .message-input {
        padding: 0.75rem 6.5rem;
        font-size: 1.2rem;
    }
    
    .attachment-indicator {
        max-width: 250px;
        min-width: 180px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .attachment-indicator i {
        font-size: 0.9rem;
    }
    
    .model-selector {
        padding: 0.75rem 1rem;
    }
}

/* ==========================================================================
   Landing Page & Auth Styles
   ========================================================================== */

.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero-section h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.feature-card {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-card i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    padding: 2rem;
}

.auth-card {
    background: white;
    border-radius: 15px;
    padding: 3rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--dark-color);
}

.form-floating {
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   Chat Header
   ========================================================================== */

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
    gap: 1rem;
}

.conversation-title-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conversation-title-container h5 {
    margin: 0;
    font-weight: 500;
}

.conversation-title-container .btn-link {
    color: var(--secondary-color);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.conversation-title-container .btn-link:hover {
    opacity: 1;
    color: var(--primary-color);
}

/* ==========================================================================
   Model Selector
   ========================================================================== */

/* ==========================================================================
   Error Pages
   ========================================================================== */

.error-page {
    padding: 4rem 2rem;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.error-icon {
    margin-bottom: 2rem;
    animation: bounce 2s infinite;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    line-height: 1;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.error-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--dark-color);
    margin: 1rem 0;
}

.error-message {
    font-size: 1.1rem;
    color: var(--secondary-color);
    max-width: 500px;
    margin: 1rem 0 2rem 0;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 2rem;
}

.error-actions .btn {
    min-width: 140px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
}

.error-help {
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    max-width: 400px;
}

.error-help p {
    margin: 0;
    font-size: 0.9rem;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Responsive adjustments for error pages */
@media (max-width: 768px) {
    .error-page {
        padding: 2rem 1rem;
    }
    
    .error-code {
        font-size: 4rem;
    }
    
    .error-title {
        font-size: 1.5rem;
    }
    
    .error-message {
        font-size: 1rem;
    }
    
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .error-actions .btn {
        width: 100%;
        max-width: 250px;
    }
}

/* ==========================================================================
   Custom Scrollbar - Subtle and Minimal
   ========================================================================== */

/* ==========================================================================
   Search Functionality
   ========================================================================== */

.search-highlight {
    background-color: #fff3cd;
    color: #856404;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    font-weight: 600;
}

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-result-project {
    border-left: 3px solid var(--primary-color);
}

.search-result-conversation {
    border-left: 3px solid #28a745;
}

.search-result-message {
    border-left: 3px solid #6c757d;
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.search-result-content {
    font-size: 0.9rem;
    color: var(--secondary-color);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--secondary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-role {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.search-result-role.user {
    background-color: var(--primary-color);
    color: white;
}

.search-result-role.assistant {
    background-color: #e9ecef;
    color: var(--dark-color);
}

.search-loading {
    padding: 1rem;
    text-align: center;
    color: var(--secondary-color);
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--secondary-color);
    font-style: italic;
}

/* ==========================================================================
   Custom Scrollbar - Subtle and Minimal
   ========================================================================== */

/* ==========================================================================
   File Attachments
   ========================================================================== */

.attachment-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    background-color: rgba(0, 0, 0, 0.02);
    margin-top: 0.5rem;
}

.attachment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.attachment-name {
    color: var(--dark-color);
    font-size: 0.9rem;
}

.attachment-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attachment-image {
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.attachment-indicator {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 300px;
    animation: slideInUp 0.3s ease-out;
    z-index: 100;
    min-width: 200px;
}

.attachment-indicator span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--dark-color);
    font-weight: 500;
}

.attachment-indicator i {
    color: var(--primary-color);
    font-size: 1rem;
}

.attachment-indicator .btn-link {
    color: var(--secondary-color);
    padding: 0.25rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    margin-left: auto;
}

.attachment-indicator .btn-link:hover {
    color: var(--danger-color);
    background-color: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

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

/* ==========================================================================
   Project Sidebar Styles
   ========================================================================== */

.sidebar-heading {
    padding: 1rem 1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.project-list {
    padding: 0 0.5rem;
}

.project-item {
    margin-bottom: 0.5rem;
    border-radius: 8px;
    background-color: var(--light-color);
    border: 1.5px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: background-color 0.2s, box-shadow 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.project-item::before {
    content: '';
    display: block;
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    opacity: 0.18;
    transition: opacity 0.2s;
}

.project-item.active,
.project-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(13,110,253,0.08);
    background: #f4f8ff;
}

.project-item.active::before,
.project-item.selected::before {
    opacity: 1;
    background: var(--primary-color);
}

.project-item:hover {
    background-color: #f6fafd;
    box-shadow: 0 4px 16px rgba(13,110,253,0.10);
    border-color: var(--primary-color);
}

.project-header {
    display: flex;
    align-items: center;
    padding: 0.85rem 0.85rem 0.85rem 1.1rem;
    cursor: pointer;
    gap: 0.5rem;
}

.project-icon {
    margin-right: 0.75rem;
    color: var(--primary-color);
    font-size: 1.25rem;
    filter: drop-shadow(0 1px 2px rgba(13,110,253,0.10));
}

.project-name {
    flex-grow: 1;
    font-weight: 600;
    font-size: 1.02rem;
    color: var(--dark-color);
    letter-spacing: 0.01em;
}

.project-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.project-actions .btn {
    color: var(--secondary-color);
    padding: 0.25rem;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}

.project-actions .btn:hover {
    color: var(--primary-color);
    background-color: rgba(13,110,253,0.08);
    box-shadow: 0 2px 8px rgba(13,110,253,0.08);
}

.project-toggle {
    font-size: 1.1rem;
    margin-left: 0.5rem;
    color: var(--secondary-color);
    transition: transform 0.2s, color 0.2s;
}

.project-item.active .project-toggle,
.project-item.selected .project-toggle {
    color: var(--primary-color);
}

.project-conversations {
    padding: 0 0.5rem 0.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #fff;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.project-conversations .conversation-item {
    padding-left: 0.5rem;
}

.new-conversation-in-project-container {
    padding: 0.5rem;
    text-align: center;
}

.new-conversation-in-project-btn {
    color: var(--primary-color);
    font-weight: 500;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.new-conversation-in-project-btn:hover {
    background-color: rgba(13, 110, 253, 0.12);
    color: #0a58ca;
}

/* ==========================================================================
   Settings Modal
   ========================================================================== */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

.settings-modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 500px;
    opacity: 0;
    transform: translateY(-20px);
    animation: slideIn 0.3s forwards;
}

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

.settings-modal-header h5 {
    margin: 0;
    font-weight: 600;
}

.settings-modal-body {
    padding: 1.5rem;
}

.settings-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

#projectInstructionInput {
    font-family: var(--bs-font-monospace);
    font-size: 0.9rem;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

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

/* ==========================================================================
   Drag and Drop Styles
   ========================================================================== */

.conversation-drag-handle {
    color: var(--secondary-color);
    cursor: grab;
    transition: color 0.2s;
}

.conversation-drag-handle:hover {
    color: var(--primary-color);
}

.conversation-drag-handle:active {
    cursor: grabbing;
}

.conversation-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    transition: opacity 0.2s, transform 0.2s;
}

.conversation-item.dragging .conversation-actions {
    opacity: 0.3;
}

.project-item.drop-zone-active,
.conversation-list.drop-zone-active {
    border: 2px dashed var(--primary-color);
    background-color: rgba(13, 110, 253, 0.05);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
    transition: all 0.2s ease;
}

.project-item.drop-zone-active::before {
    opacity: 0.8;
    background: var(--primary-color);
}

.conversation-item.move-success {
    animation: moveSuccess 2s ease-out;
}

@keyframes moveSuccess {
    0% {
        background-color: rgba(25, 135, 84, 0.2);
        transform: scale(1.02);
    }
    50% {
        background-color: rgba(25, 135, 84, 0.1);
        transform: scale(1.01);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

/* Prevent text selection during drag */
.conversation-item[draggable="true"] {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Drag preview styling */
.conversation-item.dragging {
    position: relative;
    z-index: 1000;
}

/* Drop zone indicators */
.project-item.drop-zone-active .project-header {
    background-color: rgba(13, 110, 253, 0.1);
}

.conversation-list.drop-zone-active {
    border-radius: 8px;
    padding: 0.5rem;
    margin: 0.5rem 0;
    border: 2px dashed var(--primary-color);
    background-color: rgba(13, 110, 253, 0.05);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
    position: relative;
}

.conversation-list.drop-zone-active::before {
    content: 'Drop here to move out of project';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(13, 110, 253, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
}

/* Visual feedback for drag over */
.project-conversations.drop-zone-active {
    background-color: rgba(13, 110, 253, 0.05);
    border: 2px dashed var(--primary-color);
    border-radius: 6px;
    margin: 0.25rem;
}

/* ==========================================================================
   Project Files Page
   ========================================================================== */

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.05);
}

.file-icon i {
    font-size: 1.2rem;
}

.file-info {
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    color: var(--dark-color);
}

.file-row:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 0.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
}

/* Project Files Table Styles */
.files-table {
    margin-bottom: 0;
}

.files-table th {
    border-top: none;
    font-weight: 600;
    color: var(--dark-color);
    background-color: #f8f9fa;
}

.files-table td {
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

.files-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* File Type Badges */
.file-type-badge {
    font-size: 0.75rem;
    font-weight: 500;
}

/* ==========================================================================
   File Repository Overlay
   ========================================================================== */

.file-repository-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s ease-out;
    /* Ensure it's positioned relative to the chat-main-area */
    margin-top: 0;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.file-repository-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
}

.file-repository-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-repository-toolbar {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8f9fa;
    flex-shrink: 0;
}

.file-repository-files {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem;
}

.file-repository-files .table {
    margin-bottom: 0;
}

.file-repository-files .table th {
    border-top: none;
    font-weight: 600;
    color: var(--dark-color);
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.file-repository-files .table td {
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

.file-repository-files .table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Empty state for file repository */
.file-repository-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--secondary-color);
}

.file-repository-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.file-repository-empty h4 {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.file-repository-empty p {
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   Admin Panel Styles
   ========================================================================== */

/* Admin Layout */
   .admin-sidebar {
    background: #f8f9fa;
    min-height: calc(100vh - 200px);
    padding: 1rem;
    border-radius: 0.5rem;
}

.admin-content {
    padding: 1rem;
}

/* Admin Navigation */
.admin-nav .nav-link {
    color: #495057;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
}

.admin-nav .nav-link:hover {
    background: #e9ecef;
    color: #212529;
}

.admin-nav .nav-link.active {
    background: #667eea;
    color: white;
}

.admin-nav .nav-link i {
    margin-right: 0.5rem;
}

/* Stat Cards */
.stat-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card.secondary {
    border-color: var(--secondary-color);
}

.stat-card.success {
    border-color: var(--success-color);
}

.stat-card.warning {
    border-color: var(--warning-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #495057;
}

.stat-label {
    color: #6c757d;
    font-size: 0.9rem;
}

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 0;
}

.stat-card p {
    margin-bottom: 0;
    opacity: 0.9;
}


/* Responsive adjustments for project files */
@media (max-width: 768px) {
    .file-icon {
        width: 32px;
        height: 32px;
    }
    
    .file-icon i {
        font-size: 1rem;
    }
    
    .file-name {
        font-size: 0.9rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
    
    .breadcrumb {
        font-size: 0.9rem;
    }
    
    .file-repository-header {
        padding: 1rem;
    }
    
    .file-repository-toolbar {
        padding: 0.75rem 1rem;
    }
    
    .file-repository-files {
        padding: 0.75rem 1rem;
    }
    
    .file-repository-toolbar .input-group {
        width: 100% !important;
    }
    
    .file-repository-overlay {
        /* Ensure proper positioning on mobile */
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

/* ==========================================================================
   Download Container Styles
   ========================================================================== */

.download-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.download-container .download-btn {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    min-width: 140px;
    justify-content: center;
}

.download-container .download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.download-container .download-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.download-container .download-btn.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    pointer-events: none;
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
