/* Hakhagi — Typography-first, anti-slop */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-hover: #F5F4F0;
  --border: #E8E4DE;
  --text: #1A1A1A;
  --text-muted: #6B6560;
  --text-subtle: #9E9892;
  --primary: #8B7355;
  --primary-hover: #7A6548;
  --primary-soft: rgba(139, 115, 85, 0.1);
  --accent: #C8A96E;
  --accent-soft: rgba(200, 169, 110, 0.12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.04);
  --shadow-card: 0 1px 4px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

.dark {
  --bg: #141312;
  --surface: #1C1B1A;
  --surface-hover: #242322;
  --border: #2E2C2A;
  --text: #EDEBE8;
  --text-muted: #9E9892;
  --text-subtle: #6B6560;
  --primary: #C8A96E;
  --primary-hover: #D4B683;
  --primary-soft: rgba(200, 169, 110, 0.12);
  --accent: #8B7355;
  --accent-soft: rgba(139, 115, 85, 0.18);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-card: 0 1px 4px rgba(0,0,0,0.4);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* Arabic font */
.font-arabic {
  font-family: 'Noto Naskh Arabic', 'Amiri', 'Traditional Arabic', 'Scheherazade New', 'Uthmanic Hafs', serif;
  font-weight: 400;
  line-height: 2.1;
  direction: rtl;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
  overflow: hidden;
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
}

.card-hover { cursor: pointer; }
.card-hover:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.dark .card-hover:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}

.badge-primary {
  background: var(--primary);
  color: white;
  border: none;
}

/* Bottom Nav */
nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
}

nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color 150ms ease, background 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

nav button:hover { color: var(--text-muted); }

nav button.active {
  color: var(--primary);
  background: var(--primary-soft);
}

nav button i { width: 20px; height: 20px; }

/* Container */
#content {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 88px;
}

