/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light Theme Colors - Using app's black theme */
    --primary-color: #000000;
    --secondary-color: #424242;
    --background-color: #ffffff;
    --surface-color: #f8f9fa;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;
    --accent-color: #1976d2;
    --error-color: #d32f2f;
    --success-color: #388e3c;
    --warning-color: #f57c00;
    --sidebar-bg: #f1f5f9;
    --chat-bg: #ffffff;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* Border Radius */
    --border-radius-sm: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #424242;
    --secondary-color: #616161;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #333333;
    --accent-color: #64b5f6;
    --sidebar-bg: #1e293b;
    --chat-bg: #0f172a;
}

body {
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

/* Sidebar */
.sidebar {
    width: 314px;
    background: #f5f6fa;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
    z-index: 1000;
    box-shadow: none;
}

.sidebar-header {
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f5f6fa;
    color: #222;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 700;
    font-size: 1.1rem;
    color: #222;
}

.logo i {
    font-size: 1.6rem;
    color: var(--accent-color);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: white;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-content {
    flex: 1;
    padding: var(--spacing-lg) var(--spacing-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
    background: #f5f6fa;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section h3 {
    font-size: 0.78rem;
    font-weight: 600;
    color: #b0b0b0;
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 8px;
}

.sidebar-btn {
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    color: #222;
    width: 100%;
    padding: 12px 18px;
    background: transparent;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, font-weight 0.15s;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    margin-bottom: 0;
    box-shadow: none;
}

.sidebar-btn i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    color: #222;
    flex-shrink: 0;
}

.sidebar-btn:hover, .sidebar-btn:focus {
    background: #f1f5f9;
    color: #222;
    font-weight: 700;
    outline: none;
}

.sidebar-btn:active, .sidebar-btn.active {
    background: #e3e3e3;
    color: #222;
    font-weight: 700;
}

.sidebar-btn.active {
    background: #e0e0e0;
    color: #333;
}

/* Quick Actions buttons: gray background on hover and active */
.sidebar-section:first-child .sidebar-btn {
    background: transparent !important;
}
.sidebar-section:first-child .sidebar-btn:hover,
.sidebar-section:first-child .sidebar-btn:focus,
.sidebar-section:first-child .sidebar-btn.active,
.sidebar-section:first-child .sidebar-btn:active {
    background: #e3e3e3 !important;
}

/* Remove custom color overrides for specific buttons */
.sidebar-btn:has(i.fa-plus),
.sidebar-btn:has(i.fa-search),
.sidebar-btn:has(i.fa-book),
.sidebar-btn:has(i.fa-cog) {
    border: none !important;
}

.sidebar-section:first-child .sidebar-btn i {
    color: #757575 !important;
    font-weight: 700;
}

/* History List */
.history-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.history-item {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, font-weight 0.15s;
    color: #222;
    font-size: 0.97rem;
    font-weight: 500;
}

.history-item:hover, .history-item:focus {
    background: #f1f5f9;
    color: #222;
    font-weight: 700;
    outline: none;
}

.history-item.active {
    background: #e3e3e3;
    color: #222;
    font-weight: 700;
}

.history-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.history-date {
    font-size: 0.8rem;
    color: inherit;
    opacity: 0.8;
    margin-bottom: var(--spacing-xs);
}

.history-meta {
    font-size: 0.75rem;
    opacity: 0.7;
}

.message-count {
    color: inherit;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--chat-bg);
    position: relative;
}

/* Top Right Logout */
.top-right-logout {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
}

#userEmail {
    font-size: 0.9rem;
    opacity: 0.9;
}

.logout-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logout-btn:hover {
    background-color: #333333;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #fff !important;
}

