/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #e2e8f0;
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

/* Container layout */
.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
        background: rgba(26, 32, 44, 0.8);
        backdrop-filter: blur(10px);
}

/* Sidebar styles */
.sidebar {
    width: 350px;
    background: linear-gradient(180deg, rgba(45, 55, 72, 0.95) 0%, rgba(26, 32, 44, 0.95) 100%);
    border-right: 1px solid rgba(74, 85, 104, 0.5);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(74, 85, 104, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(26, 32, 44, 0.95);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: #e2e8f0;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.toggle-btn {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.toggle-btn:hover {
    background: rgba(74, 85, 104, 0.5);
    color: #e2e8f0;
}

/* Math input container */
.math-input-container {
    padding: 1.25rem;
        border-bottom: 1px solid rgba(74, 85, 104, 0.5);
        background: rgba(26, 32, 44, 0.95);
}

#math-input {
    width: 100%;
    min-height: 100px;
        padding: 1rem;
        border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    font-size: 1rem;
        resize: vertical;
        margin-bottom: 1rem;
        background: rgba(45, 55, 72, 0.8);
        color: #e2e8f0;
        transition: all 0.2s ease;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#math-input:focus {
    outline: none;
    border-color: #4299e1;
        box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
        background: rgba(45, 55, 72, 0.95);
}

/* Shortcut buttons */
.shortcut-buttons {
    display: flex;
    gap: 0.75rem;
        margin-bottom: 1rem;
        flex-wrap: wrap;
}

.shortcut-btn {
    padding: 0.625rem 1rem;
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #e2e8f0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shortcut-btn:hover {
    background: rgba(45, 55, 72, 0.95);
    border-color: #4299e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Button container */
.button-container {
    display: flex;
    gap: 0.75rem;
}

#solve-button,
#graph-button {
    flex: 1;
    padding: 0.875rem;
    border: none;
    border-radius: 8px;
        font-size: 1rem;
        font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#solve-button {
    background: linear-gradient(135deg, #4299e1 0%, #2b6cb0 100%);
    color: white;
}

#solve-button:hover {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#graph-button {
    background: linear-gradient(135deg, #48bb78 0%, #2f855a 100%);
    color: white;
}

#graph-button:hover {
    background: linear-gradient(135deg, #38a169 0%, #276749 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#graph-button:disabled {
    background: rgba(74, 85, 104, 0.8);
    cursor: not-allowed;
}
history-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #a0aec0;
}

.history-type {
    background: rgba(66, 153, 225, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: #4299e1;
}

.history-email {
    color: #e2e8f0;
    font-style: italic;
}

.history-timestamp {
    color: #a0aec0;
}

/* History container */
.history-container {
    padding: 1.25rem;
    flex-grow: 1;
    overflow-y: auto;
    background: rgba(26, 32, 44, 0.95);
}

.history-container h3 {
    font-size: 1.1rem;
    color: #e2e8f0;
    margin-bottom: 1rem;
    font-weight: 600;
}

#history-list {
    list-style: none;
    margin-bottom: 1rem;
}

#history-list li {
    padding: 1rem;
    border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(45, 55, 72, 0.8);
    color: #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#history-list li:hover {
    background: rgba(45, 55, 72, 0.95);
    border-color: #4299e1;
    transform: translateX(4px) translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#history-list li .MathJax {
    font-size: 1em;
}

#clear-history {
    width: 100%;
    padding: 0.875rem;
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        font-weight: 500;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#clear-history:hover {
    background: rgba(45, 55, 72, 0.95);
    border-color: #4299e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Main content */
.main-content {
    flex: 1 1 70%;
        width: 70%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(26, 32, 44, 0.95);
    position: relative;
    height: 100vh;
}

#calculator {
    flex: 1 1 auto;
        height: 100%;
        min-height: 0;
        border-bottom: none;
        background: rgba(45, 55, 72, 0.95);
    position: relative;
        overflow: hidden;
}

#calculator .dcg-container {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.resize-handle {
    display: none !important;
}

