/* ==========================================================================
   Tadabbur Al-Qur'an + Tafsir — UI Overhaul & Responsive System
   Smartphone (<=600px), Tablet (601px - 1023px), Desktop (>=1024px)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL SYSTEM & CONTAINER ENHANCEMENT
   -------------------------------------------------------------------------- */
:root {
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --touch-target: 44px;
}

/* Elegant desktop container scaling */
@media (min-width: 1024px) {
  .wrap,
  header .hbar,
  header .hrow {
    max-width: 1020px;
  }
  .wrap {
    padding: 16px 20px 40px;
  }
}

@media (min-width: 1280px) {
  .wrap,
  header .hbar,
  header .hrow {
    max-width: 1040px;
  }
  .wrap {
    padding: 20px 24px 48px;
  }
}

@media (min-width: 601px) and (max-width: 1023px) {
  .wrap {
    padding: 12px 16px 32px;
  }
}

@media (max-width: 600px) {
  .wrap {
    padding: 8px 12px calc(24px + env(safe-area-inset-bottom));
  }
}

/* Touch targets enforce >= 44px for primary interactions */
button,
a.btn,
.tgl,
.szb,
.ic {
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  touch-action: manipulation;
}

/* --------------------------------------------------------------------------
   2. BERANDA TABS OVERHAUL (.tabs)
   Smooth horizontal scrolling on mobile; neat alignment on desktop.
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 5px;
  margin-top: 14px;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  flex: 0 0 auto;
  min-width: max-content;
  min-height: var(--touch-target);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
  user-select: none;
}

.tabs button:hover {
  color: var(--txt);
}

.tabs button.on {
  background: linear-gradient(135deg, var(--gold-btn) 55%, color-mix(in srgb, var(--gold-btn) 84%, #000 16%));
  color: var(--on-gold);
  font-weight: 700;
  box-shadow: 0 2px 8px var(--shadow);
}

/* Indikator "masih ada tab di luar layar": tepi memudar saat strip bisa digeser.
   Kelas sc-l / sc-r dipasang oleh JS (tabsCue di app.js) sesuai posisi geser. */