/* Chat Interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #fff !important;
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    background-color: transparent;
    max-width: 900px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.message {
    display: flex;
    gap: var(--spacing-md);
    animation: fadeIn 0.3s ease;
    max-width: 100%;
    width: 100%;
}

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

.message.assistant {
    align-self: flex-start;
}

.message-content {
    max-width: 100%;
    width: 100%;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-xl);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.message.user .message-content {
    background: #f1f1f1 !important; /* Light gray background */
    color: var(--text-primary);
    border-bottom-right-radius: var(--border-radius-sm);
    border: none;
    padding: var(--spacing-sm) var(--spacing-md); /* Small padding */
    max-width: 50%; /* Half the width of the message area */
    width: fit-content;
    align-self: flex-end;
}

.message.assistant .message-content {
    background: transparent !important;
    border: none !important;
    color: var(--text-primary);
    border-bottom-left-radius: var(--border-radius-sm);
    max-width: 98vw;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-shadow: none;
}

.message.assistant {
    max-width: 100% !important;
    width: 100%;
}

.message-text {
    line-height: 1.7;
    word-wrap: break-word;
    font-size: 0.95rem;
    max-width: 100%;
    width: 100%;
}

.message-text p {
    margin-bottom: var(--spacing-sm);
}

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

.message-text code {
    background-color: var(--border-color);
    padding: 2px 6px;
    border-radius: var(--border-radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.message-text pre {
    background-color: var(--border-color);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    margin: var(--spacing-sm) 0;
}

.message-text pre code {
    background: none;
    padding: 0;
}

.message-actions {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.message-action-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: var(--text-secondary);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.message-action-btn:hover {
    background-color: var(--surface-color);
    color: var(--text-primary);
    transform: scale(1.05);
}

/* Chat Input */
.chat-input-container {
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
}

/* Chat Input Wrapper - full width, compact, flush with left/right (10px margin), 20px from bottom */
.chat-input-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px; /* reduced from 10px */
    background-color: var(--background-color);
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius-xl);
    padding: 8px 8px; /* reduced from 18px 14px */
    transition: all var(--transition-fast);
    max-width: 850px;
    margin: 0 auto 20px auto;
    margin-top: 0;
    width: 100%;
}

/* For horizontal alignment of input and buttons, wrap them in a row container */
.input-row {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: var(--spacing-md);
    width: 100%;
}

.chat-input-wrapper:focus-within {
    border-color: #e0e0e0 !important;
}

.attachment-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.attachment-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
    transform: scale(1.05);
}

.attachment-btn.active {
    background-color: var(--primary-color);
    color: white;
}

#chatInput {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    background: transparent;
    color: var(--text-primary);
    min-height: 40px;
    max-height: 80px;
}

#chatInput::placeholder {
    color: var(--text-secondary);
    padding-top: 6px; /* add top padding for better alignment */
    padding-left: 6px; /* add left padding for better alignment */
    font-size: 0.92rem; /* reduced font size */
}

.send-btn {
    background: #000 !important;
    color: #fff !important;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.send-btn i {
    color: #fff !important;
}

.send-btn:hover:not(:disabled) {
    background: #222 !important;
    color: #fff !important;
    box-shadow: var(--shadow-lg);
}

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

/* Attachment Menu */
.attachment-menu {
    position: absolute;
    bottom: 44px;
    left: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-sm);
    display: none;
    flex-direction: column;
    gap: var(--spacing-xs);
    z-index: 10;
    min-width: 150px;
    margin-bottom: 0;
}

.attachment-menu.show {
    display: flex;
    animation: slideUp 0.2s ease;
}

.attachment-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

.attachment-option:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateX(2px);
}

.attachment-option i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* Hidden file input */
.file-input {
    display: none;
}

/* Animation for attachment menu */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: var(--spacing-md);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    backdrop-filter: blur(5px);
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    background-color: var(--surface-color);
    padding: var(--spacing-xxl);
    border-radius: var(--border-radius-xl);
    text-align: center;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

/* Auth Modal Redesign */
/* Center the auth modal on the screen */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.18);
    z-index: 2000;
    transition: background 0.3s;
}

/* Hide auth modal by default */
.auth-modal {
  display: none;
}

/* Show modal when .show class is present */
.auth-modal.show {
  display: flex;
}