#result-container {
    display: none !important;
}

/* Solution steps */
#solution-steps {
    max-height: 100%;
    overflow-y: auto;
}

.result-section {
    margin-bottom: 2rem;
        padding: 1.25rem;
        border: 1px solid rgba(74, 85, 104, 0.5);
    border-radius: 8px;
    background: rgba(45, 55, 72, 0.8);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .result-section:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
        background: rgba(45, 55, 72, 0.95);
}

.result-section h3 {
    color: #e2e8f0;
        margin-bottom: 1rem;
        font-size: 1.1rem;
    font-weight: 600;
}

.result-content {
    color: #e2e8f0;
    line-height: 1.6;
    padding: 1.25rem;
    background: rgba(26, 32, 44, 0.8);
        border-radius: 8px;
        margin: 0.75rem 0;
        overflow-x: auto;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Markdown styles */
.result-content h1,
.result-content h2,
.result-content h3,
.result-content h4,
.result-content h5,
.result-content h6 {
    color: #e2e8f0;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.result-content p {
    margin: 1em 0;
}

.result-content ul,
.result-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.result-content li {
    margin: 0.5em 0;
}

.result-content code {
    background: rgba(45, 55, 72, 0.8);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
}

.result-content pre {
    background: rgba(45, 55, 72, 0.8);
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
}

.result-content pre code {
    background: none;
    padding: 0;
}

.result-content blockquote {
    border-left: 4px solid #4299e1;
    margin: 1em 0;
    padding: 0.5em 1em;
    background: rgba(66, 153, 225, 0.1);
    border-radius: 0 6px 6px 0;
}

/* LaTeX styles */
.result-content .MathJax {
    font-size: 1.1em;
    margin: 0.5em 0;
    }
    
    .result-content .MathJax_Display {
        margin: 1em 0;
        overflow-x: auto;
        overflow-y: hidden;
}

.info-image {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid rgba(74, 85, 104, 0.5);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.math-content {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(45, 55, 72, 0.8);
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid rgba(74, 85, 104, 0.5);
}

/* Loading spinner */
.loading-spinner {
    display: inline-block !important;
        width: 18px !important;
        height: 18px !important;
        border: 3px solid rgba(255, 255, 255, 0.3) !important;
        border-top-color: #4299e1 !important;
        border-radius: 50% !important;
        animation: chatSpin 0.8s linear infinite !important;
        vertical-align: middle !important;
}

@keyframes chatSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Error message */
.error-message {
    color: #fc8181;
    background: rgba(254, 215, 215, 0.2);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border: 1px solid rgba(245, 101, 101, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Primary section styles */
.primary-section {
    background: rgba(66, 153, 225, 0.2);
    border-color: #4299e1;
}

.primary-section .result-content {
    background: rgba(26, 32, 44, 0.8);
}

/* Scanner info styles */
.scanner-info {
    font-size: 0.9em;
    color: #a0aec0;
        font-weight: normal;
        margin-left: 0.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        }
.sidebar {
    width: 100%;
    height: auto;
    max-height: 50vh;
}
.main-content {
    height: 50vh;
}
#calculator {
    height: 100%;
}
}

/* Brand styles */
.brand {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.5rem;
    background: rgba(17, 24, 39, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    transition: all 0.3s ease;
    }
    
.brand:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

.logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 0 20px rgba(66, 153, 225, 0.3),
        0 0 40px rgba(66, 153, 225, 0.2);
    transition: all 0.3s ease;
    background: rgba(17, 24, 39, 0.95);
    padding: 3px;
    border: 1px solid rgba(66, 153, 225, 0.4);
}

.logo:hover {
    transform: scale(1.15);
    box-shadow: 0 0 25px rgba(66, 153, 225, 0.4),
        0 0 50px rgba(66, 153, 225, 0.3);
    border-color: rgba(66, 153, 225, 0.6);
}

.sidebar-header .brand h2 {
    font-size: 1.75rem;
    background: linear-gradient(135deg, #4299e1 0%, #667eea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    letter-spacing: -0.025em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Update sidebar header for better brand alignment */
.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(74, 85, 104, 0.5);
    display: flex;
    justify-content: space-between;
        align-items: center;
        background: rgba(26, 32, 44, 0.95);
}

/* Add brand watermark to main content */
.main-content::before {
    content: 'Calcumo';
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    font-size: 8rem;
    font-weight: 900;
    color: rgba(66, 153, 225, 0.03);
    pointer-events: none;
    z-index: 0;
    transform: rotate(-15deg);
    white-space: nowrap;
}

/* Update title styles */
.result-section h3 {
    color: #e2e8f0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
        display: flex;
        align-items: center;
        gap: 0.5rem;
}

.result-section h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.1em;
    background: linear-gradient(to bottom, #4299e1, #667eea);
    border-radius: 2px;
}
.daily-stats-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(74, 85, 104, 0.5);
}

.daily-stats-section h3 {
    font-size: 1.1rem;
    color: #e2e8f0;
    margin-bottom: 1rem;
}

.daily-stats-grid {
    display: grid;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.daily-stat {
    background: rgba(26, 32, 44, 0.8);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-date {
    color: #e2e8f0;
    font-size: 0.9rem;
}

.stat-count {
    color: #4299e1;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Scrollbar styles for daily stats */
.daily-stats-grid::-webkit-scrollbar {
    width: 6px;
}

.daily-stats-grid::-webkit-scrollbar-track {
    background: rgba(26, 32, 44, 0.8);
    border-radius: 3px;
}

.daily-stats-grid::-webkit-scrollbar-thumb {
    background: rgba(74, 85, 104, 0.8);
    border-radius: 3px;
}

/* Chatbot sidebar styles */
.chatbot-sidebar {
    width: 560px;
        min-width: 560px;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid transparent;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
    background: transparent;
}

.chatbot-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(74, 85, 104, 0.5);
    font-size: 1.25rem;
    color: #e2e8f0;
    font-weight: 600;
    background: rgba(26, 32, 44, 0.95);
    text-align: center;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    position: relative;
}

/* Scroll to bottom button */
.scroll-to-bottom {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: rgba(59, 130, 246, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.8);
}

.scroll-to-bottom.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-to-bottom:hover {
    background: rgba(59, 130, 246, 1);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-bottom:active {
    transform: translateY(0) scale(0.95);
}

/* Smooth message transitions */
.message {
    transition: opacity 0.2s ease-in-out;
}

.message.streaming {
    opacity: 0.95;
}

/* Improved assistant content rendering */
.assistant-content {
    transition: all 0.1s ease-out;
}

body.theme-purple .chatbot-messages {
    background: #e9d8ff !important;
    /* light uniform purple */
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
}
.chatbot-input-container {
    padding: 0 1.5rem 1.5rem 1.5rem;
    background: rgba(26, 32, 44, 0.95);
}
.input-inner-wrap {
    position: relative;
    width: 100%;
}

#chatbot-input {
    width: 100%;
    min-height: 150px;
    padding: 1.3rem 3.2rem 1.3rem 3.2rem;
        border-radius: 18px;
    border: 2px solid rgba(159, 122, 234, 0.2);
    font-size: 1.05rem;
        background: rgba(30, 41, 59, 0.35);
    color: #e2e8f0;
    resize: none;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.08);
    transition: all 0.3s ease;
    outline: none;
    font-family: 'Calibri', 'Poppins', Arial, Helvetica, sans-serif;
        line-height: 2;
}

#chatbot-input:focus {
    border-color: #9f7aea;
    box-shadow: 0 0 0 3px rgba(159, 122, 234, 0.2),
        0 0 15px rgba(159, 122, 234, 0.3);
}
.file-upload-button {
    position: absolute;
    left: 1.3rem;
    bottom: 1.3rem;
    width: 42px;
    height: 42px;
    background: rgba(159, 122, 234, 0.1);
        border: 1px solid rgba(159, 122, 234, 0.2);
        color: #9f7aea;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 20;
}

.file-upload-button:hover,
.file-upload-button:focus {
    background: rgba(159, 122, 234, 0.2);
        color: #c084fc;
    transform: scale(1.08);
}

#chatbot-send {
    position: absolute;
    right: 1.3rem;
        bottom: 1.3rem;
        width: 42px;
        height: 42px;
        border-radius: 50%;
    border: 1px solid rgba(159, 122, 234, 0.2);
        background: rgba(159, 122, 234, 0.1);
        color: #9f7aea;
        font-size: 1.35rem;
        font-weight: 600;
    cursor: pointer;
    box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s, color 0.2s, transform 0.2s;
        z-index: 20;
}

#chatbot-send:hover,
#chatbot-send:focus {
    background: rgba(159, 122, 234, 0.2);
        color: #c084fc;
        transform: scale(1.08);
    }
    
    @media (max-width: 768px) {
        .chatbot-input-container {
            padding: 0 1rem 1rem 1rem;
            }

        .input-inner-wrap {
            width: 100%;
        }

                                                #chatbot-send,
                                                .file-upload-button {
                                                    width: 36px;
                                                    height: 36px;
                                                    font-size: 1.1rem;
                                                    left: 0.7rem;
                                                    right: 0.7rem;
                                                    bottom: 0.7rem;
                                                }
                        
                                                #chatbot-input {
                                                    min-height: 100px;
                                                    font-size: 1rem;
                                                    padding: 1rem 2.5rem;
                                                }
}

