/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e5e5e5;
    --border-color-light: #e5e7eb;
    --input-bg: #ffffff;
    --input-border: #e5e7eb;
    --sidebar-bg: #ffffff;
    --message-user-bg: #ffffff;
    --message-ai-bg: #f9f9f9;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-light: rgba(0, 0, 0, 0.05);
}

body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #121212;
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #333333;
    --border-color-light: #374151;
    --input-bg: #262626;
    --input-border: #404040;
    --sidebar-bg: #1a1a1a;
    --message-user-bg: #262626;
    --message-ai-bg: #1f1f1f;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-light: rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    position: relative;
    z-index: 100;
}

/* Sidebar toggle button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 1px 2px var(--shadow-light);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--input-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--shadow);
}

.sidebar-toggle:active {
    transform: translateY(0);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* Mobile sidebar behavior */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 2px 0 8px var(--shadow);
    }

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

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
}

.sidebar-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.sidebar-content::-webkit-scrollbar {
    display: none;
}

.sidebar-brand {
    padding: 0 0.25rem;
}

.sidebar-logo {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-logo span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-tagline {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color-light);
}

.sidebar-link.active {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.25);
}

.sidebar-link-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    font-size: 1.15rem;
}

.sidebar-link-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-link-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.sidebar-link-subtitle {
    font-size: 0.8rem;
    color: inherit;
    opacity: 0.65;
}

.sidebar-link.active .sidebar-link-subtitle {
    color: rgba(255, 255, 255, 0.85);
    opacity: 1;
}

/* New Chat Button */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0.5rem 1rem 0.5rem;
    border-radius: 8px;
    background: #007bff;
    color: #ffffff;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    border: none;
}

.new-chat-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.conversation-preview {
    color: var(--text-primary);
}

.conversation-preview:hover {
    background: var(--bg-secondary);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.new-chat-btn svg {
    flex-shrink: 0;
}




/* Container removed - no longer needed */


.navigation {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: none;
    border: 1px solid #000000;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    color: #000000;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.nav-btn:hover {
    background: #000000;
    color: #ffffff;
}

/* Main content */
.main-content {
    margin-top: 10px;
    flex: 1;
    background: var(--bg-secondary);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
    padding-bottom: 0;
    position: relative;
    transition: background-color 0.3s ease;
}

.main-content>.theme-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
}

.hero-section {
    text-align: center;
    width: 100%;
    flex: 1;
    overflow: visible;
    padding-bottom: 1rem;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 1px 2px var(--shadow-light);
}

.theme-toggle:hover {
    background: var(--input-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--shadow);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-icon {
    width: 20px;
    height: 20px;
    transition: opacity 0.2s ease;
}

.theme-icon.moon-icon {
    display: none;
}

body.dark-mode .theme-icon.sun-icon {
    display: none;
}

body.dark-mode .theme-icon.moon-icon {
    display: block;
}

.hero-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
}

.hero-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

/* Text input container - legacy, may be used by reply boxes */
.text-input-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e5e5;
}

/* Bottom input bar */
.bottom-input-bar {
    position: sticky;
    bottom: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: none;
    box-shadow: none;
    z-index: 100;
    padding: 1.25rem;
    margin-top: auto;
    margin-left: 1rem;
    margin-right: 1rem;
    margin-bottom: 1rem;
    border-radius: 24px;
    transition: all 0.3s ease;
    /* Allow relative positioning for image preview */
}

body.dark-mode .bottom-input-bar {
    background: transparent;
    border-top: none;
    box-shadow: none;
}

.bottom-input-container {
    width: 100%;
    margin: 0;
    display: flex;
    align-items: flex-end;
    gap: 0.875rem;
    flex-wrap: wrap;
    position: relative;
}

