/* NPTEL Exam Practice Platform - Modern Dark UI */
:root {
  --bg-primary: #0a0f1d;
  --bg-secondary: #111827;
  --bg-card: #1e293b;
  --bg-card-hover: #283548;
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-subtle: rgba(56, 189, 248, 0.12);
  
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --success-border: #16a34a;
  
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --error-border: #dc2626;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

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

.logo-badge {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Card Component */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* View Screens */
.view-screen {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.view-screen.active {
  display: block;
}

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

/* Setup Screen */
.setup-header {
  margin-bottom: 1.5rem;
}

.setup-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

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

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.25rem;
}

.chip-btn {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.chip-btn:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* Weeks Grid */
.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.week-tile {
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  user-select: none;
}

.week-tile:hover {
  border-color: #475569;
  background-color: var(--bg-card-hover);
}

.week-tile.selected {
  border-color: var(--accent-primary);
  background-color: var(--accent-subtle);
}

.week-tile input[type="checkbox"] {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.week-tile-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.week-tile-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Counter Banner */
.counter-banner {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Options Section */
.options-section {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  margin-bottom: 2rem;
}

.options-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.toggle-control {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  background-color: var(--bg-secondary);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.toggle-control:hover {
  background-color: var(--bg-card-hover);
  border-color: #475569;
}

.toggle-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background-color: #334155;
  border-radius: var(--radius-full);
  position: relative;
  flex-shrink: 0;
  transition: var(--transition);
  margin-top: 2px;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background-color: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: var(--transition);
}

.toggle-control input[type="checkbox"]:checked + .toggle-slider {
  background-color: var(--accent-primary);
}

.toggle-control input[type="checkbox"]:checked + .toggle-slider::after {
  transform: translateX(18px);
}

.toggle-text {
  display: flex;
  flex-direction: column;
}

.toggle-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.toggle-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #fff;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.45);
  transform: translateY(-1px);
}

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

.btn-secondary:hover:not(:disabled) {
  background-color: #334155;
  border-color: #475569;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background-color: var(--bg-card-hover);
}

.btn-large {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

/* Quiz Screen */
.quiz-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

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

.badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
}

.badge-week {
  background-color: var(--accent-subtle);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-number {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.quiz-score-indicator {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.progress-container {
  height: 6px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: var(--radius-full);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Question Card */
.question-header {
  margin-bottom: 1.5rem;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-line;
}

/* Options Container */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.option-item {
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.option-item:hover:not(.locked) {
  background-color: var(--bg-card-hover);
  border-color: #64748b;
  transform: translateX(2px);
}

.option-item.selected {
  background-color: var(--accent-subtle);
  border-color: var(--accent-primary);
}

.option-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}

.option-item.selected .option-badge {
  background-color: var(--accent-primary);
  color: #0a0f1d;
  border-color: var(--accent-primary);
}

.option-text {
  font-size: 0.96rem;
  color: var(--text-primary);
  line-height: 1.45;
  flex: 1;
}

/* Post-Submit States */
.option-item.locked {
  cursor: default;
}

.option-item.correct {
  background-color: var(--success-bg) !important;
  border-color: var(--success) !important;
}

.option-item.correct .option-badge {
  background-color: var(--success) !important;
  color: #fff !important;
  border-color: var(--success) !important;
}

.option-item.incorrect {
  background-color: var(--error-bg) !important;
  border-color: var(--error) !important;
}

.option-item.incorrect .option-badge {
  background-color: var(--error) !important;
  color: #fff !important;
  border-color: var(--error) !important;
}

/* Feedback Banner */
.feedback-banner {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
  border: 1.5px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  animation: fadeIn 0.25s ease-out;
}

.feedback-banner.is-correct {
  background-color: var(--success-bg);
  border-color: var(--success-border);
}

.feedback-banner.is-incorrect {
  background-color: var(--error-bg);
  border-color: var(--error-border);
}

.feedback-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 1rem;
}

.feedback-banner.is-correct .feedback-icon {
  background-color: var(--success);
  color: #fff;
}

.feedback-banner.is-incorrect .feedback-icon {
  background-color: var(--error);
  color: #fff;
}

.feedback-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.feedback-banner.is-correct h4 {
  color: var(--success);
}

.feedback-banner.is-incorrect h4 {
  color: var(--error);
}

.feedback-content p {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Quiz Action Bar */
.quiz-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.keyboard-hints {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

kbd {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

/* Summary Screen */
.summary-card {
  text-align: center;
}

.summary-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.2), rgba(30, 41, 59, 0.8));
  border: 3px solid var(--accent-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.2);
}

.score-percentage {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1;
}

.score-fraction {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  margin-top: 0.35rem;
}

.summary-hero h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

/* Stats Row */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-pill {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-correct .stat-num { color: var(--success); }
.stat-incorrect .stat-num { color: var(--error); }
.stat-time .stat-num { color: var(--accent-primary); }

/* Breakdown Grid */
.week-breakdown-section {
  text-align: left;
  border-top: 1px solid var(--border-color);
  padding-top: 1.75rem;
  margin-bottom: 2rem;
}

.week-breakdown-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.breakdown-item {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.breakdown-week {
  font-weight: 600;
  font-size: 0.9rem;
}

.breakdown-score {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.breakdown-score.perfect { color: var(--success); }
.breakdown-score.good { color: var(--accent-primary); }
.breakdown-score.poor { color: var(--error); }

/* Summary Actions */
.summary-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

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

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 640px) {
  .app-container {
    padding: 1rem 0.75rem 2rem;
  }
  
  .card {
    padding: 1.25rem;
  }

  .quiz-actions {
    flex-direction: column-reverse;
    gap: 1rem;
    align-items: stretch;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons .btn {
    width: 100%;
  }

  .keyboard-hints {
    text-align: center;
  }

  .stats-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .summary-actions {
    flex-direction: column;
  }

  .summary-actions .btn {
    width: 100%;
  }
}