/* Remove .sidebar if not used anymore */
.sidebar {
    display: none !important;
}

.chat-message .assistant-content {
    font-size: inherit;
    color: inherit;
    font-family: inherit;
    line-height: inherit;
}

.input-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.2rem 0.2rem 0.2rem;
}

.file-name-bubble {
    flex: 1;
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        background: transparent;
        border: none;
        padding: 0;
        max-height: 64px;
        overflow-y: auto;
    }
    
    .file-chip {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
            background: rgba(66, 153, 225, 0.15);
            color: #4299e1;
            padding: 0.45rem 1rem;
            border-radius: 999px;
            font-size: 1rem;
            font-weight: 600;
            max-width: none;
            /* allow full width */
            overflow: visible;
        }
        
        .file-chip i {
            flex-shrink: 0;
            margin-left: 0;
            font-size: 1rem;
        }
                                .file-chip i {
                                    margin-left: 0.45rem;
                                    cursor: pointer;
                                    transition: color 0.15s;
                                }
                                .file-chip i:hover {
                                    color: #e53e3e;
}

.ai-model-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(30, 41, 59, 0.85);
    color: #e2e8f0;
    border: 1.5px solid #4299e1;
    border-radius: 999px;
    padding: 0.45rem 2.2rem 0.45rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.08);
    outline: none;
    transition: border 0.2s, box-shadow 0.2s, background 0.2s;
    cursor: pointer;
    position: relative;
    min-width: 120px;
    /* For rounded dropdown in Chrome */
    overflow: hidden;
}