.bottom-text-input {
    flex: 1;
    min-width: 200px;
    border: 1.5px solid #d0d0d0;
    background: #e8e8e8;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    resize: none;
    min-height: 48px;
    max-height: 200px;
    font-family: inherit;
    outline: none;
    padding: 0.875rem 1.125rem;
    border-radius: 20px;
    transition: all 0.2s ease;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .bottom-text-input {
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    background: rgba(38, 38, 38, 0.5);
}

.bottom-text-input:focus {
    border-color: var(--border-color);
    outline: none;
    border-width: 1px;
    box-shadow: 0 0 0 3px var(--shadow-light);
}

.bottom-text-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.bottom-input-actions {
    display: flex;
    gap: 0.625rem;
    align-items: center;
}

.file-attachment-panel {
    margin-top: 1rem;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 18px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.6);
}

.file-attachment-panel.hidden {
    display: none;
}

body.dark-mode .file-attachment-panel {
    background: rgba(15, 23, 42, 0.3);
    border-color: rgba(99, 102, 241, 0.4);
}

.file-attachment-panel .panel-heading {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

body.dark-mode .file-attachment-panel .panel-heading {
    color: #e2e8f0;
}

.attachment-list {
    min-height: 40px;
}

.attachment-empty {
    font-size: 0.9rem;
    color: #475569;
}

.attachment-list-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.attachment-section-title {
    width: 100%;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    margin-top: 0.25rem;
}

.attachment-pill {
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    min-width: 180px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
}

body.dark-mode .attachment-pill {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(99, 102, 241, 0.4);
    color: #e2e8f0;
}

.attachment-pill.selected {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.12);
}

.attachment-pill.pending {
    opacity: 0.7;
    cursor: default;
}

.attachment-pill.disabled {
    pointer-events: none;
}

.attachment-top {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    font-weight: 600;
    color: #0f172a;
}

body.dark-mode .attachment-top {
    color: #f8fafc;
}