.auth-modal-content {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 0;
    min-width: 350px;
    max-width: 720px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    position: relative;
    animation: modalFadeIn 0.3s;
}

.auth-modal-left {
    flex: 1 1 0;
    padding: 40px 32px 40px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 220px;
    background: #fff;
}

.auth-app-logo {
    font-size: 3rem;
    margin-bottom: 22px;
    color: #1976d2;
}

.auth-app-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 22px;
    letter-spacing: 1.5px;
    color: #fff;
}

.auth-features-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.8;
    width: 100%;
}

.auth-features-list li {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid #222;
    padding-bottom: 10px;
    font-size: 1.04rem;
}

.auth-features-list li:last-child {
    border-bottom: none;
}

.auth-features-list strong {
    min-width: 80px;
    font-weight: 700;
    color: #90caf9;
    display: inline-block;
}

.auth-modal-right {
    flex: 1 1 0;
    padding: 40px 40px 40px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 220px;
    background: #fafbfc;
}

.auth-header {
    margin-bottom: 32px;
    text-align: left;
}

.auth-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #222;
}

.auth-header p {
    font-size: 1.1rem;
    color: #757575;
}

.auth-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    width: 100%;
}

.auth-tab {
    flex: 1;
    padding: 14px 0;
    background: #f1f5f9;
    border: none;
    border-radius: 8px 8px 0 0;
    color: #000;
    font-weight: 600;
    font-size: 1.13rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.auth-tab.active {
    background: #000;
    color: #fff;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 1rem;
    color: #444;
    font-weight: 500;
}

.form-group input {
    padding: 10px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 7px;
    font-size: 1rem;
    background: #f8f9fa;
    transition: border 0.2s;
}

.form-group input:focus {
    border: 1.5px solid #1976d2;
    outline: none;
    background: #fff;
}

.auth-submit-btn {
    margin-top: 10px;
    padding: 12px 0;
    background: #1976d2;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
}

.auth-submit-btn:hover:not(:disabled) {
    background: #1256a3;
}

.auth-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.google-signin-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 18px;
}

.google-signin-btn {
    width: 100%;
    max-width: 260px;
    padding: 10px 0;
    border-radius: 7px;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto;
    background: #fff;
    color: #222;
    border: 1.5px solid #000;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: border 0.2s, box-shadow 0.2s;
}

.google-signin-btn:hover {
    border: 1.5px solid #1976d2;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.10);
}

.google-g-icon {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.auth-error {
    color: var(--error-color);
    font-size: 0.98rem;
    margin-top: 12px;
    text-align: center;
    min-height: 20px;
}

.auth-modal-right > div[style*="text-align:center"] {
    margin-top: 18px !important;
}

#registerLink, #loginLink {
    display: block;
    margin-top: 8px;
    color: #1976d2;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: color 0.2s;
}

#registerLink:hover, #loginLink:hover {
    color: #1256a3;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .auth-modal-content {
        min-width: 0;
        max-width: 98vw;
        border-radius: 12px;
        padding: 0;
    }
    .auth-modal-columns {
        flex-direction: column;
        min-width: 0;
        max-width: 98vw;
        border-radius: 12px;
    }
    .auth-modal-left, .auth-modal-right {
        padding: 24px 12px;
        min-width: 0;
    }
    .auth-modal-divider {
        width: 100%;
        height: 1.5px;
        margin: 0 0 16px 0;
        background: #e0e0e0;
        align-self: auto;
        box-shadow: none;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    backdrop-filter: blur(6px);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    margin: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    border: 1.5px solid var(--border-color);
    animation: modalFadeIn 0.35s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(24px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: var(--spacing-xl) var(--spacing-lg) var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--background-color);
}

.modal-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius-md);
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background-color: var(--border-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

.modal-body {
    padding: var(--spacing-xl) var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
    background: var(--surface-color);
}

.modal-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: var(--background-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
}

.modal-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: #fff;
    border: none;
    padding: var(--spacing-sm) var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.modal-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #222, var(--accent-color));
    transform: translateY(-2px) scale(1.04);
    box-shadow: var(--shadow-md);
}

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