.tabs.sc-l,
.tabs.sc-r {
  mask-image: linear-gradient(to right, transparent 0, #000 30px, #000 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 30px, #000 100%);
}
.tabs.sc-r {
  mask-image: linear-gradient(to left, transparent 0, #000 30px, #000 100%);
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 30px, #000 100%);
}
.tabs.sc-l.sc-r {
  mask-image: linear-gradient(to right, transparent 0, #000 30px, #000 calc(100% - 30px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 30px, #000 calc(100% - 30px), transparent 100%);
}

.tabs button:active {
  transform: scale(0.98);
}

/* Tablet & Desktop tabs layout */
@media (min-width: 768px) {
  .tabs {
    overflow-x: visible;
  }
  .tabs button {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 8px;
  }
}

/* --------------------------------------------------------------------------
   3. SURAH & JUZ GRID RESPONSIVE OVERHAUL
   -------------------------------------------------------------------------- */
.surah-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.scard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  color: inherit;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 58px;
}

.scard:hover {
  border-color: var(--accent);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px var(--shadow);
}

.snum {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--gold);
  font-size: 13px;
}

@media (min-width: 601px) and (max-width: 1023px) {
  .surah-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

@media (min-width: 820px) and (max-width: 1023px) {
  .surah-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
}

@media (min-width: 1024px) {
  .surah-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

@media (min-width: 1280px) {
  .surah-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
}

@media (max-width: 600px) {
  .surah-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .scard {
    padding: 10px 10px;
    gap: 9px;
  }
  .snum {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .surah-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   4. KARTU AYAT HARI INI (DAILY VERSE)
   -------------------------------------------------------------------------- */
.daily-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 18px 20px 20px;
  margin-top: 14px;
  margin-bottom: 6px;
  box-shadow: 0 4px 20px var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .daily-card {
  background: linear-gradient(175deg, #131d33 0%, #0f1729 100%);
  border-color: #263659;
}

[data-theme="light"] .daily-card {
  background: linear-gradient(175deg, #ffffff 0%, #f4f6fb 100%);
  border-color: #d6dded;
  box-shadow: 0 6px 24px rgba(24, 33, 58, 0.08);
}

[data-theme="sepia"] .daily-card {
  background: linear-gradient(175deg, #faf3e2 0%, #f2e7cd 100%);
  border-color: #d8c79e;
  box-shadow: 0 6px 24px rgba(58, 46, 26, 0.08);
}

.daily-card:hover {
  border-color: var(--gold);
}

/* Header kartu: badge & tanggal */
.daily-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.daily-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(232, 199, 119, 0.12);
  border: 1px solid rgba(232, 199, 119, 0.35);
  color: var(--gold);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

[data-theme="light"] .daily-badge {
  background: rgba(148, 101, 0, 0.08);
  border-color: rgba(148, 101, 0, 0.25);
}

.daily-badge-icon {
  font-size: 14px;
  line-height: 1;
}

.daily-date {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

/* Tag rujukan surat & ayat */
.daily-surah-tag {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.daily-surah-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--txt);
  text-decoration: none;
  font-weight: 700;
  font-size: 15.5px;
}

.daily-surah-title:hover {
  color: var(--accent);
}

.daily-surah-num {
  color: var(--gold);
}

.daily-surah-meta {
  font-size: 12.5px;
  color: var(--muted);
}

/* Renungan / Refleksi Callout */
.daily-refleksi {
  background: rgba(91, 141, 239, 0.07);
  border-left: 3.5px solid var(--gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 10px 14px;
  margin-bottom: 16px;
}

[data-theme="light"] .daily-refleksi {
  background: rgba(42, 95, 207, 0.05);
}

[data-theme="sepia"] .daily-refleksi {
  background: rgba(138, 90, 0, 0.06);
}

.daily-refleksi-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.daily-refleksi-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--tafsir-txt);
  font-style: italic;
}

/* Teks Arab Utsmani Daily */
.daily-arab {
  direction: rtl;
  text-align: right;
  font-family: var(--arfont);
  font-size: calc(clamp(25px, 14px + 2.6vw, 38px) * var(--ar));
  line-height: 2.05;
  color: var(--ar-txt);
  padding: 6px 2px 10px;
  word-spacing: 2px;
  unicode-bidi: isolate;
}

/* Terjemah Kemenag Daily */
.daily-terj {
  font-size: calc(14.5px * var(--tf));
  line-height: 1.7;
  color: var(--terj-txt);
  margin-bottom: 18px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

/* Tombol aksi daily card */
.daily-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 8px;
}

.daily-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--txt);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  min-height: var(--touch-target);
  transition: all 0.16s ease;
  cursor: pointer;
  user-select: none;
}

.daily-btn .i {
  width: 17px;
  height: 17px;
}

.daily-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.daily-btn:active {
  transform: translateY(0);
}

.daily-btn-tafsir {
  background: rgba(91, 141, 239, 0.12);
  border-color: rgba(91, 141, 239, 0.35);
  color: var(--accent);
}

.daily-btn-tafsir:hover {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.daily-btn-play {
  background: rgba(232, 199, 119, 0.12);
  border-color: rgba(232, 199, 119, 0.35);
  color: var(--gold);
}

.daily-btn-play:hover {
  background: var(--gold-btn);
  color: var(--on-gold);
  border-color: var(--gold-btn);
}

@media (max-width: 600px) {
  .daily-card {
    padding: 14px 14px 16px;
    border-radius: var(--radius-lg);
  }
  .daily-header {
    margin-bottom: 10px;
  }
  .daily-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    width: 100%;
  }
  .daily-btn {
    width: 100%;
    padding: 9px 8px;
    font-size: 12.5px;
  }
}

/* --------------------------------------------------------------------------
   5. DOA AL-QUR'AN RESPONSIVE STYLING
   -------------------------------------------------------------------------- */
.doa-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

/* Category filter chips */
.doa-category-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 2px;
}

.doa-category-chips::-webkit-scrollbar {
  display: none;
}

.doa-chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.16s ease;
}

.doa-chip:hover {
  border-color: var(--accent);
  color: var(--txt);
}

.doa-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* Doa Grid layout */
.doa-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 10px;
}

@media (min-width: 768px) {
  .doa-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

@media (min-width: 1140px) {
  .doa-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* Doa Card */
.doa-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.doa-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--shadow);
}

.doa-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.doa-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.35;
}

.doa-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.doa-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--gold);
}