.ai-model-select:focus,
.ai-model-select:hover {
    border-color: #3182ce;
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.13);
}

/* Style the dropdown arrow */
.ai-model-select {
    background-image: url('data:image/svg+xml;utf8,<svg fill="%234299e1" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7.293 7.293a1 1 0 011.414 0L10 8.586l1.293-1.293a1 1 0 111.414 1.414l-2 2a1 1 0 01-1.414 0l-2-2a1 1 0 010-1.414z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 1.1em;
    padding-right: 2.2rem;
}

/* Style the dropdown options (best effort, limited by browser support) */
.ai-model-select option {
    background: #232b3b;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 0.5em 1em;
    margin: 0.2em 0;
}

.ai-model-select option:checked,
.ai-model-select option:focus,
.ai-model-select option:hover {
    background: #4299e1 !important;
    color: #fff !important;
}

/* For Chrome, Edge, Safari: style the dropdown popup */
.ai-model-select::-webkit-dropdown-list {
    background: #232b3b;
    border-radius: 16px;
}

/* For Firefox: style the dropdown popup */
.ai-model-select:-moz-focusring {
    color: #fff;
    background: #232b3b;
}

@media (max-width: 768px) {
    .input-top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .file-name-bubble {
        max-width: 100px;
        font-size: 0.92rem;
        padding: 0.35rem 0.7rem;
    }

    .ai-model-select {
        font-size: 0.95rem;
        min-width: 90px;
        padding: 0.35rem 1.5rem 0.35rem 0.7rem;
    }
}

.custom-dropdown {
    position: relative;
    min-width: 140px;
    font-family: inherit;
}

.dropdown-selected {
    width: 100%;
    background: rgba(30, 41, 59, 0.85);
    color: #e2e8f0;
    border: 1.5px solid #4299e1;
    border-radius: 999px;
    padding: 0.45rem 2.2rem 0.45rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.08);
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border 0.2s, box-shadow 0.2s, background 0.2s;
    gap: 0.7em;
}