@media (max-width: 600px) {
    .modal-content {
        max-width: 98vw;
        margin: var(--spacing-sm);
        border-radius: var(--border-radius-md);
    }
    .modal-header, .modal-body, .modal-footer {
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.book-card {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.book-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
}

.book-title {
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 1.1rem;
}

.book-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Settings */
.settings-section {
    margin-bottom: var(--spacing-xl);
}

.settings-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: var(--transition-fast);
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.account-info {
    background-color: var(--background-color);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border-color);
}

.account-info p {
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

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

.settings-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.settings-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .top-right-logout {
        top: var(--spacing-md);
        right: var(--spacing-md);
    }
    
    .message {
        max-width: 90%;
    }
    
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: var(--spacing-sm);
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .chat-messages {
        padding: var(--spacing-md);
    }
    
    .chat-input-container {
        padding: var(--spacing-md);
    }
    
    .message {
        max-width: 95%;
    }
    
    .top-right-logout {
        top: var(--spacing-sm);
        right: var(--spacing-sm);
    }
    
    .user-info {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

@media (max-width: 700px) {
    .chat-input-wrapper {
        max-width: 100%;
        margin-left: 8px;
        margin-right: 8px;
    }
}

@media (max-width: 900px) {
    .chat-input-wrapper {
        max-width: 100%;
        margin: 0 auto 20px auto;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent; /* Transparent guide line */
}

::-webkit-scrollbar-thumb {
    background: #ececec; /* Very light gray */
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #e0e0e0; /* Slightly darker on hover */
}

/* Focus Styles */
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sidebar,
    .top-right-logout,
    .chat-input-container,
    .modal,
    .auth-modal {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .chat-messages {
        padding: 0;
    }
}

/* Sidebar tokens badge next to Quick Actions */
.tokens-info-sidebar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: #444;
    border-radius: 16px;
    padding: 3px 12px 3px 8px;
    font-size: 0.95rem;
    font-weight: 600;
    margin-left: 0;
    box-shadow: none;
    transition: color 0.2s;
}
.tokens-info-sidebar i {
    color: #444;
    font-size: 1.1em;
    margin-right: 3px;
}

/* Remove old .tokens-info style if not used elsewhere */
.tokens-info {
    display: none !important;
}

/* Chat Header */
.chat-header {
    background-color: var(--chat-color);
    padding: var(--spacing-sm) var(--spacing-xl) var(--spacing-sm) var(--spacing-xl); /* reduced vertical padding */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 40px; /* reduced from 64px */
}

.attachment-preview-container {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
    min-height: 0;
    max-width: 788px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    min-height: 60px;
    max-height: 160px;
    overflow-y: auto;
    box-sizing: border-box;
}
.attachment-preview-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 60px;
    min-width: 60px;
    height: 60px;
}
.attachment-preview-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.attachment-preview-item i {
    font-size: 2.2em;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: var(--border-color);
    border-radius: 6px;
}
.attachment-preview-remove {
    position: absolute;
    top: -0.4px;
    right: -6px;
    background: #d32f2f;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.9em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
} 

.get-app-btn {
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f6ff;
    color: #4f5bd5;
    border: none;
    padding: 7px 22px 7px 16px;
    border-radius: 999px;
    font-size: 0.93rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    margin: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.get-app-btn:hover, .get-app-btn:focus {
    background: #e8ebfd;
    color: #3b44a1;
    outline: none;
}
.get-app-icon {
    color: #4f5bd5;
    font-size: 1.15em;
    margin-right: 4px;
} 

/* Center the chat input and prompt in the middle of the chat area */
.chat-input-center-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    position: static;
    transform: none;
    top: auto;
    left: auto;
}

/* Centered state for welcome prompt, if needed */
.chat-input-center-container.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    align-items: center;
    z-index: 2;
}

/* Remove .bottom variant, not needed with flex layout */
.chat-input-center-container.bottom {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    top: auto;
    transform: none;
    width: 100%;
    align-items: stretch;
    z-index: 2;
    flex-direction: column;
} 

.chat-input-prompt {
    text-align: center;
    margin-bottom: 70px;
    font-size: 1.6rem;
    color: #888888;
    font-weight: 600;
} 

/* Chat Mode Toggle Row */
.chat-mode-toggle-row {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    margin-top: 6px;
    margin-bottom: 8px;
    width: 100%;
    position: relative;
}
.flex-spacer {
    flex-grow: 1;
}

.chat-mode-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'Poppins', 'Inter', sans-serif;
    font-size: 0.82rem; /* reduced from 0.92rem */
    font-weight: 500;
    color: var(--text-primary);
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border 0.15s;
    outline: none;
}
.chat-mode-btn.active {
    background: #e3f0fb;
    border-color: #1976d2;
    color: #1976d2;
}
.chat-mode-btn:not(.active):hover {
    background: #f3f4f6;
    border-color: #b0b0b0;
} 
.chat-mode-btn:focus, .chat-mode-btn:active {
    border-width: 1px;
    outline: none;
}
.attachment-toggle-btn {
    color: #757575;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 7px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border 0.15s;
    outline: none;
    position: relative;
    z-index: 2;
}
.attachment-toggle-btn:focus, .attachment-toggle-btn:active, .attachment-toggle-btn.active {
    border-width: 1px;
    outline: none;
} 

