/* Dark Mode Design System for JEE Main PYQs
   Palette: Zinc Dark (Cal.com / Vercel Aesthetic)
   Canvas: #09090b | Surface: #141416 | Border: #27272a | Primary CTA: #ffffff
*/

:root {
  --canvas: #09090b;
  --surface-soft: #141416;
  --surface-card: #141416;
  --surface-card-hover: #1a1a1e;
  --surface-strong: #27272a;
  --surface-dark: #09090b;
  
  --hairline: #27272a;
  --hairline-soft: #1f1f23;
  
  --primary: #ffffff;
  --primary-active: #e4e4e7;
  --on-primary: #000000;
  
  --ink: #ffffff;
  --body: #d4d4d8;
  --muted: #a1a1aa;
  --muted-soft: #71717a;
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-text: #34d399;
  --success-border: rgba(16, 185, 129, 0.25);
  
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-text: #f87171;
  --danger-border: rgba(239, 68, 68, 0.25);
  
  --tier2-bg: rgba(59, 130, 246, 0.12);
  --tier2-text: #60a5fa;
  --tier2-border: rgba(59, 130, 246, 0.25);
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-elevated: 0 10px 25px rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: var(--font-family);
  background: var(--canvas);
  color: var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Top Navigation ---------------- */
header.top-nav {
  height: 64px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  backdrop-filter: blur(12px);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-circle {
  width: 28px;
  height: 28px;
  background: #ffffff;
  color: #000000;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--ink);
}

/* Nav-Pill-Group (Cal.com signature pill-in-pill in dark mode) */
.nav-pill-group {
  display: flex;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
}

.nav-pill-item {
  background: transparent;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-pill-item:hover {
  color: var(--ink);
}

.nav-pill-item.active {
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-subtle);
}

.sys-spec-badge {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 6px;
}

.spec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* ---------------- Layout & Views ---------------- */
.main-wrapper {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
  flex: 1;
}

.view-section {
  display: none;
}

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

/* ---------------- View 1: Booklet Builder ---------------- */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  align-items: start;
}

.catalog-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-headline h2 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--ink);
  line-height: 1.15;
}

.section-headline p {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Subject Nav-Pill-Bar */
.subject-pill-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.subject-nav {
  display: flex;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 2px;
}

.subj-btn {
  background: transparent;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.subj-btn:hover {
  color: var(--ink);
}

.subj-btn.active {
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-subtle);
}

.subj-counter {
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

/* Filter / Search Bar */
.catalog-actions {
  display: flex;
  gap: 0.5rem;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-input {
  width: 100%;
  height: 40px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 12px 0 34px;
  font-size: 0.88rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: #ffffff;
}

.search-icon-svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.btn-secondary {
  height: 40px;
  padding: 0 14px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-strong);
  border-color: #3f3f46;
}

/* Chapter Cards Grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.75rem;
}

.chapter-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.15s ease;
  user-select: none;
}

.chapter-card:hover {
  background: var(--surface-card-hover);
  border-color: #3f3f46;
}

.chapter-card.selected {
  background: #18181c;
  border-color: #ffffff;
  box-shadow: 0 0 0 1px #ffffff;
}

.chapter-card.is-deleted-chapter {
  opacity: 0.75;
}

.chapter-checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--hairline);
  border-radius: 4px;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.chapter-card.selected .chapter-checkbox {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
}

.chapter-card.selected .chapter-checkbox::after {
  content: "✓";
  font-size: 11px;
  font-weight: 800;
}

.chapter-content {
  flex: 1;
  min-width: 0;
}

.chapter-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.chapter-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.chapter-pos {
  font-size: 0.72rem;
  color: var(--muted-soft);
  font-weight: 500;
}

.chapter-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline);
  color: var(--muted);
}

.badge-tag.badge-deleted {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
  font-weight: 600;
}

/* ---------------- Generator Sidebar Panel ---------------- */
.config-sidebar {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 80px;
}

.sidebar-title h3 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.sidebar-title p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
}

/* Year Config Range */
.year-dropdown-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.year-select {
  height: 38px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  outline: none;
}

.year-select:focus {
  border-color: #ffffff;
}

.year-separator {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.preset-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.preset-chip {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.preset-chip:hover {
  color: var(--ink);
  border-color: #3f3f46;
}

.preset-chip.active {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  font-weight: 600;
}

/* Question Type Buttons */
.qtype-button-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.qtype-btn {
  height: 34px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.qtype-btn:hover {
  color: var(--ink);
}

.qtype-btn.active {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  font-weight: 600;
}

/* Feature Toggle Card */
.feature-toggle-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.feature-toggle-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #ffffff;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-desc h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.toggle-desc p {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}

.text-input {
  height: 38px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-size: 0.85rem;
  color: var(--ink);
  outline: none;
}

.text-input:focus {
  border-color: #ffffff;
}

/* Summary Card */
.selection-summary {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  padding: 3px 0;
}

.summary-item .label {
  color: var(--muted);
}

.summary-item .val {
  font-weight: 600;
  color: var(--ink);
}

/* Primary CTA Button (Solid White with Black Text in Dark Mode) */
.btn-primary-black {
  height: 42px;
  background: #ffffff;
  color: #000000;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}

.btn-primary-black:hover:not(:disabled) {
  background: #e4e4e7;
}

.btn-primary-black:disabled {
  background: var(--surface-strong);
  color: var(--muted-soft);
  cursor: not-allowed;
}

/* ---------------- View 2: Weightage & Analysis ---------------- */
.weightage-header-band {
  margin-bottom: 2rem;
}

.weightage-header-band h2 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.weightage-header-band p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* 4-up Metrics Grid */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.metric-card-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.metric-card-value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.metric-card-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Weightage Filter Toolbar */
.weightage-toolbar {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.toolbar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

/* One-Click High Yield Callout Card */
.high-yield-callout {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-left: 4px solid #ffffff;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.callout-text h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.callout-text p {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Weightage Table */
.weightage-table-wrapper {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.weightage-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.weightage-table th {
  background: #18181b;
  border-bottom: 1px solid var(--hairline);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.weightage-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline-soft);
  color: var(--body);
}

.weightage-table tr:last-child td {
  border-bottom: none;
}

.weightage-table tr:hover td {
  background: #19191d;
}

.table-chapter-title {
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar-track {
  width: 120px;
  height: 6px;
  background: var(--hairline);
  border-radius: var(--radius-pill);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.progress-bar-val {
  height: 100%;
  background: #ffffff;
  border-radius: var(--radius-pill);
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

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

.tier-badge.tier-2 {
  background: var(--tier2-bg);
  color: var(--tier2-text);
  border: 1px solid var(--tier2-border);
}

.tier-badge.tier-3 {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid var(--hairline);
}

.btn-table-action {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  color: var(--ink);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-table-action:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-box {
  background: #141416;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.modal-indicator {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--hairline);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.modal-indicator.done {
  border: none;
  animation: none;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 4px;
}

.modal-msg {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.modal-progress-track {
  width: 100%;
  height: 6px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 20px;
}

.modal-progress-fill {
  height: 100%;
  width: 5%;
  background: #ffffff;
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.modal-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.modal-actions .btn {
  flex: 1;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-modal-dl {
  background: #ffffff;
  color: #000000;
  border: none;
}

.btn-modal-dl:hover {
  background: #e4e4e7;
}

.btn-modal-close {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  color: var(--ink);
}

.btn-modal-close:hover {
  background: var(--surface-strong);
}

@media (max-width: 900px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
  .stat-cards-grid {
    grid-template-columns: 1fr 1fr;
  }
}
