/* Custom Deep Researcher Design System */

:root {
    --bg-main: #0a0d16;
    --bg-sidebar: #101524;
    --bg-card: rgba(20, 27, 47, 0.75);
    --border-color: rgba(255, 255, 255, 0.07);
    --text-primary: #f1f5f9;
    --text-muted: #94a3b8;
    
    --accent-purple: #9d4edd;
    --accent-cyan: #00f5d4;
    --accent-gradient: linear-gradient(135deg, #7b2cbf 0%, #00f5d4 100%);
    
    --glow-shadow: 0 0 20px rgba(157, 78, 221, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* App Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-icon {
    color: var(--accent-cyan);
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 0 8px rgba(0, 245, 212, 0.4));
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.new-search-btn {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: var(--glow-shadow);
    transition: var(--transition-smooth);
}

.new-search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 245, 212, 0.3);
}

.history-section {
    margin-top: 40px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-left: 4px;
}

.history-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}
.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.history-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item:hover, .history-item.active {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(157, 78, 221, 0.3);
}

.history-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.empty-history {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding-top: 24px;
    font-style: italic;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}
.main-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Search Interface Views */
.search-workspace {
    width: 100%;
    max-width: 720px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 32px;
    animation: fadeIn 0.5s ease-out;
}

.search-header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 40%, var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.search-box-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    width: 100%;
}

.search-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

.settings-trigger {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.settings-trigger:hover {
    color: var(--accent-purple);
}

.submit-search-btn {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(157, 78, 221, 0.2);
    transition: var(--transition-smooth);
}

.submit-search-btn:hover {
    box-shadow: 0 4px 20px rgba(0, 245, 212, 0.25);
    transform: translateY(-1px);
}

/* Extended Settings Drawer */
.extended-settings {
    background: rgba(20, 27, 47, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
}

.settings-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: 600;
}

.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.radio-label input[type="radio"] {
    flex-shrink: 0;
}

.setting-select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-primary);
    user-select: none;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-purple);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Active Results View */
.results-workspace {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease-out;
}

.research-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.status-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
}

.status-indicator.running {
    background: rgba(157, 78, 221, 0.15);
    color: #c084fc;
    border: 1px solid rgba(157, 78, 221, 0.3);
}

.status-indicator.completed {
    background: rgba(0, 245, 212, 0.1);
    color: #4ade80;
    border: 1px solid rgba(0, 245, 212, 0.3);
}

.toggle-steps-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
}

.steps-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
}

.step-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    padding: 4px 0;
}

.step-row.active {
    color: var(--text-primary);
}

.step-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(157, 78, 221, 0.2);
    border-top: 2px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.step-check {
    color: var(--accent-cyan);
    width: 16px;
    height: 16px;
}

/* Report Render Body */
.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease-out;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.report-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.report-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Markdown Rendering Engine Styling */
.markdown-body {
    line-height: 1.625;
    font-size: 0.975rem;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    color: #fff;
}

.markdown-body h1 { font-size: 1.75rem; }
.markdown-body h2 { font-size: 1.35rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 6px; }
.markdown-body h3 { font-size: 1.1rem; }

.markdown-body p {
    margin-bottom: 16px;
    color: #cbd5e1;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent-purple);
    padding-left: 16px;
    color: var(--text-muted);
    font-style: italic;
    margin: 16px 0;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
    padding-left: 20px;
    color: #cbd5e1;
}

.markdown-body li {
    margin-bottom: 6px;
}

/* Inline Citation Tags */
.markdown-body a[href^="http"] {
    color: var(--accent-cyan);
    text-decoration: none;
}

.markdown-body a[href^="http"]:hover {
    text-decoration: underline;
}

/* Citation Badges */
.citation-badge {
    background: rgba(0, 245, 212, 0.15);
    border: 1px solid rgba(0, 245, 212, 0.3);
    color: var(--accent-cyan);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0px 4px;
    border-radius: 4px;
    margin: 0 2px;
    display: inline-block;
    vertical-align: super;
}

/* Right Panel: Debate Sidebar */
.debate-sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.debate-sidebar.collapsed {
    width: 50px;
}

.debate-toggle-bar {
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    flex-shrink: 0;
}

.debate-toggle-bar span {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 8px;
    flex-grow: 1;
}