/* Hamburger menu button in chat header */
.hamburger-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    transition: background var(--transition-fast);
    position: relative;
    z-index: 2;
}
.hamburger-menu-btn:focus, .hamburger-menu-btn:hover {
    background: #f1f5f9;
}
[data-theme="dark"] .hamburger-menu-btn:focus, [data-theme="dark"] .hamburger-menu-btn:hover {
    background: #222;
}

/* Dropdown menu for hamburger */
.hamburger-dropdown-menu {
    position: absolute;
    top: 44px;
    right: 0;
    min-width: 160px;
    background: var(--background-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-radius: var(--border-radius-md);
    padding: 8px 0;
    display: none;
    flex-direction: column;
    z-index: 10;
    border: 1px solid var(--border-color);
}
.hamburger-dropdown-menu .dropdown-item {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 10px 20px;
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.hamburger-dropdown-menu .dropdown-item:hover, .hamburger-dropdown-menu .dropdown-item:focus {
    background: #f1f5f9;
    color: var(--accent-color);
}
[data-theme="dark"] .hamburger-dropdown-menu {
    background: #23272f;
    border: 1px solid #333;
}
[data-theme="dark"] .hamburger-dropdown-menu .dropdown-item:hover, [data-theme="dark"] .hamburger-dropdown-menu .dropdown-item:focus {
    background: #222;
    color: var(--accent-color);
} 

.auth-modal-columns {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-width: 320px;
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: none;
}
.auth-modal-left {
    flex: 1 1 0;
    padding: 40px 32px 40px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 220px;
    background: #fff;
}
.auth-modal-divider {
    width: 1.5px;
    background: #e0e0e0;
    margin: 32px 0;
    align-self: stretch;
    box-shadow: 0 0 2px #e0e0e0;
}
.auth-modal-right {
    flex: 1 1 0;
    padding: 40px 40px 40px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 220px;
    background: #fafbfc;
}
@media (max-width: 600px) {
    .auth-modal-columns {
        flex-direction: column;
        min-width: 0;
        max-width: 95vw;
    }
    .auth-modal-left, .auth-modal-right {
        padding: 24px 12px;
        min-width: 0;
    }
    .auth-modal-divider {
        width: 100%;
        height: 1.5px;
        margin: 0 0 16px 0;
        background: #e0e0e0;
        align-self: auto;
        box-shadow: none;
    }
} 

.new-chat-btn {
    background: none;
    border: none;
    font-size: 1.35rem;
    color: #222;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 50%;
    margin-right: 8px;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.new-chat-btn:focus, .new-chat-btn:hover {
    background: #f1f5f9;
    color: var(--accent-color);
    outline: none;
}
[data-theme="dark"] .new-chat-btn:focus, [data-theme="dark"] .new-chat-btn:hover {
    background: #222b3a;
    color: var(--accent-color);
} 

/* Custom AI response styling */
.ai-response {
  line-height: 1.7;
}
.ai-response hr {
  display: none;
} 

.ai-response p {
  margin-bottom: 1.5em;
} 

.ai-response li {
  margin-bottom: 1em;
} 

.ai-response h1, .ai-response h2, .ai-response h3, .ai-response h4, .ai-response h5, .ai-response h6 {
 
  margin-top: 0.5em;
  margin-bottom: 0.5em;
} 

/* Add styles for history menu button and dropdown */
.history-menu-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    margin-left: 6px;
    transition: background 0.15s, color 0.15s;
    position: relative;
    z-index: 2;
}
.history-menu-btn:hover, .history-menu-btn:focus {
    background: #f1f5f9;
    color: #1976d2;
}

.history-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-menu {
    display: none;
    flex-direction: column;
    min-width: 120px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: fixed;
    z-index: 100;
    padding: 4px 0;
}

.history-menu-item {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 10px 18px;
    font-size: 0.97rem;
    color: #222;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-radius: 0;
}
.history-menu-item:hover, .history-menu-item:focus {
    background: #f1f5f9;
    color: #1976d2;
} 

/* Inline renaming styles for history */
.history-item-renaming {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border-radius: 999px;
    padding: 8px 14px;
    margin-bottom: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.history-rename-input {
    font-size: 0.97rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px 8px;
    outline: none;
    transition: border 0.2s;
}
.history-rename-input:focus {
    border: 1.5px solid var(--accent-color);
}
.history-rename-save, .history-rename-cancel {
    background: none;
    border: none;
    color: #1976d2;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}
.history-rename-save:hover {
    background: #e8f5e9;
    color: #388e3c;
}
.history-rename-cancel:hover {
    background: #ffebee;
    color: #d32f2f;
}

/* Modal overlay improvements for delete confirmation */
#deleteConfirmModal.modal {
    display: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 2000;
}
#deleteConfirmModal.modal.show {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}
#deleteConfirmModal .modal-content {
    max-width: 400px;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    border: 1.5px solid #e0e0e0;
}
#deleteConfirmModal .modal-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px 24px 12px 24px;
}
#deleteConfirmModal .modal-body {
    background: #fff;
    padding: 18px 24px;
    font-size: 1.05rem;
}
#deleteConfirmModal .modal-footer {
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 14px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
#deleteConfirmModal .modal-btn {
    min-width: 90px;
} 