.dropdown-selected:focus,
.dropdown-selected:hover {
    border-color: #3182ce;
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.13);
}

.dropdown-selected i {
    margin-left: 0.5em;
    font-size: 1em;
    color: #4299e1;
    transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-selected i {
    transform: rotate(-180deg);
}

.dropdown-list {
    position: absolute;
    bottom: 110%;
    left: 0;
    width: 100%;
    background: #232b3b;
    border-radius: 18px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.18);
    margin: 0;
    padding: 0.3em 0;
    z-index: 100;
    list-style: none;
    border: 1.5px solid #4299e1;
    animation: dropdownFadeInUp 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdownFadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.dropdown-option {
    display: flex;
        align-items: center;
        justify-content: space-between;
    padding: 0.7em 1.2em;
    color: #e2e8f0;
    background: none;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    border-radius: 12px;
    transition: background 0.18s, color 0.18s;
    margin: 0 0.3em;
    outline: none;
}

.dropdown-option:hover,
.dropdown-option:focus {
    background: #4299e1;
    color: #fff;
}

.dropdown-option.selected {
    background: #2b6cb0;
    color: #fff;
}

@media (max-width: 768px) {
    .custom-dropdown {
        min-width: 100px;
    }

    .dropdown-selected {
        font-size: 0.95rem;
        padding: 0.35rem 1.5rem 0.35rem 0.7rem;
    }

    .dropdown-list {
        font-size: 0.95rem;
    }
}
.uploaded-image-label,
.uploaded-pdf-label {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(66, 153, 225, 0.15);
    color: #4299e1;
    border-radius: 12px;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.uploaded-pdf-label {
    background: rgba(159, 122, 234, 0.15);
    color: #9f7aea;
}
.chat-message {
    font-size: 1.05rem !important;
    line-height: 2 !important;
    color: #fff !important;
    margin-bottom: 2rem !important;
    padding: 1rem 1rem !important;
    background: #232b3a !important;
    border-radius: 18px !important;
    font-family: 'Calibri', 'Poppins', Arial, Helvetica, sans-serif !important;
    box-shadow: none !important;
    position: relative !important;
    /* NEW: Prevent horizontal overflow of very long words/equations */
        word-wrap: break-word !important;
        overflow-wrap: anywhere !important;
        white-space: pre-wrap !important;
        /* respect line breaks but allow wrapping */
        max-width: 100% !important;
    }
    
    /* NEW: Ensure inline SVG or MathJax-rendered equations fit within the bubble */
    .chat-message .MathJax_Display,
    .chat-message .MathJax_SVG {
        max-width: 100% !important;
        overflow-x: auto !important;
        height: auto !important;
}
/* Optional: make sure block-level MathJax display equations scroll instead of pushing layout */
.chat-message .MathJax_Display {
    display: block !important;
    white-space: normal !important;
}
        /* Hide any potential pseudo-elements that might be creating black shapes */
        .chat-message::before,
        .chat-message::after,
        .assistant-content::before,
        .assistant-content::after,
        .chat-message .assistant-content::before,
        .chat-message .assistant-content::after {
            display: none !important;
        }

.chat-message * {
    color: inherit !important;
    font-family: inherit !important;
    background: transparent !important;
    box-shadow: none !important;
}

.chat-message strong {
    font-weight: 700 !important;
    color: #fff !important;
    padding: 0 0.1em !important;
}

.chat-message em {
    color: #fff !important;
    font-style: italic !important;
    padding: 0 0.1em !important;
}

.chat-message p,
.chat-message ul,
.chat-message ol,
.chat-message li,
.assistant-content p,
.assistant-content ul,
.assistant-content ol,
.assistant-content li {
    margin-left: unset !important;
    padding-left: unset !important;
}

.chat-message code {
    background: #2d3748 !important;
    color: #fff !important;
    padding: 0.2em 0.5em !important;
    border-radius: 5px !important;
    font-size: 0.98em !important;
    margin: 0 0.2em !important;
}

.chat-message pre {
    background: #2d3748 !important;
    color: #fff !important;
    padding: 1em 1.5em !important;
    border-radius: 8px !important;
    margin: 1.2em 0 !important;
    overflow-x: auto !important;
    font-size: 1em !important;
    line-height: 1.7 !important;
}

.chat-message blockquote {
    background: #2d3748 !important;
    border-left: 4px solid #4299e1 !important;
    margin: 1.2em 0 !important;
    padding: 1em 1.5em !important;
    border-radius: 8px !important;
    color: #fff !important;
    line-height: 1.7 !important;
}
/* --- ChatGPT-style markdown & code block enhancements --- */
.chat-message p {
    margin: 1em 0 !important;
}

.chat-message ul,
.chat-message ol {
    margin: 0.8em 0 !important;
        padding-left: 1.2rem !important;
        list-style-position: inside !important;
}

.chat-message li {
    line-height: 1.7 !important;
    margin-bottom: 0.3em !important;
        padding-left: 0 !important;
}

.chat-message a {
    color: #63b3ed !important;
    text-decoration: underline;
}

.chat-message hr {
    border: none;
    border-top: 1px solid #2d3748;
    margin: 1.5em 0;
}

/* Code block copy button */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: rgba(66, 153, 225, 0.2);
    color: #fff;
}

.copy-btn i {
    pointer-events: none;
}

/* Ensure code block bottom padding leaves space for button */
.chat-message pre {
    padding-top: 2.2em !important;
}

/* --- End markdown enhancements --- */


/* --- Conversation context menu --- */
#convo-context-menu {
    position: absolute;
    background: #2a3447;
    border: 1px solid rgba(74, 85, 104, 0.7);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 0.3rem 0;
    z-index: 9999;
    display: none;
    min-width: 180px;
}

