/* ==========================================================================
   Aplikasi TKA Matematika - Pusmendik ANBK CBT Edition Styling
   Mobile-Friendly & Touch-Optimized for Smartphones
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --pm-blue-dark: #1b4776;
  --pm-blue-light: #2c6cb0;
  --pm-blue-btn: #007bff;
  --pm-red-btn: #a51d24;
  --pm-red-hover: #82151b;
  --pm-yellow-btn: #e6a100;
  --pm-yellow-hover: #c48900;
  --pm-gray-bg: #f1f5f9;
  --pm-card-bg: #ffffff;
  --pm-text-main: #1e293b;
  --pm-text-muted: #64748b;
  --pm-border: #cbd5e1;
}

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

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--pm-gray-bg);
  color: var(--pm-text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 70px; /* Space for mobile bottom nav */
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
}

/* Formula & Math container responsive */
.formula-box, .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
.app-nav {
  background: linear-gradient(135deg, #1b4776 0%, #295b92 100%);
  color: white;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  color: #d1e2f5;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.nav-tab-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.nav-tab-btn.active {
  background: #ffffff;
  color: var(--pm-blue-dark);
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -3px 12px rgba(0,0,0,0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 4px 8px 4px;
  z-index: 999;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 8px;
  flex: 1;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.15s;
}

.mobile-nav-item i {
  font-size: 18px;
}

.mobile-nav-item.active {
  color: #0284c7;
  font-weight: 700;
}

@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none;
  }
}

/* ==========================================================================
   PUSMENDIK CBT HEADER & LAYOUT (Replica)
   ========================================================================== */
.pusmendik-header {
  background: linear-gradient(90deg, #1e4573 0%, #27568f 60%, #1e4573 100%);
  color: white;
  padding: 10px 16px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.cbt-container {
  max-width: 1180px;
  margin: 14px auto 30px auto;
  width: 96%;
}

.cbt-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.07);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 580px;
}

/* CBT Top Bar */
.cbt-card-topbar {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.font-size-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #475569;
}

.font-size-btn {
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #cbd5e0;
  background: white;
  font-weight: 600;
  touch-action: manipulation;
}

.font-size-btn.active {
  background: #2b6cb0;
  color: white;
  border-color: #2b6cb0;
}

.btn-info-soal {
  background: #0284c7;
  color: white;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.timer-badge {
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 600;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 16px;
  font-variant-numeric: tabular-nums;
}

.btn-daftar-soal {
  background: #1e4573;
  color: white;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* Question body */
.cbt-question-body {
  padding: 18px 16px;
  flex: 1;
  overflow-y: auto;
}

.font-size-sm .cbt-question-body { font-size: 14px; }
.font-size-md .cbt-question-body { font-size: 15px; }
.font-size-lg .cbt-question-body { font-size: 17px; }

/* Hierarki Indikator */
.hierarki-badge-card {
  background: #f0f7ff;
  border: 1px solid #c8e1ff;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
}

.hierarki-badge-title {
  font-weight: 600;
  color: #0d47a1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

/* Stimulus Box */
.stimulus-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.stimulus-img-container {
  display: flex;
  justify-content: center;
  margin: 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 48px;
  transition: all 0.15s;
}

.option-item:hover, .option-item:active {
  background: #f8fafc;
  border-color: #94a3b8;
}

.option-item.selected {
  border-color: #2b6cb0;
  background: #eff6ff;
}

.option-marker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #475569;
  flex-shrink: 0;
  margin-top: 2px;
}

.option-item.selected .option-marker {
  border-color: #2b6cb0;
  background: #2b6cb0;
  color: white;
}

.option-item.multi .option-marker {
  border-radius: 6px;
}

/* Bottom Bar */
.cbt-card-bottombar {
  padding: 12px 14px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-cbt-prev, .btn-cbt-ragu, .btn-cbt-next, .btn-cbt-finish {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s;
  padding: 8px 16px;
}

.btn-cbt-prev {
  background: var(--pm-red-btn);
  color: white;
  border: none;
}

.btn-cbt-ragu {
  background: var(--pm-yellow-btn);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
}

.btn-cbt-next {
  background: var(--pm-blue-btn);
  color: white;
  border: none;
}

.btn-cbt-finish {
  background: #16a34a;
  color: white;
  border: none;
}

/* ==========================================================================
   POP-UP MODAL DAFTAR SOAL (Grid 5x5 = 25 Butir)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 12px;
}

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

.daftar-soal-modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.daftar-soal-header {
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.daftar-soal-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* 5x5 grid = 25 questions */
  gap: 10px;
  padding: 18px 16px;
  overflow-y: auto;
}

.soal-grid-btn {
  height: 48px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  border: 1.5px solid #cbd5e1;
  background: white;
  color: #334155;
}

.soal-grid-btn.status-unanswered {
  background: white;
  border-color: #cbd5e1;
  color: #334155;
}

.soal-grid-btn.status-answered {
  background: #0284c7;
  border-color: #0284c7;
  color: white;
}

.soal-grid-btn.status-ragu {
  background: #f59e0b;
  border-color: #d97706;
  color: #1e1e1e;
}

.soal-grid-btn.status-current {
  outline: 3px solid #38bdf8;
  outline-offset: 1px;
}

.grid-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 11px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ==========================================================================
   KOTAK-KOTAK SUB MATERI GRID (Card Box Style for Kids)
   ========================================================================== */
.submateri-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

@media (min-width: 640px) {
  .submateri-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
  }
}

.submateri-box {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.submateri-box:hover, .submateri-box:active {
  border-color: #0284c7;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.12);
}

.submateri-box.active {
  border-color: #0284c7;
  background: #f0f9ff;
}

.submateri-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

/* Kotak-kotak mini nomor soal di latihan */
.latihan-soal-num-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 4px;
  -webkit-overflow-scrolling: touch;
}

.latihan-num-box {
  min-width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
}

.latihan-num-box.active {
  background: #0284c7;
  color: white;
  border-color: #0284c7;
}

/* Kategori Table Mobile */
.kategori-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}

.kategori-table th, .kategori-table td {
  padding: 10px 8px;
  text-align: center;
  border-top: 1px solid #e2e8f0;
}

.kategori-table th:first-child, .kategori-table td:first-child {
  text-align: left;
  width: 65%;
}

/* Responsive Overrides */
@media (max-width: 640px) {
  .btn-cbt-prev, .btn-cbt-ragu, .btn-cbt-next, .btn-cbt-finish {
    font-size: 11px;
    padding: 8px 10px;
  }
  .timer-badge {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* ==========================================================================
   CONTOH SOAL KONTEKSTUAL & JURUSAN STYLING
   ========================================================================== */
.contoh-soal-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.contoh-soal-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.jurusan-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.jurusan-tag-ipa {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.jurusan-tag-ips {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.jurusan-tag-smk {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.pembahasan-collapsible {
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 12px 14px;
  margin-top: 10px;
  animation: fadeIn 0.2s ease-out;
}

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

/* In-App Custom Popup & Toast Animations */
@keyframes slideDownToast {
  from { opacity: 0; transform: translateY(-16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popUpZoom {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.animate-toast {
  animation: slideDownToast 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-popup {
  animation: popUpZoom 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
