/* ==================== */
/* CSS Variables        */
/* ==================== */
:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --primary-light: #7c91f7;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* ==================== */
/* Reset & Base         */
/* ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

/* ==================== */
/* Container            */
/* ==================== */
.container {
    max-width: 900px;
    margin: 0 auto;
}

/* ==================== */
/* Header               */
/* ==================== */
.header {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 1.125rem;
    opacity: 0.95;
    font-weight: 300;
}

/* ==================== */
/* Card Component       */
/* ==================== */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
}

/* ==================== */
/* Input Section        */
/* ==================== */
.input-label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.question-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
    margin-bottom: 1.5rem;
}

.question-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==================== */
/* Mode Selector        */
/* ==================== */
.mode-selector {
    margin-bottom: 1.5rem;
}

.mode-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.mode-btn {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.mode-btn:hover {
    border-color: var(--primary-light);
    background: var(--bg-secondary);
}

.mode-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mode-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.mode-info {
    flex: 1;
}

.mode-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.mode-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.mode-time {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

/* ==================== */
/* Submit Button        */
/* ==================== */
.submit-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-icon {
    transition: var(--transition);
}

.submit-btn:hover:not(:disabled) .btn-icon {
    transform: translateX(4px);
}

/* ==================== */
/* Progress Section     */
/* ==================== */
.progress-section {
    animation: fadeIn 0.3s ease;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.progress-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.estimated-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 999px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-stage {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 500;
}

/* ==================== */
/* Models Status        */
/* ==================== */
.models-status {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.model-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1rem;
    border: 1px solid var(--border);
}

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

.model-name {
    font-weight: 600;
    color: var(--text-primary);
}

.model-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
}

.model-card.pending .status-dot {
    background: var(--text-light);
}

.model-card.processing .status-dot {
    background: var(--warning);
    animation: pulse 2s ease infinite;
}

.model-card.completed .status-dot {
    background: var(--success);
}

.model-card.disabled .status-dot {
    background: var(--border);
}

.status-text {
    color: var(--text-secondary);
}

.model-progress {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}

.model-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    width: 0%;
    transition: width 0.5s ease;
}

/* ==================== */
/* Iteration Status     */
/* ==================== */
.iteration-status {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.iteration-badge {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
}

/* ==================== */
/* Results Section      */
/* ==================== */
.results-section {
    animation: fadeIn 0.5s ease;
}

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

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
}

/* ==================== */
/* Confidence Indicator */
/* ==================== */
.confidence-indicator {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.confidence-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.confidence-bar-container {
    position: relative;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.confidence-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--warning) 0%, var(--success) 100%);
    border-radius: var(--radius-sm);
    transition: width 1s ease;
}

.confidence-value {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==================== */
/* Results Content      */
/* ==================== */
.results-content {
    line-height: 1.8;
    color: var(--text-primary);
}

.results-content h1,
.results-content h2,
.results-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.results-content h1 {
    font-size: 1.75rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.results-content h2 {
    font-size: 1.5rem;
    color: var(--primary);
}

.results-content h3 {
    font-size: 1.25rem;
}

.results-content p {
    margin-bottom: 1rem;
}

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

.results-content li {
    margin-bottom: 0.5rem;
}

.results-content code {
    background: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875em;
    font-family: 'Courier New', monospace;
}

.results-content pre {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 1rem;
}

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

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

/* ==================== */
/* Details Section      */
/* ==================== */
.details-section {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.details-summary {
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    padding: 0.5rem 0;
    user-select: none;
    list-style: none;
}

.details-summary::-webkit-details-marker {
    display: none;
}

.details-summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
}

details[open] .details-summary::before {
    transform: rotate(90deg);
}

.details-content {
    margin-top: 1rem;
}

.detail-block {
    margin-bottom: 2rem;
}

.detail-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.detail-text {
    color: var(--text-secondary);
    line-height: 1.8;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-sm);
}

/* ==================== */
/* Error Section        */
/* ==================== */
.error-section {
    animation: fadeIn 0.3s ease;
}

.error-card {
    text-align: center;
    padding: 3rem 2rem;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--error);
    margin-bottom: 1rem;
}

.error-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* ==================== */
/* Toast Notification   */
/* ==================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    z-index: 1000;
}

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

.toast-text {
    font-weight: 500;
}

/* ==================== */
/* Footer               */
/* ==================== */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    color: white;
    opacity: 0.9;
    font-size: 0.875rem;
}

/* ==================== */
/* Utility Classes      */
/* ==================== */
.hidden {
    display: none !important;
}

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

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ==================== */
/* Responsive Design    */
/* ==================== */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .mode-options {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Update notification animation */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