#convo-context-menu .context-option {
    padding: 0.6rem 1rem;
    color: #e2e8f0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}

#convo-context-menu .context-option:hover {
    background: rgba(66, 153, 225, 0.2);
}

/* --- end context menu --- */
/* --- Improved Markdown List Spacing & Indentation --- */
.chat-message ul,
.chat-message ol,
.result-content ul,
.result-content ol {
    margin: 0.8em 0 !important;
    padding-left: 3rem !important;
    list-style-position: outside !important;
}

.chat-message li,
.result-content li {
    line-height: 1.7 !important;
    margin-bottom: 0.3em !important;
    padding-left: 1rem !important;
    text-indent: 0 !important;
}

.chat-message ul ul,
.chat-message ol ul,
.chat-message ul ol,
.chat-message ol ol,
.result-content ul ul,
.result-content ol ul,
.result-content ul ol,
.result-content ol ol {
    margin-top: 0.3em !important;
    margin-bottom: 0.3em !important;
    padding-left: 2rem !important;
}

/* Visually emphasise list markers */
.chat-message ul li::marker,
.result-content ul li::marker {
    color: #000000 !important;
        content: "•" !important;
        font-size: 1.4em !important;
}

.chat-message ol li::marker,
.result-content ol li::marker {
    font-weight: 600 !important;
    color: #000000 !important;
}