/* Segmented control active */
.font-size-btn { color: var(--text-muted); background: var(--surface-hover); }
.font-size-btn.active { color: white; background: var(--primary); border-color: var(--primary); }
.dark .font-size-btn.active { color: #0B1120; background: var(--primary); }

/* Note editor */
.note-editor {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  border: 1px solid var(--border);
}
.note-editor textarea {
  width: 100%;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.note-editor textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.btn-soft {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all 150ms;
}
.btn-soft:hover { background: var(--border); }
.btn-primary {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: var(--primary);
  color: white;
  transition: all 150ms;
}
.dark .btn-primary { color: #0B1120; }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Typography scale — adjustable via data-font-size */
:root { --fs: 1; }

body[data-font-size="small"] { --fs: 0.875; }
body[data-font-size="large"] { --fs: 1.125; }

.text-xs { font-size: calc(0.75rem * var(--fs)); line-height: 1.4; }
.text-sm { font-size: calc(0.875rem * var(--fs)); line-height: 1.5; }
.text-base { font-size: calc(1rem * var(--fs)); line-height: 1.6; }
.text-lg { font-size: calc(1.125rem * var(--fs)); line-height: 1.5; }
.text-xl { font-size: calc(1.25rem * var(--fs)); line-height: 1.4; }
.text-2xl { font-size: calc(1.5rem * var(--fs)); line-height: 1.3; }
.text-3xl { font-size: calc(1.875rem * var(--fs)); line-height: 1.2; }
.text-4xl { font-size: calc(2.25rem * var(--fs)); line-height: 1.1; }

/* Quran & Hadits text (not affected by font scale) */

.font-mono {
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Spacing system (8px grid) */
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }
.space-y-5 > * + * { margin-top: 20px; }
.space-y-6 > * + * { margin-top: 24px; }

/* Flex & Grid */
.flex { display: flex; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-2\\.5 { gap: 10px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Borders */
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-none { border: none; }

/* Utilities */
.rounded-xl { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-sm); }
.rounded-full { border-radius: 9999px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leading-snug { line-height: 1.4; }
.leading-relaxed { line-height: 1.625; }
.leading-loose { line-height: 1.8; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.uppercase { text-transform: uppercase; }
.transition { transition: all 150ms ease; }
.opacity-40 { opacity: 0.4; }
.opacity-60 { opacity: 0.6; }

/* Spacing helpers */
.w-full { width: 100%; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-2\\.5 { padding-top: 10px; padding-bottom: 10px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* Dzikir tabs */
.tab-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-subtle);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
}
.tab-btn:hover { color: var(--text-muted); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Dzikir card padding */
.dzikir-card { padding: 16px; }

/* Counter disabled */
.counter-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Kategori label */
.kat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}


/* Search input */
.search-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.search-input::placeholder { color: var(--text-subtle); }
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ============================================================
   THEME: Warp (NeedMCP) — warm cream editorial
   Applied via body.theme-warp. Default Hakhagi theme = no class.
   ============================================================ */
.theme-warp {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-hover: #f1efea;
  --border: #e8e6e0;
  --text: #1a1a18;
  --text-muted: #5a5a58;
  --text-subtle: #9a9997;
  --primary: #1E3A5F;          /* navy identity retained */
  --primary-hover: #2A4A6F;
  --primary-soft: rgba(30, 58, 95, 0.08);
  --accent: #C8A96E;           /* gold mapped from taupe */
  --accent-soft: rgba(200, 169, 110, 0.12);
}

.theme-warp.dark {
  --bg: #0e0e0d;
  --surface: #161615;
  --surface-hover: #1a1a19;
  --border: rgba(226, 226, 226, 0.08);
  --text: #faf9f6;
  --text-muted: #afaeac;
  --text-subtle: #868584;
  --primary: #C8A96E;          /* gold in dark, like Hakhagi */
  --primary-hover: #D4B683;
  --primary-soft: rgba(200, 169, 110, 0.12);
  --accent: #1E3A5F;
  --accent-soft: rgba(30, 58, 95, 0.18);
}

/* Warp: more generous card padding (editorial pacing) */
.theme-warp .card { padding: 20px; }
@media (min-width: 480px) {
  .theme-warp .card { padding: 24px; }
}

/* Theme picker button (Settings) */
.theme-btn {
  color: var(--text-muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
}
.theme-btn.active {
  color: white;
  background: var(--primary);
  border-color: var(--primary);
}
.theme-warp.dark .theme-btn.active { color: #0e0e0d; }

/* ═══════════════════════════════════════
   Additional UI — Sholat, Quran, Hadits
   ═══════════════════════════════════════ */

.sholat-time-box {
  text-align: center; padding: 14px 6px; border-radius: 10px;
  background: var(--surface-hover); border: 1px solid var(--border);
  position: relative;
}
.sholat-time-box .label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.sholat-time-box .time { font-size: calc(1.3rem * var(--fs)); font-weight: 600; color: var(--text); direction: ltr; }
.sholat-time-box .time.highlight { color: var(--primary); }
.sholat-time-box .remaining { font-size: 0.6rem; color: var(--accent); margin-top: 2px; font-weight: 500; }
.sholat-time-box.active { border-color: var(--primary); background: var(--primary-soft); }

.month-table { width: 100%; border-collapse: collapse; font-size: calc(0.7rem * var(--fs)); }
.month-table th { padding: 6px 2px; text-align: center; color: var(--text-subtle); font-weight: 500; font-size: 0.65rem; border-bottom: 1px solid var(--border); }
.month-table td { padding: 6px 2px; text-align: center; vertical-align: top; border-bottom: 1px solid var(--border); }
.month-table td.today { background: var(--primary-soft); border-radius: 8px; }
.month-table td.active .day-num { font-weight: 600; color: var(--primary); }
.month-table .day-num { font-size: calc(0.8rem * var(--fs)); font-weight: 500; }
.month-table .day-prayer { font-size: 0.55rem; color: var(--text-subtle); margin-top: 1px; }

.surah-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.surah-item:last-child { border-bottom: none; }
.surah-item:hover { background: var(--surface-hover); }
.surah-num { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); border-radius: 50%; font-size: 0.75rem; font-weight: 600; color: var(--primary); flex-shrink: 0; }
.surah-name { font-weight: 600; font-size: calc(0.9rem * var(--fs)); }

.ayat-arab { font-family: 'Noto Naskh Arabic', 'Amiri', serif; font-size: calc(1.5rem * var(--fs)); line-height: 2.2; text-align: right; direction: rtl; }
.ayat-latin { font-style: italic; color: var(--text-subtle); }
.ayat-terj { font-size: calc(0.85rem * var(--fs)); color: var(--text-muted); line-height: 1.7; }

.hadits-book { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.hadits-book:last-child { border-bottom: none; }
.hadits-book:hover { background: var(--surface-hover); }
.hadits-arab { font-family: 'Noto Naskh Arabic', 'Amiri', serif; font-size: calc(1.2rem * var(--fs)); line-height: 2; text-align: right; direction: rtl; }
.hadits-terj { font-size: calc(0.85rem * var(--fs)); color: var(--text-muted); line-height: 1.7; }

.dzikir-card { padding: 16px; }
.dzikir-card .dzikir-arab { font-family: 'Noto Naskh Arabic', 'Amiri', serif; font-size: calc(1.2rem * var(--fs)); line-height: 2; text-align: right; direction: rtl; margin-bottom: 8px; }
.counter-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--primary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.counter-btn:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
.counter-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.search-input { width: 100%; padding: 11px 14px; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 0.875rem; font-family: inherit; color: var(--text); outline: none; transition: border-color 150ms, box-shadow 150ms; }
.search-input::placeholder { color: var(--text-subtle); }
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.btn-soft { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); transition: all 150ms; }
.btn-soft:hover { background: var(--border); }

.font-size-btn { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; font-size: 0.8rem; color: var(--text-muted); background: var(--surface-hover); transition: all 0.15s; }
.font-size-btn.active { color: white; background: var(--primary); border-color: var(--primary); }
.dark .font-size-btn.active { color: #0B1120; }

/* ═══════════════════════════════════════
   Sholat — Clean comfortable UI
   ═══════════════════════════════════════ */

.next-prayer-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white; border-radius: 16px; padding: 28px 20px 24px;
  text-align: center; position: relative; overflow: hidden;
}
.next-prayer-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(200,169,110,0.2) 0%, transparent 60%);
}
.next-prayer-card > * { position: relative; }
.next-prayer-card .next-label { font-size: 0.65rem; font-weight: 500; opacity: 0.7; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 6px; }
.next-prayer-card .next-name { font-size: 1.3rem; font-weight: 600; opacity: 0.9; }
.next-prayer-card .next-time { font-size: 2.8rem; font-weight: 700; line-height: 1.05; letter-spacing: -1px; margin: 2px 0; }
.next-prayer-card .next-countdown { 
  display: inline-block; background: rgba(255,255,255,0.12);
  padding: 4px 16px; border-radius: 20px;
  font-size: 0.8rem; font-weight: 500; margin-top: 8px;
}
.next-prayer-card .current-time-display {
  margin-top: 12px; font-size: 0.7rem; opacity: 0.35;
  font-family: monospace; letter-spacing: 1px;
}

/* 5 Prayer Times — Clean pill style */
.prayer-grid-5 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.prayer-item {
  text-align: center; padding: 16px 8px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.prayer-item.next {
  background: var(--primary-soft); border-color: var(--primary);
}
.prayer-item.past { opacity: 0.45; }
.prayer-item .prayer-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.prayer-item .prayer-time { font-size: calc(1.3rem * var(--fs)); font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.prayer-item.next .prayer-time { color: var(--primary); }
.prayer-item .prayer-remaining { font-size: 0.6rem; color: var(--primary); font-weight: 600; margin-top: 4px; }

/* Info row */
.info-row { display: flex; justify-content: center; gap: 20px; }
.info-row span { font-size: 0.75rem; color: var(--text-muted); }
.info-row strong { color: var(--text); font-weight: 600; }

/* Calendar — Clean grid */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-header { text-align: center; font-size: 0.6rem; color: var(--text-subtle); font-weight: 500; padding: 6px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.cal-cell { text-align: center; padding: 6px 2px; border-radius: 10px; min-height: 38px; transition: background 0.15s; }
.cal-cell.cal-today { background: var(--primary-soft); }
.cal-cell.cal-empty { visibility: hidden; }
.cal-date { font-size: calc(0.8rem * var(--fs)); font-weight: 500; color: var(--text); line-height: 1.3; }
.cal-date-today { color: var(--primary); font-weight: 700; }
.cal-maghrib { font-size: 0.5rem; color: var(--text-subtle); margin-top: 1px; }

@media (max-width: 380px) {
  .prayer-grid-5 { gap: 6px; }
  .prayer-item { padding: 12px 4px; }
  .prayer-item .prayer-time { font-size: calc(1.1rem * var(--fs)); }
  .next-prayer-card { padding: 20px 14px 18px; }
  .next-prayer-card .next-time { font-size: 2.2rem; }
  .info-row { gap: 12px; }
}