.debate-sidebar.collapsed .debate-toggle-bar span {
    display: none;
}

.toggle-chevron {
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.debate-sidebar.collapsed .toggle-chevron {
    transform: rotate(180deg);
}

.debate-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.debate-sidebar.collapsed .debate-container {
    display: none;
}

.debate-header {
    margin-bottom: 16px;
}

.debate-header h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.debate-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.debate-feed {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}

.debate-feed::-webkit-scrollbar {
    width: 4px;
}
.debate-feed::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
}

.debate-bubble {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: slideUp 0.3s ease-out;
}

.debate-bubble-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
}

.debate-bubble.gemini .debate-bubble-header { color: #60a5fa; }
.debate-bubble.claude .debate-bubble-header { color: #c084fc; }
.debate-bubble.gpt-oss .debate-bubble-header { color: #34d399; }
.debate-bubble.codex .debate-bubble-header { color: #fbbf24; }

.debate-bubble-content {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #cbd5e1;
    white-space: pre-line;
}

.debate-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding-top: 40px;
    font-style: italic;
}

/* Utility Animations & States */
.hidden {
    display: none !important;
}

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

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

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

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

/* Google OAuth Login Screen */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #101524 0%, #0a0d16 100%);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1000;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    backdrop-filter: blur(16px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.login-icon {
    color: var(--accent-cyan);
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 0 12px rgba(0, 245, 212, 0.5));
    margin-bottom: 8px;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, #fff 40%, var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 12px 0;
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    color: #1f2937;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

.google-login-btn:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.google-icon {
    flex-shrink: 0;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: auto; /* Push to bottom of sidebar */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.user-avatar {
    color: var(--accent-cyan);
    width: 16px;
    height: 16px;
    background: rgba(0, 245, 212, 0.1);
    padding: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.user-email {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logout-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
}

/* ---- Agent config + quotas ---- */
.settings-top-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.quota-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    color: var(--text-muted, #94a3b8);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
}
.quota-refresh-btn:hover { color: #fff; border-color: rgba(212,146,58,0.4); }
.quota-refresh-btn i { width: 14px; height: 14px; }

.agent-config-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.agent-card {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px;
    background: rgba(0,0,0,0.18);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 14px;
    align-items: start;
}
.agent-card.disabled { opacity: 0.55; }
.agent-card-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    grid-column: 1 / -1;
    cursor: pointer;
}
.agent-card-toggle input { accent-color: #d4923a; }
.agent-fields {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 560px) {
    .agent-fields { grid-template-columns: 1fr; }
}
.agent-field label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7a8494;
    margin-bottom: 4px;
}
.agent-field select {
    width: 100%;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #e8eaed;
    padding: 7px 10px;
    font-size: 0.85rem;
}
.quota-bars {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.quota-row {
    display: grid;
    grid-template-columns: 88px 1fr 48px;
    gap: 8px;
    align-items: center;
    font-size: 0.75rem;
    color: #94a3b8;
}
.quota-bar-track {
    height: 6px;
    border-radius: 99px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}
.quota-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #d4923a, #e4a64f);
    min-width: 0;
    transition: width 0.3s ease;
}
.quota-bar-fill.warn { background: linear-gradient(90deg, #c97a2a, #e07040); }
.quota-bar-fill.hot { background: linear-gradient(90deg, #c44, #e07070); }
.quota-pct { text-align: right; font-variant-numeric: tabular-nums; color: #cbd5e1; }
.quota-reset {
    grid-column: 1 / -1;
    font-size: 0.7rem;
    color: #64748b;
}
.quota-na { font-size: 0.75rem; color: #64748b; font-style: italic; }

.live-quota-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 4px;
}
.live-quota-chip {
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: #94a3b8;
}
.live-quota-chip strong { color: #e8eaed; font-weight: 600; }

.cost-card {
    background: rgba(20, 27, 47, 0.75);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 16px 18px;
}
.cost-header h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}
.cost-sub {
    margin: 0 0 12px;
    font-size: 0.78rem;
    color: #7a8494;
}
.cost-provider {
    margin-bottom: 10px;
}
.cost-provider-name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.cost-line {
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
}
.cost-line .delta {
    font-weight: 600;
    color: #e4a64f;
    font-variant-numeric: tabular-nums;
}
.cost-line .delta.zero { color: #64748b; }
