/* Multi-Jumbck - Clean Monochromatic Theme */
/* OS 24/Nov - Beautiful monochromatic design with theme support */

:root {
    --primary: #ffffff;
    --secondary: #fafafa;
    --tertiary: #f5f5f5;
    --quaternary: #e8e8e8;
    --text-primary: #000000;
    --text-secondary: #333333;
    --text-muted: #666666;
    --accent: #000000;
    --border: #e0e0e0;
    --success: #28a745;
    --error: #dc3545;
    --warning: #ffc107;
    --shadow-light: rgba(0, 0, 0, 0.04);
    --shadow-medium: rgba(0, 0, 0, 0.08);
    --shadow-heavy: rgba(0, 0, 0, 0.12);
    --radius: 8px;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #1a1a1a;
    --secondary: #242424;
    --tertiary: #2d2d2d;
    --quaternary: #383838;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent: #ffffff;
    --border: #404040;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    --shadow-heavy: rgba(0, 0, 0, 0.7);
}

/* Beige Theme (Walk the Dragon style) */
[data-theme="beige"] {
    --primary: #f5f1e8;
    --secondary: #ebe6dc;
    --tertiary: #e3ddd1;
    --quaternary: #d9d3c7;
    --text-primary: #2d2a24;
    --text-secondary: #4a4539;
    --text-muted: #6e6a5e;
    --accent: #8b7355;
    --border: #d0c9ba;
    --shadow-light: rgba(45, 42, 36, 0.06);
    --shadow-medium: rgba(45, 42, 36, 0.1);
    --shadow-heavy: rgba(45, 42, 36, 0.15);
}

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

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* User Info Bar */
.user-bar {
    position: absolute;
    top: 1rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 4px var(--shadow-light);
}

.theme-circles {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.theme-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.theme-circle:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.theme-circle.active {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px var(--primary), 0 2px 8px rgba(0,0,0,0.3);
    transform: scale(1.1);
}

.theme-circle.light {
    background: #ffffff;
    border-color: #e0e0e0;
}

.theme-circle.dark {
    background: #1a1a1a;
}

.theme-circle.beige {
    background: #f5f1e8;
    border: 1px solid #d0c9ba;
}

.user-bar .username {
    color: var(--text-secondary);
    font-weight: 500;
}

.user-bar .logout-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.user-bar .logout-btn:hover {
    background: var(--text-primary);
    color: var(--primary);
    border-color: var(--text-primary);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--primary);
    padding: 0.5rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 7px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tab-btn:hover {
    background: var(--secondary);
    color: var(--text-secondary);
}

.tab-btn.active {
    background: var(--text-primary);
    color: var(--primary);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Cards */
.card {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border);
}

/* Query Section */
.query-section {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border);
}

#query-input {
    width: 100%;
    background: var(--secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    transition: all 0.2s ease;
}

#query-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--shadow-light);
}

#query-input::placeholder {
    color: var(--text-muted);
}

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

.model-selection {
    display: flex;
    gap: 1.5rem;
}

.model-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.model-checkbox:hover {
    color: var(--text-primary);
}

.model-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--text-primary);
    cursor: pointer;
}

.model-checkbox span {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Buttons */
.btn-primary {
    background: var(--text-primary);
    color: var(--primary);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 3px var(--shadow-light);
}

.btn-primary:hover {
    background: #333333;
    box-shadow: 0 2px 8px var(--shadow-medium);
}

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

.btn-secondary {
    background: var(--primary);
    color: var(--text-primary);
    border: 2px solid var(--text-primary);
    padding: 0.75rem 2rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.btn-secondary:hover {
    background: var(--text-primary);
    color: var(--primary);
}

/* Responses Grid */
.responses-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* Executive Summary Card */
.executive-summary-card {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 4px 12px var(--shadow-medium);
    border: 2px solid var(--text-primary);
    position: relative;
    min-height: 200px;
    grid-column: 1 / -1;
    margin-bottom: 1rem;
}

.executive-summary-card.expanded {
    /* Style when expanded */
}

.summary-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.summary-header-bar:hover {
    opacity: 0.8;
}

.summary-header-bar > div {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.summary-header-bar h2 {
    font-size: 1.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin: 0;
}

.summary-collapsible-content {
    display: block;
}

.summary-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.summary-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.summary-tab:hover {
    color: var(--text-primary);
    background: var(--secondary);
    border-radius: var(--radius) var(--radius) 0 0;
}

.summary-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
    font-weight: 600;
}

.summary-tab-content {
    color: var(--text-secondary);
    line-height: 1.8;
    min-height: 150px;
}

.summary-tab-content .markdown-content {
    max-height: none;
}

.summary-tab-content .markdown-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.summary-tab-content .markdown-content h2:first-child {
    margin-top: 0;
}

.summary-tab-content .markdown-content ul,
.summary-tab-content .markdown-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.summary-tab-content .markdown-content li {
    margin-bottom: 0.5rem;
}

.summary-tab-content .markdown-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.response-card {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border);
    position: relative;
    min-height: 200px;
}

.response-card.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.response-header h3 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.response-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.response-status.success {
    color: var(--success);
}

.response-status.error {
    color: var(--error);
}

.response-content {
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
}

.response-content pre {
    background: var(--secondary);
    padding: 1rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

/* Settings Section */
.settings-section {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border);
}

.settings-section h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-primary);
}

