/* =============================================================================
   SOFIA'S GRADE 8 REVIEWER - EYE-COMFORT & GORGEOUS PALETTE STYLESHEET
   NO Pure White! Soothing Gradients, Subject-Themed Cards, Dark Mode Toggle
   ============================================================================= */

:root {
  --font-main: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  
  /* Default Eye-Comfort Palette (Soft Warm Slate & Creams) */
  --bg-app: #f4f6fa;
  --bg-card: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #52617a;
  --card-border: #cbd5e1;
  --opt-bg: #f8fafc;
  --opt-border: #cbd5e1;
  --opt-text: #1e293b;
  --opt-badge-bg: #e2e8f0;
  --opt-badge-text: #334155;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #34d399;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #f87171;

  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* =============================================================================
   EYE-CARE THEMES PER SUBJECT (GORGEOUS TINTED GRADIENTS - NO PURE WHITE!)
   ============================================================================= */

/* 1. ARALING PANLIPUNAN 8 (Regal Twilight Sky) */
body[data-subject="ap"] {
  --bg-app: #edf4fe;
  --card-bg-gradient: linear-gradient(145deg, #f0f7ff 0%, #e0effe 100%);
  --card-border: #bfdbfe;
  --card-glow: 0 16px 36px -10px rgba(37, 99, 235, 0.16);
  --prompt-color: #1e3a8a;
  --opt-bg: #f4f9ff;
  --opt-border: #bfdbfe;
  --opt-hover: #dbeafe;
  --opt-badge-bg: #dbeafe;
  --opt-badge-text: #1d4ed8;
  --primary: #2563eb;
}

/* 2. PE & HEALTH 8 (Soothing Sage / Fresh Mint) */
body[data-subject="pe_health"] {
  --bg-app: #edf9f3;
  --card-bg-gradient: linear-gradient(145deg, #f0fdf4 0%, #dcfce7 100%);
  --card-border: #bbf7d0;
  --card-glow: 0 16px 36px -10px rgba(5, 150, 105, 0.16);
  --prompt-color: #064e3b;
  --opt-bg: #f2fcf6;
  --opt-border: #bbf7d0;
  --opt-hover: #d1fae5;
  --opt-badge-bg: #d1fae5;
  --opt-badge-text: #047857;
  --primary: #059669;
}

/* 3. FILIPINO 8 (Warm Honey Parchment / Amber Cream) */
body[data-subject="filipino"] {
  --bg-app: #fdf8eb;
  --card-bg-gradient: linear-gradient(145deg, #fffbeb 0%, #fef3c7 100%);
  --card-border: #fde68a;
  --card-glow: 0 16px 36px -10px rgba(217, 119, 6, 0.16);
  --prompt-color: #78350f;
  --opt-bg: #fffdf5;
  --opt-border: #fde68a;
  --opt-hover: #fef3c7;
  --opt-badge-bg: #fef3c7;
  --opt-badge-text: #b45309;
  --primary: #d97706;
}

/* 4. MUSIC & ARTS 8 (Enchanting Lavender / Lilac Mist) */
body[data-subject="music_arts"] {
  --bg-app: #f6f0fe;
  --card-bg-gradient: linear-gradient(145deg, #faf5ff 0%, #f3e8ff 100%);
  --card-border: #e9d5ff;
  --card-glow: 0 16px 36px -10px rgba(124, 58, 237, 0.16);
  --prompt-color: #4c1d95;
  --opt-bg: #faf7ff;
  --opt-border: #e9d5ff;
  --opt-hover: #f3e8ff;
  --opt-badge-bg: #f3e8ff;
  --opt-badge-text: #7c3aed;
  --primary: #7c3aed;
}

/* 5. TLE 8 (Warm Apricot / Sunset Peach) */
body[data-subject="tle"] {
  --bg-app: #fef4eb;
  --card-bg-gradient: linear-gradient(145deg, #fff7ed 0%, #ffedd5 100%);
  --card-border: #fed7aa;
  --card-glow: 0 16px 36px -10px rgba(234, 88, 12, 0.16);
  --prompt-color: #7c2d12;
  --opt-bg: #fffbf7;
  --opt-border: #fed7aa;
  --opt-hover: #ffedd5;
  --opt-badge-bg: #ffedd5;
  --opt-badge-text: #ea580c;
  --primary: #ea580c;
}

/* =============================================================================
   🌙 ULTRA EYE-COMFORT NIGHT MODE (DARK THEME)
   ============================================================================= */

body.dark-theme {
  --bg-app: #0b0f19;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --card-bg-gradient: linear-gradient(145deg, #172033 0%, #0f172a 100%);
  --card-border: #334155;
  --card-glow: 0 18px 40px -10px rgba(0, 0, 0, 0.6);
  --prompt-color: #f8fafc;
  --opt-bg: #1e293b;
  --opt-border: #334155;
  --opt-text: #f1f5f9;
  --opt-hover: #293548;
  --opt-badge-bg: #334155;
  --opt-badge-text: #cbd5e1;
}

body.dark-theme .app-header {
  background: linear-gradient(135deg, #090d16, #111827);
  border-bottom: 1px solid #1f2937;
}

body.dark-theme .subjects-nav {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

body.dark-theme .subject-tab {
  background: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}

body.dark-theme .subject-tab:hover {
  background: #273549;
}

body.dark-theme .top-toolbar {
  background: #151d2f;
  border-color: #334155;
}

body.dark-theme .view-mode-buttons {
  background: #0f172a;
}

body.dark-theme .mode-btn {
  color: #94a3b8;
}

body.dark-theme .mode-btn.active {
  background: #1e293b;
  color: #f8fafc;
}

body.dark-theme .note-slide-card {
  background: #151d2f;
  border-color: #334155;
}

body.dark-theme .note-slide-card h3 {
  color: #93c5fd;
  border-bottom-color: #1e293b;
}

body.dark-theme .mini-card {
  background: #0f172a;
  border-color: #334155;
}

body.dark-theme .styled-table th {
  background: #1e293b;
  color: #e2e8f0;
}

body.dark-theme .styled-table td {
  border-color: #334155;
}

body.dark-theme .note-box {
  background: #2b2207;
  color: #fef08a;
  border-left-color: #facc15;
}

/* =============================================================================
   HEADER & NAVIGATION
   ============================================================================= */

.app-header {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: white;
  padding: 0.9rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e, #fb7185);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.45);
}

.brand-text h1 {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-text p {
  font-size: 0.78rem;
  color: #c7d2fe;
}

.header-toggles {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-toggle {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  border-radius: 50px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
}

.btn-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Subjects Nav Bar */
.subjects-nav {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
  padding: 0.55rem 1rem;
  position: sticky;
  top: 61px;
  z-index: 90;
  overflow-x: auto;
  white-space: nowrap;
}

.subjects-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  gap: 0.55rem;
}

.subject-tab {
  padding: 0.55rem 1.05rem;
  border-radius: 50px;
  border: 1.5px solid var(--card-border);
  background: rgba(255, 255, 255, 0.75);
  color: #334155;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
}

.subject-tab:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.subject-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* =============================================================================
   MAIN STAGE & TOOLBAR
   ============================================================================= */

.main-stage {
  max-width: 920px;
  width: 100%;
  margin: 1.25rem auto;
  padding: 0 1rem 2.5rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.top-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg-gradient);
  padding: 0.95rem 1.35rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--card-border);
  margin-bottom: 1.15rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.subject-title-area h2 {
  font-size: 1.3rem;
  font-weight: 850;
  color: var(--prompt-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.subject-title-area span {
  font-size: 0.83rem;
  color: var(--text-muted);
  font-weight: 600;
}

.view-mode-buttons {
  display: flex;
  background: rgba(0, 0, 0, 0.06);
  padding: 4px;
  border-radius: 50px;
  gap: 3px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 0.42rem 1rem;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 750;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: white;
  color: #1e1b4b;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* =============================================================================
   CARD SLIDE (BEAUTIFUL, COMFORTABLE ON THE EYES - NO PURE WHITE!)
   ============================================================================= */

.quiz-slide-wrapper {
  background: var(--card-bg-gradient);
  border-radius: var(--radius-xl);
  border: 2px solid var(--card-border);
  box-shadow: var(--card-glow);
  padding: 2rem 2.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Sleek Progress Bar */
.slide-progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  margin-bottom: 1.35rem;
  overflow: hidden;
}

.slide-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #06b6d4, #10b981);
  width: 0%;
  border-radius: 12px;
  transition: width 0.35s ease;
}

/* Slide Meta Row */
.slide-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
}

.q-badge-count {
  font-size: 0.85rem;
  font-weight: 850;
  color: white;
  background: var(--primary);
  padding: 0.32rem 0.95rem;
  border-radius: 50px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.q-angle-badge {
  font-size: 0.8rem;
  font-weight: 750;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--card-border);
  padding: 0.3rem 0.85rem;
  border-radius: 50px;
}

.live-score-pill {
  font-size: 0.88rem;
  font-weight: 850;
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #86efac;
  padding: 0.3rem 0.9rem;
  border-radius: 50px;
}

/* Focused Question Prompt */
.question-prompt {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--prompt-color);
  line-height: 1.5;
  margin-bottom: 1.6rem;
  min-height: 60px;
  letter-spacing: -0.01em;
}

/* Beautiful Option Buttons (Tinted, Elevated, Easy to Read) */
.options-stack {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.35rem;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  text-align: left;
  background: var(--opt-bg);
  border: 2px solid var(--opt-border);
  border-radius: var(--radius-lg);
  padding: 0.95rem 1.25rem;
  font-size: 1.02rem;
  font-family: inherit;
  font-weight: 650;
  color: var(--opt-text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.quiz-option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--opt-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.quiz-option-btn .opt-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--opt-badge-bg);
  color: var(--opt-badge-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  font-size: 0.92rem;
  margin-right: 1rem;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}

.quiz-option-btn .opt-label {
  flex: 1;
}

/* Correct & Wrong Visual States */
.quiz-option-btn.state-correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25) !important;
}

.quiz-option-btn.state-correct .opt-badge {
  background: #10b981 !important;
  color: white !important;
}

.quiz-option-btn.state-wrong {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2) !important;
}

.quiz-option-btn.state-wrong .opt-badge {
  background: #ef4444 !important;
  color: white !important;
}

.quiz-option-btn:disabled {
  cursor: default;
}

/* Instant Feedback & True Answer Banner */
.feedback-banner {
  border-radius: var(--radius-md);
  padding: 1.05rem 1.35rem;
  margin-bottom: 1.35rem;
  display: none;
  animation: slideInDown 0.25s ease;
  font-size: 0.95rem;
}

.feedback-banner.show-correct {
  display: block;
  background: rgba(16, 185, 129, 0.12);
  border: 2px solid #34d399;
  border-left: 6px solid #10b981;
  color: #065f46;
}

.feedback-banner.show-wrong {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid #f87171;
  border-left: 6px solid #ef4444;
  color: #991b1b;
}

.feedback-banner h4 {
  font-size: 1.05rem;
  font-weight: 850;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Slide Action Bar (Next Slide & Timer) */
.slide-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1.5px solid rgba(0, 0, 0, 0.08);
}

.btn-advance-slide {
  background: linear-gradient(135deg, var(--primary), #312e81);
  color: white;
  border: none;
  padding: 0.8rem 1.65rem;
  border-radius: 50px;
  font-weight: 850;
  font-size: 0.98rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.btn-advance-slide:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn-advance-slide:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.auto-advance-timer {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* =============================================================================
   COMPLETION / SUMMARY CARD (SLIDE 50 FINISHED)
   ============================================================================= */

.exam-summary-card {
  background: var(--card-bg-gradient);
  border-radius: var(--radius-xl);
  border: 2px solid #86efac;
  box-shadow: var(--card-glow);
  padding: 2.75rem 1.75rem;
  text-align: center;
  display: none;
  animation: zoomIn 0.3s ease;
}

.exam-summary-card.active {
  display: block;
}

.summary-trophy {
  font-size: 4.2rem;
  margin-bottom: 0.5rem;
  animation: bounce 1.2s infinite alternate;
}

.summary-score-large {
  font-size: 3.4rem;
  font-weight: 900;
  color: #059669;
  letter-spacing: -0.03em;
  margin: 0.5rem 0;
}

.summary-remark {
  font-size: 1.15rem;
  color: var(--prompt-color);
  font-weight: 700;
  max-width: 620px;
  margin: 0 auto 1.5rem auto;
}

.summary-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn-retest-shuffle {
  background: linear-gradient(135deg, #10b981, #047857);
  color: white;
  border: none;
  padding: 0.9rem 1.85rem;
  border-radius: 50px;
  font-size: 1.05rem;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-retest-shuffle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

/* =============================================================================
   LECTURE NOTES / HANDOUT VIEW
   ============================================================================= */

.notes-deck-view {
  display: none;
}

.notes-deck-view.active {
  display: block;
}

.note-slide-card {
  background: var(--card-bg-gradient);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--card-border);
  padding: 1.85rem;
  margin-bottom: 1.35rem;
  box-shadow: var(--card-glow);
}

.note-slide-card h3 {
  font-size: 1.3rem;
  color: var(--prompt-color);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--card-border);
}

.lesson-card {
  margin-bottom: 1rem;
}

.lesson-card h4 {
  font-size: 1.1rem;
  color: var(--prompt-color);
  margin: 0.8rem 0 0.4rem 0;
}

.lesson-card ul, .lesson-card ol {
  padding-left: 1.5rem;
  margin-bottom: 0.85rem;
}

.lesson-card li {
  margin-bottom: 0.4rem;
}

.note-box {
  background: rgba(254, 240, 138, 0.4);
  border-left: 5px solid #eab308;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0.85rem 0;
  color: #713f12;
  font-size: 0.92rem;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.mini-card {
  background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid var(--card-border);
  padding: 1.05rem;
  border-radius: var(--radius-md);
}

.styled-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.styled-table th, .styled-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--card-border);
  text-align: left;
}

.styled-table th {
  background: rgba(0, 0, 0, 0.05);
  font-weight: 800;
  color: var(--prompt-color);
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* Keyframes */
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

@media (max-width: 640px) {
  .quiz-slide-wrapper {
    padding: 1.35rem;
  }
  .question-prompt {
    font-size: 1.15rem;
  }
  .quiz-option-btn {
    font-size: 0.95rem;
    padding: 0.85rem;
  }
}