/* --- Confirmation Modal --- */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.confirm-modal {
    background: #ffffff;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.confirm-modal p {
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.confirm-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirm-btn,
.cancel-btn {
    flex: 1;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.confirm-btn {
    background: #4299e1;
    color: #ffffff;
}

.confirm-btn:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

.cancel-btn {
    background: #e2e8f0;
    color: #1a202c;
}

.cancel-btn:hover {
    background: #cbd5e1;
    transform: translateY(-2px);
}

/* Dark theme overrides */
body.theme-dark .confirm-modal {
    background: #232b3a;
}

body.theme-dark .confirm-modal p {
    color: #e2e8f0;
}

body.theme-dark .cancel-btn {
    background: #334155;
    color: #e2e8f0;
}

body.theme-dark .cancel-btn:hover {
    background: #475569;
}

body.theme-dark .confirm-btn {
    background: #2563eb;
}

body.theme-dark .confirm-btn:hover {
    background: #1e40af;
}

.spinner-center {
    display: block !important;
    margin: 0.8rem auto !important;
}

body:not(.theme-dark) .confirm-modal p {
    color: #1a202c;
}

/* Credit pill bubble */
.credit-pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(57, 255, 20, 0.25);
        color: #39ff14 !important;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    text-transform: capitalize;
    margin-left: 0.6rem;
    box-shadow: 0 0 6px rgba(57, 255, 20, 0.6);
}

.info-icon {
    color: #4299e1;
    margin-left: 0.6rem;
    cursor: help;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
}

/* Match credits-left pill height to dropdown */
.credits-remaining.credit-pill {
    padding: 0.45rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.file-upload-button.has-files {
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
}

.file-upload-button.disabled {
    color: #4a5568;
    /* gray */
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.file-upload-button.disabled:hover,
.file-upload-button.disabled:focus {
    transform: none;
    color: #4a5568;
}
body.theme-purple .chat-message {
    padding: 1rem 1.6rem !important;
    /* more breathing room */
    line-height: 1.75 !important;
}

body.theme-purple .chat-message ul,
body.theme-purple .chat-message ol {
    padding-left: 1.4rem !important;
    /* indent bullets/numbers */
    margin: 0.6rem 0 !important;
    list-style-position: inside !important;
}

body.theme-purple .chat-message li {
    margin: 0.4rem 0 !important;
    /* even spacing between items */
}
/* Ensure assistant messages still leave extra space for the floating graph button */
.chat-message.assistant {
    padding-bottom: 3.5rem !important;
}
/* Error message styling */
.error-content {
    color: #e53e3e;
    background: rgba(254, 215, 215, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border-left: 4px solid #e53e3e;
    display: inline-block;
    margin-top: 0.5rem;
}

/* Streaming performance optimization */
.chat-message.streaming .assistant-content {
    opacity: 0.9;
    transition: opacity 0.1s ease;
}

/* Prevent layout shift during streaming */
.assistant-content {
    min-height: 1.5em;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Optimize rendering during math processing */
.assistant-content.math-processing {
    pointer-events: none;
    opacity: 0.95;
}

/* --- Assistant Content Bullet & Spacing Fixes --- */
.assistant-content ul,
.assistant-content ol {
    margin: 0.7em 0 0.7em 1.6em !important;
    padding-left: 1.2em !important;
    list-style-position: inside !important;
}

.assistant-content li {
    margin-bottom: 0.3em !important;
    line-height: 1.6 !important;
    padding-left: 0 !important;
    text-indent: 0 !important;
}

.assistant-content p {
    margin: 0.7em 0 !important;
    line-height: 1.6 !important;
}

/* --- End Assistant Content Bullet & Spacing Fixes --- */