/* ============================================
   AI Educational Content Generator - Styles
   Modern Dark Theme with Glassmorphism
   ============================================ */

/* CSS Variables */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.3);
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Gradient */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
        radial-gradient(ellipse 50% 30% at 20% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
    animation: float 3s ease-in-out infinite;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 
        0 8px 32px var(--glass-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 40px var(--glass-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Section Titles */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.agent-badge {
    font-size: 1.25rem;
    background: transparent;
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Generate Button */
.btn-generate {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-family);
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-generate::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-generate:hover::before {
    left: 100%;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

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

.btn-generate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Pipeline Flow */
.pipeline-flow {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
    animation: fadeIn 0.4s ease;
}

.flow-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent-primary);
    position: relative;
}

.arrow-line {
    width: 2px;
    height: 30px;
    background: linear-gradient(to bottom, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
}

.arrow-head {
    font-size: 1rem;
    animation: bounce 1s ease infinite;
}

.refinement-arrow {
    color: var(--warning);
}

.refinement-arrow .arrow-line {
    background: linear-gradient(to bottom, var(--warning), #d97706);
}

.refinement-label {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--warning);
    white-space: nowrap;
    padding: 0.25rem 0.5rem;
    background: var(--warning-bg);
    border-radius: var(--radius-sm);
}

/* Output Sections */
.output-section {
    margin-bottom: 0;
    animation: slideUp 0.5s ease;
}

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

.section-header .section-title {
    margin-bottom: 0;
}

.status-badge {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.refined-badge {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
}

/* Content Blocks */
.content-block {
    margin-bottom: 1.5rem;
}

.content-block:last-child {
    margin-bottom: 0;
}

.content-block h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.explanation-content {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
}

/* MCQ Cards */
.mcqs-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mcq-card {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    transition: all var(--transition-fast);
}

.mcq-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.02);
}

.mcq-question {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.875rem;
    line-height: 1.5;
}

.mcq-options {
    display: grid;
    gap: 0.5rem;
}

.mcq-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.mcq-option.correct {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    flex-shrink: 0;
}

.correct .option-letter {
    background: var(--success);
    color: white;
}

/* Review Status */
.review-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-weight: 500;
}

.review-status.pass {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.review-status.fail {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.review-status-icon {
    font-size: 1.25rem;
}

/* Feedback List */
.feedback-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feedback-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.feedback-item::before {
    content: '•';
    color: var(--accent-primary);
    font-weight: bold;
    flex-shrink: 0;
}

/* Refined Section */
.refined-section {
    border: 1px solid rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.02);
}

/* Error Section */
.error-section {
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.3);
    animation: shake 0.5s ease;
}

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

.error-section h3 {
    font-size: 1.25rem;
    color: var(--error);
    margin-bottom: 0.5rem;
}

.error-section p {
    color: var(--text-secondary);
}

/* Footer */
.footer {
    text-align: center;
    padding-top: 3rem;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

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

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem 1rem;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .glass-card {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .refinement-label {
        position: static;
        transform: none;
        margin-top: 0.5rem;
    }
}

/* ============================================
   Part 2: Scores Grid, Teacher Notes, Feedback
   ============================================ */

/* Scores Grid */
.scores-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
    width: 100%;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.score-item.high {
    background: var(--success-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.score-item.medium {
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.score-item.low {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.score-emoji {
    font-size: 1rem;
}

.score-label {
    flex: 1;
    color: var(--text-secondary);
}

.score-value {
    font-weight: 600;
    color: var(--text-primary);
}

.score-item.high .score-value { color: var(--success); }
.score-item.medium .score-value { color: var(--warning); }
.score-item.low .score-value { color: var(--error); }

/* Teacher Notes */
.teacher-notes {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
}

.teacher-notes h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.teacher-notes-content {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.teacher-notes-content p {
    margin-bottom: 0.75rem;
}

.teacher-notes-content ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.teacher-notes-content li {
    margin-bottom: 0.25rem;
}

/* Enhanced Feedback Items */
.feedback-item {
    flex-direction: column;
    gap: 0.25rem;
}

.feedback-field {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-bottom: 0.25rem;
    font-family: monospace;
}

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

.no-feedback {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* Responsive scores grid */
@media (max-width: 480px) {
    .scores-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Tabs Navigation
   ============================================ */

.tabs-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.25rem;
    background: var(--glass-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-family);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: white;
    background: var(--accent-gradient);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ============================================
   History Section
   ============================================ */

.btn-refresh {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-family: var(--font-family);
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-refresh:hover {
    background: rgba(99, 102, 241, 0.2);
}

.history-item {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    margin-bottom: 1rem;
    transition: all var(--transition-fast);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.history-item.approved {
    border-left: 3px solid var(--success);
}

.history-item.rejected {
    border-left: 3px solid var(--error);
}

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

.history-topic {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.history-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-status.approved {
    background: var(--success-bg);
    color: var(--success);
}

.history-status.rejected {
    background: var(--error-bg);
    color: var(--error);
}

.history-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.history-run-id {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.loading-text, .no-history {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

.error-text {
    text-align: center;
    color: var(--error);
    padding: 2rem;
}

/* ============================================
   Artifact Detail View (Expandable)
   ============================================ */

.history-expand-hint {
    font-size: 0.75rem;
    color: var(--accent-primary);
    margin-top: 0.5rem;
    opacity: 0.7;
}

.history-item:hover .history-expand-hint {
    opacity: 1;
}

.artifact-detail {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.artifact-detail-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-section {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.detail-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.75rem;
}

.attempt-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--accent-primary);
}

.attempt-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.attempt-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.mini-score {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.attempt-feedback {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.attempt-feedback ul {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
}

.attempt-feedback code {
    font-size: 0.7rem;
    background: rgba(99, 102, 241, 0.15);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: var(--accent-primary);
}

.detail-explanation {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
}

.detail-mcqs {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

.detail-mcqs ol {
    margin: 0.5rem 0 0 1rem;
    padding: 0;
}

.detail-mcqs li {
    margin-bottom: 0.5rem;
}

.detail-teacher-notes {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: var(--radius-sm);
}

.detail-teacher-notes ul {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    color: var(--accent-primary);
}

.detail-timestamps {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
