/* NTS SSPA District MIS Preparation Portal Modern Stylesheet */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;
  --accent: #10b981;
  --accent-hover: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --sidebar-w: 280px;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.15);
  --secondary: #f8fafc;
  --bg-main: #0b1120;
  --bg-card: #1e293b;
  --border: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Layout */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-menu {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0,0,0,0.06);
  font-weight: 700;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.25);
  color: white;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Content Area */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100vw - var(--sidebar-w));
}

.top-bar {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 8px;
}

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

.btn-icon {
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.btn-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Views */
.content-view {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: none;
}

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

/* Hero / Header Card */
.hero-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: white;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.hero-info h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  font-weight: 800;
}

.hero-info p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  max-width: 650px;
  line-height: 1.5;
}

.hero-stats {
  display: flex;
  gap: 16px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 12px 18px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Filters & Controls */
.filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.select-custom, .input-search {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.select-custom:focus, .input-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-search {
  flex: 1;
  min-width: 220px;
}

/* Study Card */
.study-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.study-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.set-tag {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
}

.q-number {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.q-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 18px;
  color: var(--text-main);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.option-btn {
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: 10px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.option-btn:hover:not(.disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.opt-letter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.option-btn.correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
}

.option-btn.correct .opt-letter {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.option-btn.wrong {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.option-btn.wrong .opt-letter {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

/* Roman Urdu & Detailed Explanation Box */
.explanation-box {
  background: #f0f7ff;
  border-left: 5px solid var(--primary);
  border-radius: 10px;
  padding: 16px 20px;
  margin-top: 16px;
  font-size: 0.95rem;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
  color: #1e293b;
  display: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

[data-theme="dark"] .explanation-box {
  background: #0f224a;
  color: #e2e8f0;
  border-left-color: #3b82f6;
}

.explanation-box .exp-heading {
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
}

.explanation-box .exp-section {
  margin-top: 6px;
}

.explanation-box .exp-section strong {
  color: #0f172a;
}

[data-theme="dark"] .explanation-box .exp-section strong {
  color: #93c5fd;
}

.explanation-box .exp-tip {
  background: #fef3c7;
  color: #92400e;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-top: 10px;
  display: inline-block;
  font-weight: 600;
}

[data-theme="dark"] .explanation-box .exp-tip {
  background: #78350f;
  color: #fef3c7;
}

.explanation-box.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.btn-sm {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-sm:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-sm.bookmarked {
  background: #fef3c7;
  color: #d97706;
  border-color: #f59e0b;
}

/* Milestone Cards Grid */
.milestones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.milestone-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.milestone-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.milestone-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 20px;
  width: fit-content;
  margin-bottom: 12px;
}

.milestone-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.milestone-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 18px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Test Examination Modal / Overlay */
.test-modal {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.test-modal.active {
  display: flex;
}

.test-header {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.test-timer {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.test-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.test-question-area {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  max-width: 800px;
  margin: 0 auto;
}

.test-sidebar {
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.palette-btn {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.palette-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.palette-btn.answered {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Result Card */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 600px;
  margin: 40px auto;
  box-shadow: var(--shadow-lg);
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 8px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
}

.score-big {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}

.score-total {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Mobile Bottom Navigation Bar (App Experience) */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 90;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s ease;
}

.bottom-nav-item .b-icon {
  font-size: 1.25rem;
  transition: transform 0.2s;
}

.bottom-nav-item .b-label {
  font-size: 0.72rem;
  font-weight: 700;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active .b-icon {
  transform: translateY(-2px);
}

/* Mobile responsive adjustments */
@media (max-width: 900px) {
  body {
    padding-bottom: 70px; /* Space for bottom nav bar */
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
    width: 100vw;
  }
  .mobile-toggle {
    display: block;
  }
  .mobile-bottom-bar {
    display: flex;
  }
  .content-view {
    padding: 16px 12px;
  }
  .hero-card {
    padding: 20px 16px;
    border-radius: 12px;
  }
  .hero-info h1 {
    font-size: 1.25rem;
  }
  .study-card {
    padding: 16px 14px;
    border-radius: 12px;
  }
  .q-text {
    font-size: 1rem;
  }
  .option-btn {
    padding: 12px 14px;
    font-size: 0.9rem;
    min-height: 48px; /* Thumb-friendly touch target */
  }
  .test-body {
    flex-direction: column;
  }
  .test-question-area {
    padding: 18px 14px;
  }
  .test-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 180px;
    padding: 12px;
  }
}

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