.doa-source {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.doa-source:hover {
  text-decoration: underline;
}

.doa-arab {
  direction: rtl;
  text-align: right;
  font-family: var(--arfont);
  font-size: calc(clamp(22px, 12px + 2.2vw, 32px) * var(--ar));
  line-height: 1.95;
  color: var(--ar-txt);
  padding: 4px 0 6px;
}

.doa-latin {
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.55;
}

.doa-terj {
  font-size: calc(14px * var(--tf));
  line-height: 1.65;
  color: var(--terj-txt);
}

.doa-fadhilah {
  background: var(--panel2);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  border-left: 3px solid var(--accent);
}

.doa-actions {
  display: flex;
  gap: 7px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.doa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--txt);
  font-size: 12.5px;
  font-weight: 600;
  min-height: 38px;
  cursor: pointer;
}

.doa-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   6. KHATAM TRACKER RESPONSIVE STYLING
   -------------------------------------------------------------------------- */
.khatam-dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 14px;
}

/* Hero Progress Card */
.khatam-progress-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  box-shadow: 0 4px 20px var(--shadow);
}

.khatam-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.khatam-progress-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--txt);
}

.khatam-progress-pct {
  font-size: 24px;
  font-weight: 800;
  color: var(--gold);
}

/* Progress bar */
.khatam-progress-bar {
  height: 10px;
  background: var(--panel2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}

.khatam-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--gold) 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Stats grid */
.khatam-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 680px) {
  .khatam-stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

.khatam-stat-box {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: center;
}

.khatam-stat-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}

.khatam-stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* Mode Switcher Tabs */
.khatam-mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 4px;
}

.khatam-mode-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  min-height: 38px;
}

.khatam-mode-tabs button.on {
  background: var(--panel);
  color: var(--txt);
  box-shadow: 0 1px 4px var(--shadow);
}

/* Juz Grid (30 items) */
.khatam-juz-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (min-width: 500px) {
  .khatam-juz-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }
}

@media (min-width: 768px) {
  .khatam-juz-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
  }
}

@media (min-width: 1024px) {
  .khatam-juz-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 10px;
  }
}

.khatam-juz-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.16s ease;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.khatam-juz-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.khatam-juz-item.done {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-txt);
}

.khatam-juz-num {
  font-size: 14px;
  font-weight: 700;
}

.khatam-juz-status {
  font-size: 11px;
  margin-top: 2px;
  opacity: 0.85;
}

/* Page Grid (604 items / mini chips) */
.khatam-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.khatam-page-chip {
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.khatam-page-chip:hover {
  border-color: var(--accent);
  color: var(--txt);
}

.khatam-page-chip.done {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-txt);
  font-weight: 700;
}

/* Action row */
.khatam-action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   7. POLISH & VISUAL HARMONY
   -------------------------------------------------------------------------- */
/* Smooth touch bounce and scroll physics */
html {
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
}

/* Selection highlights */
::selection {
  background: rgba(91, 141, 239, 0.35);
  color: inherit;
}

/* Note box enhancement */
.note {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  line-height: 1.6;
}

/* Tab panel enter transition (smooth switch) */
@keyframes tabin {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.tabin { animation: tabin 0.18s ease; }
@media (prefers-reduced-motion: reduce) {
  .tabin { animation: none; }
}