.info-text {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.api-key-group {
    margin-bottom: 1.5rem;
}

.api-key-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    background: var(--secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: monospace;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--shadow-light);
}

.toggle-visibility {
    background: var(--primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-visibility:hover {
    background: var(--text-primary);
    color: var(--primary);
    border-color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--shadow-light);
}

/* Login/Register Forms */
.auth-container {
    max-width: 400px;
    margin: 5rem auto;
    background: var(--primary);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px var(--shadow-medium);
    border: 1px solid var(--border);
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-primary);
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.auth-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.auth-links a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* reCAPTCHA Container */
.g-recaptcha {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

/* History Section */
.history-section {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border);
}

.history-item {
    background: var(--secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.history-item:hover {
    box-shadow: 0 2px 8px var(--shadow-light);
}

.history-item.expanded {
    background: var(--primary);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.history-header:hover {
    opacity: 0.8;
}

.expand-icon {
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.history-content {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.history-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.history-query {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;
    max-height: 3em;
    word-break: break-word;
}

.history-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.history-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.history-tab:hover {
    color: var(--text-primary);
    background: var(--primary);
}

.history-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
    font-weight: 600;
}

.history-response-container {
    padding: 1rem 0;
    min-height: 100px;
}

.history-response-container .markdown-content {
    max-height: 500px;
    overflow-y: auto;
}

/* Admin Tables */
.admin-table {
    width: 100%;
    background: var(--primary);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.admin-table thead {
    background: var(--text-primary);
    color: var(--primary);
}

.admin-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.admin-table td {
    padding: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
}

.admin-table tbody tr:hover {
    background: var(--secondary);
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
}

.admin-actions button {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--primary);
    color: var(--text-secondary);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.admin-actions button:hover {
    background: var(--text-primary);
    color: var(--primary);
    border-color: var(--text-primary);
}

/* Loading Animation */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Alert Messages */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid;
    font-size: 0.95rem;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--secondary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .user-bar {
        position: static;
        margin-bottom: 1rem;
        justify-content: center;
    }
    
    .nav-tabs {
        overflow-x: auto;
        gap: 0.25rem;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .responses-grid {
        grid-template-columns: 1fr;
    }
    
    .query-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .model-selection {
        justify-content: center;
    }
    
    .auth-container {
        margin: 2rem auto;
        padding: 1.5rem;
    }
}

/* Markdown Content Styling - ChatGPT-like */
.markdown-content {
    line-height: 1.7;
    color: var(--text-secondary);
    font-size: 15px;
}

.markdown-content p {
    margin: 0 0 16px 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    margin: 24px 0 16px 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.markdown-content h1 { font-size: 28px; }
.markdown-content h2 { font-size: 24px; }
.markdown-content h3 { font-size: 20px; }
.markdown-content h4 { font-size: 18px; }

.markdown-content ul,
.markdown-content ol {
    margin: 0 0 16px 0;
    padding-left: 28px;
}

.markdown-content li {
    margin: 6px 0;
}

.markdown-content li p {
    margin: 4px 0;
}

.markdown-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-content em {
    font-style: italic;
}

.markdown-content code {
    background: var(--secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 14px;
    color: var(--text-primary);
}

.markdown-content pre {
    background: var(--secondary);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border);
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
}

.markdown-content blockquote {
    border-left: 4px solid var(--text-secondary);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-content a {
    color: var(--text-primary);
    text-decoration: underline;
    font-weight: 500;
}

.markdown-content a:hover {
    opacity: 0.8;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 14px;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #e5e7eb;
    padding: 10px 14px;
    text-align: left;
}

.markdown-content th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-content tr:nth-child(even) {
    background: #f9fafb;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

/* Override response-content styles for markdown */
.response-content .markdown-content {
    white-space: normal;
}
