/* iPadOS Optimized Stylesheet with Strict Enforcement UI */
:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-card: #1e293b;
  --bg-elevated: #283548;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --warning: #f59e0b;
  --success: #10b981;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* App Header & iPad Notch Support */
.header {
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: env(safe-area-inset-top, 12px) 20px 12px 20px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text p {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Strict Enforcement Badge */
.enforcement-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  padding: 6px 14px;
  border-radius: 20px;
  color: #fca5a5;
  font-size: 12px;
  font-weight: 600;
  animation: pulse-danger 2s infinite;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Navigation Tabs */
.nav-bar {
  display: flex;
  gap: 8px;
  max-width: 1200px;
  margin: 12px auto 0 auto;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.nav-bar::-webkit-scrollbar { display: none; }

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.nav-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Main Container */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
}

/* Deadline & Countdown Banner */
.deadline-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.deadline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.deadline-card.critical {
  border-color: var(--danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), var(--bg-card));
}

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

.deadline-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.deadline-card.critical .deadline-title {
  color: #f87171;
}

.deadline-timer {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.deadline-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 30-Min Sprint Tracker & Enforcement Controls */
.sprint-box {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
}

.sprint-box.sprint-active {
  border-color: #60a5fa;
  box-shadow: 0 0 30px rgba(96, 165, 250, 0.4);
  animation: pulse-sprint 2s infinite ease-in-out;
}

@keyframes pulse-sprint {
  0%, 100% { border-color: #60a5fa; box-shadow: 0 0 20px rgba(96, 165, 250, 0.3); }
  50% { border-color: #ef4444; box-shadow: 0 0 30px rgba(239, 68, 68, 0.35); }
}

/* Today's Learning Focus Card */
.today-focus-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border: 2px solid #3b82f6;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.2);
  transition: border-color 0.3s ease;
}

.sprint-info h3 {
  font-size: 18px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sprint-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

.sprint-timer-display {
  font-size: 42px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #60a5fa;
  text-shadow: 0 0 16px var(--accent-glow);
}

.sprint-actions {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* Subject Grid */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.subject-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}
.subject-card:hover {
  border-color: #475569;
}

.subject-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.subject-code {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1);
}

.subject-name {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}

.subject-badge {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.progress-container {
  margin: 16px 0;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #0f172a;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Lesson Accordion & Gated Tasks */
.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.lesson-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lesson-item.completed {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

.lesson-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.lesson-title {
  font-size: 14px;
  font-weight: 600;
}

.lesson-tag {
  font-size: 10px;
  font-weight: 700;
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}

.tag-pe {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.tag-tma {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.lesson-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
.btn-icon:hover { background: var(--bg-elevated); }

.btn-verify {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.btn-verify.done {
  border-color: var(--success);
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

/* Strict Modal & Checkpoint Popup */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 2px solid var(--danger);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 16px 40px var(--danger-glow);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

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

.modal-icon-danger {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.quiz-btn {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.quiz-btn:active { background: var(--bg-elevated); }
.quiz-btn.correct { border-color: var(--success); background: rgba(16,185,129,0.15); color: #6ee7b7; }
.quiz-btn.wrong { border-color: var(--danger); background: rgba(239,68,68,0.15); color: #fca5a5; }

/* Interactive Flashcard View */
.flashcard-box {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  margin-bottom: 16px;
  transition: transform 0.2s, border-color 0.2s;
}
.flashcard-box:active { transform: scale(0.99); }
.flashcard-subject { font-size: 12px; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.flashcard-q { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.flashcard-a { font-size: 17px; font-weight: 600; color: #6ee7b7; margin-top: 16px; display: none; }

/* iPad Floating Reminder Toast */
.enforcement-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e1b4b;
  border: 2px solid #818cf8;
  color: #e0e7ff;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 90;
  max-width: 400px;
  transform: translateY(120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.enforcement-toast.show {
  transform: translateY(0);
}

/* ================= GUIDED SPRINT STUDIO FULLSCREEN OVERLAY ================= */
.studio-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-shrink: 0;
}

.studio-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.studio-lesson-tag {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studio-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.step-badge.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.step-badge.done {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: var(--success);
}

.step-connector {
  width: 16px;
  height: 2px;
  background: var(--border);
}

.studio-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.studio-timer-pill {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid #3b82f6;
  color: #93c5fd;
  padding: 6px 16px;
  border-radius: 20px;
}

/* Studio Workspace & Stages */
.studio-workspace {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

.studio-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stage-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px;
  height: 100%;
  min-height: calc(100vh - 120px);
}

@media (max-width: 900px) {
  .stage-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.media-container {
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 480px;
}

.video-iframe, .pdf-iframe {
  width: 100%;
  height: 100%;
  flex: 1;
  border: none;
  background: #000;
}

.guide-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.focus-card, .hunt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}

.focus-list {
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
}

.hunt-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hunt-item {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-left: 3px solid #34d399;
  border-radius: 4px;
  line-height: 1.5;
}

/* Practice Sandbox (Stage 3) */
.code-editor {
  flex: 1;
  width: 100%;
  background: #090d16;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 14px;
  resize: none;
  outline: none;
  margin-bottom: 12px;
  min-height: 240px;
}

.code-editor:focus {
  border-color: #38bdf8;
}

.code-output {
  background: #050811;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: #4ade80;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Checkpoint Studio (Stage 4) */
.checkpoint-container {
  max-width: 720px;
  margin: 40px auto;
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  width: 100%;
}

.explanation-box {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.6;
}
.explanation-box.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--success);
  color: #a7f3d0;
}
.explanation-box.danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
}