.attachment-remove {
    border: none;
    background: transparent;
    color: #ef4444;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.attachment-meta {
    font-size: 0.8rem;
    color: #475569;
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.image-pill .attachment-meta {
    align-items: center;
}

.attachment-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.message-attachments,
.response-attachment-note {
    margin-top: 0.75rem;
    background: rgba(15, 23, 42, 0.05);
    padding: 0.75rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #0f172a;
}

body.dark-mode .message-attachments,
body.dark-mode .response-attachment-note {
    background: rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
}

.response-attachment-note ul {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
}

.btn-icon-submit {
    width: 48px;
    height: 48px;
    border-radius: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.btn-icon-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-icon-submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

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

.btn-icon-submit svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.bottom-input-bar .btn {
    border-radius: 20px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.bottom-input-bar .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bottom-input-bar .btn:active {
    transform: translateY(0);
}

.bottom-input-bar .btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #ffffff;
    border: none;
}

.bottom-input-bar .btn-primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
}

.bottom-input-bar .btn-secondary {
    background: #e8e8e8;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-secondary);
    border: 1.5px solid #d0d0d0;
}

body.dark-mode .bottom-input-bar .btn-secondary {
    background: rgba(38, 38, 38, 0.6);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.bottom-input-bar .btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.bottom-input-bar .media-uploader {
    margin-top: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    position: relative;
    align-self: flex-start;
    flex-shrink: 0;
}

.bottom-input-bar .file-upload-btn {
    width: 48px;
    height: 48px;
    border-radius: 20px;
    background: #e8e8e8;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid #d0d0d0;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .bottom-input-bar .file-upload-btn {
    background: rgba(38, 38, 38, 0.6);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.bottom-input-bar .file-upload-btn:hover {
    background: var(--input-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--shadow);
}

.bottom-input-bar .file-upload-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px var(--shadow-light);
}

.bottom-input-bar .image-preview {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    left: 0;
    background: var(--bg-primary);
    padding: 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 -4px 20px var(--shadow);
    z-index: 101;
    min-width: 280px;
    display: none;
    flex-wrap: wrap;
    gap: 0.75rem;
    transition: all 0.3s ease;
    width: max-content;
    max-width: min(500px, calc(100vw - 4rem));
    margin-bottom: 0.5rem;
    align-items: flex-start;
    justify-content: flex-start;
}

.bottom-input-bar .image-preview:not(:empty),
.bottom-input-bar .image-preview[style*="flex"] {
    display: flex !important;
}

.bottom-input-bar .image-preview-item {
    position: relative;
    display: inline-block;
}

.bottom-input-bar .image-preview-item .thumb {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 8px var(--shadow);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: block;
}

.bottom-input-bar .image-preview-item .thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 1;
}

.bottom-input-bar .image-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid var(--bg-primary);
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.bottom-input-bar .image-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.bottom-input-bar .image-remove-btn:active {
    transform: scale(0.95);
}

.text-input {
    width: 100%;
    border: 1px solid #e5e5e5;
    background: #ffffff;
    font-size: 1rem;
    line-height: 1.6;
    color: #000000;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    outline: none;
    padding: 1rem;
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.text-input:focus {
    border-color: #10a37f;
    outline: none;
    border-width: 1px;
}

.text-input::placeholder {
    color: #000000;
    opacity: 0.5;
}

.input-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.text-input-container .btn-primary {
    background: #10a37f;
    color: #ffffff;
}

.text-input-container .btn-primary:hover {
    background: #0d8f6e;
    color: #ffffff;
}

.text-input-container .btn-secondary {
    background: #ffffff;
    color: #000000;
    border: 1px solid #e5e5e5;
}

.text-input-container .btn-secondary:hover {
    background: #f5f5f5;
    color: #000000;
    border-color: #e5e5e5;
}

/* Media uploader */
.media-uploader {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #ffffff;
    color: #000000;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-upload-btn:hover {
    background: #f5f5f5;
    border-color: #ffffff;
    color: #000000;
}

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

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.image-preview {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.image-preview .thumb {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 1px solid #000000;
}

.text-input-container .image-preview .thumb {
    border: 1px solid #ffffff;
}

.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #000000;
    color: #ffffff;
}

.btn-primary:hover {
    background: #333333;
}

.btn-secondary {
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
}

.btn-secondary:hover {
    background: #f5f5f5;
    color: #000000;
}


/* Responsive design */
@media (max-width: 768px) {
    /* Sidebar is handled in the mobile sidebar behavior section above */

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .text-input-container {
        padding: 1.25rem;
    }

    /* Container removed */
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }

    .bottom-input-container {
        flex-direction: column;
        align-items: stretch;
    }

    .bottom-text-input {
        min-width: 100%;
    }

    .bottom-input-actions {
        width: 100%;
        justify-content: space-between;
    }

    .text-input-container {
        padding: 1rem;
    }

    .bottom-input-bar {
        padding: 0.75rem;
    }

    .bottom-input-bar .image-preview {
        max-width: calc(100vw - 2rem);
        min-width: auto;
        width: calc(100vw - 2rem);
        left: 0;
        right: 0;
    }
}

/* Animation for page load */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.hero-section {
    animation: fadeInUp 0.8s ease-out;
}


.text-input-container {
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* --- Enhanced styles appended --- */

/* Conversation message cards */
.message-card {
    overflow: visible;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: none;
    border: none;
    animation: slideInUp 0.5s ease-out;
    text-align: left;
    margin-bottom: 1rem;
}

.message-card .message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.message-card .message-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.message-card .message-meta {
    margin-left: auto;
    font-size: 0.85rem;
    color: #000000;
    opacity: 0.6;
}

.message-card .message-body {
    white-space: pre-wrap;
    line-height: 1.7;
}

/* Bold and underlined text styling in messages */
.message-card .message-body strong {
    font-weight: 700;
    color: var(--text-primary);
}

.message-card .message-body u {
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
}

.message-card .message-body strong u {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.message-card.user {
    background: var(--message-user-bg);
}

.message-card.user .message-title {
    color: var(--text-primary);
}

.message-card.user .message-icon {
    color: #10a37f;
}

.message-card.ai {
    background: var(--message-ai-bg);
}

.message-card.ai .message-title {
    color: var(--text-primary);
}

.message-card .message-body {
    color: var(--text-primary);
}

.message-card .message-meta {
    color: var(--text-secondary);
    opacity: 0.6;
}

.message-card .message-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.message-icon svg {
    width: 18px;
    height: 18px;
}

/* Reply box */
.reply-box {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: slideInUp 0.5s ease-out;
    text-align: left;
}

.reply-box .reply-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.reply-box .reply-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.reply-box .media-uploader {
    margin-top: 0.5rem;
}

.reply-box textarea {
    width: 100%;
    min-height: 72px;
    padding: 0.875rem 1rem;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
    background: #ffffff;
    color: #000000;
}

.reply-box textarea:focus {
    border-color: #10a37f;
    outline: none;
    border-width: 1px;
}

.reply-box textarea::placeholder {
    color: #000000;
    opacity: 0.5;
}

/* Sidebar conversation previews */
.conversation-preview {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: background 0.2s ease;
    cursor: pointer;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    position: relative;
}

.conversation-preview:hover {
    background: var(--bg-secondary);
}

.conversation-preview .preview-text {
    flex: 1;
    min-width: 0;
    /* Allow text truncation */
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview .delete-conversation-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    opacity: 0.6;
}

.conversation-preview:hover .delete-conversation-btn {
    display: flex;
}

.conversation-preview .delete-conversation-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    opacity: 1;
}

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

.conversation-preview .delete-conversation-btn svg {
    width: 16px;
    height: 16px;
}

/* Stack utilities */
.stack-md {
    margin-top: 1rem;
}

.stack-lg {
    margin-top: 1.5rem;
}


.top-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* User Menu Dropdown */
.user-menu-container {
    position: relative;
}

.user-menu-container.hidden {
    display: none !important;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: var(--message-ai-bg);
    border: 1px solid var(--border-color-light);
    box-shadow: 0 12px 24px var(--shadow-light);
    transition: all 0.3s ease;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.user-menu-toggle:hover {
    background: var(--input-bg);
    border-color: var(--border-color);
    box-shadow: 0 8px 16px var(--shadow);
    transform: translateY(-1px);
}

.user-menu-toggle:active {
    transform: translateY(0);
}

.user-avatar {
    font-size: 1.4rem;
    line-height: 1;
}

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

.dropdown-arrow {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.user-menu-toggle[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color-light);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    padding: 0.5rem;
    z-index: 1000;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
    visibility: hidden;
}

.user-menu-dropdown:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.95rem;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

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

.menu-item:active {
    transform: scale(0.98);
}

.menu-item-button {
    color: var(--text-primary);
}

.menu-item-button:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.menu-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.menu-text {
    flex: 1;
    font-weight: 500;
}

.menu-divider {
    height: 1px;
    background: var(--border-color-light);
    margin: 0.5rem 0;
}

/* Responsive adjustments for user menu */
@media (max-width: 768px) {
    .user-menu-dropdown {
        right: 0;
        left: auto;
        min-width: 200px;
        max-width: calc(100vw - 2rem);
    }
}

.hidden {
    display: none !important;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    z-index: 2000;
    padding: 1.5rem;
}

.auth-overlay.hidden {
    display: none !important;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    border: 1px solid var(--border-color-light);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.4rem;
    border-radius: 999px;
}

.auth-tab {
    flex: 1;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.6rem 0;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.auth-tab.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.35);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form.hidden {
    display: none;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.auth-form input {
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    padding: 0.7rem 0.85rem;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.auth-submit-btn {
    margin-top: 0.5rem;
    padding: 0.75rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 18px 35px rgba(99, 102, 241, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.4);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color-light);
}

.auth-google-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-color-light);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.auth-google-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
    color: #6366f1;
}