/* Markdown Table Styling for chat markdown (matches Flutter look) */
.ai-response table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.2em;
}
.ai-response th, .ai-response td {
  border: 1px solid #e0e0e0;
  padding: 8px 12px;
  text-align: left;
}
.ai-response th {
  background: #f5f5f5;
  font-weight: bold;
}

/* Markdown Blockquote Styling for important notes */
.ai-response blockquote {
  border-left: 4px solid #FFD700;
  background: #FFFBEA;
  color: #8A6A1B;
  padding: 0.7em 1.2em;
  margin: 1.2em 0;
  font-style: italic;
}

/* Optional: Highlight blockquotes that start with 'Important:' */
.ai-response blockquote.important-note {
  border-left: 4px solid #f57c00;
  background: #fff3e0;
  color: #b26a00;
  font-weight: bold;
} 

/* Professional Login Button */
.login-btn-professional {
    background: #f5f6fa;
    color: #232323;
    border: 1.5px solid #e0e0e0;
    border-radius: 999px;
    padding: 7px 22px;
    font-size: 0.97rem;
    font-weight: 600;
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border 0.18s, box-shadow 0.18s;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.login-btn-professional:hover, .login-btn-professional:focus {
    background: #e3e7ef;
    color: #1976d2;
    border-color: #1976d2;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
    text-decoration: none;
} 