/* ============ Waktu Solat MY — Styles ============ */
:root {
  --bg: #071c14;
  --surface: #0b3d2e;
  --surface-2: #0e4a38;
  --accent: #4ade80;
  --accent-soft: rgba(74, 222, 128, 0.15);
  --text: #f0fdf4;
  --text-dim: #a7d7bd;
  --border: rgba(74, 222, 128, 0.2);
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(74, 222, 128, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(45, 212, 191, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1.25rem 1rem 2rem;
}

.app { width: 100%; max-width: 480px; }

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.5rem; }

.brand-icon { font-size: 1.75rem; }

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand h1 .brand-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-accent {
  color: var(--accent);
  margin-left: 0.3rem;
}

.location-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 38px;
  padding: 0 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.lang-btn:hover { background: var(--surface-2); color: var(--accent); }
.lang-btn:active { transform: scale(0.94); }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.locate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.locate-btn:hover { background: var(--surface-2); }
.locate-btn:active { transform: scale(0.94); }
.locate-btn.active {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.select-wrap select {
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234ade80' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  max-width: 190px;
}

.select-wrap select:focus,
.locate-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.location-status {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  min-height: 1.1em;
}

.location-status.error { color: #fca5a5; }

/* ---------- Next prayer card ---------- */
.next-prayer-card {
  margin-top: 1rem;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.np-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.np-name {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 0.35rem;
  color: var(--accent);
}

.np-time {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.np-countdown {
  margin-top: 0.6rem;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  display: inline-block;
  padding: 0.35rem 1.1rem;
  border: 1px solid var(--border);
}

.np-dates {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.np-dates .dot { opacity: 0.5; }

/* ---------- Panel notifikasi ---------- */
.notif-panel {
  margin-top: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.notif-info strong { font-size: 0.95rem; display: block; }

.notif-info p {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* Suis togol */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .slider { background: var(--accent-soft); }
.switch input:checked + .slider::before {
  transform: translateY(-50%) translateX(20px);
  background: var(--accent);
}
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Baris bunyi notifikasi */
.sound-row {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.sound-label {
  font-size: 0.85rem;
  color: var(--text);
}

.sound-select {
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.sound-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Baris notifikasi seterusnya */
.notif-next {
  margin-top: 0.75rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.test-btn {
  margin-top: 0.85rem;
  width: 100%;
  padding: 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.test-btn:hover { background: var(--accent-soft); color: var(--accent); }

.notif-status {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  min-height: 1.1em;
}

.notif-status.error { color: #fca5a5; }

.notif-btn.active { color: var(--accent); }

/* Butang muat semula — animasi putar semasa dimuat semula */
.locate-btn.spinning svg { animation: spin 0.6s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Onboarding (kunjungan pertama) ---------- */
.onboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 20, 14, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

/* `hidden` mesti menang — jika tidak overlay menghalang klik walaupun tertutup */
.onboard-overlay[hidden] { display: none; }

.onboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.7rem 1.4rem 1.3rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  max-height: 88dvh;
  overflow-y: auto;
}

.ob-icon { font-size: 2.2rem; display: block; }

.onboard-card h2 { margin: 0.4rem 0 0.9rem; font-size: 1.25rem; }

.ob-benefit { font-weight: 600; font-size: 0.95rem; }

.ob-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0.4rem 0 1.1rem;
  line-height: 1.45;
}

.ob-primary,
.ob-secondary {
  display: block;
  width: 100%;
  padding: 0.75rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.6rem;
  transition: filter 0.2s, background 0.2s;
}

.ob-primary {
  background: var(--accent);
  color: #06281c;
  border: none;
  font-weight: 700;
}

.ob-primary:hover { filter: brightness(1.1); }

.ob-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.ob-secondary:hover { background: var(--accent-soft); }

.ob-skip {
  background: none;
  border: none;
  color: var(--text-dim);
  margin-top: 1.1rem;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* Titik merah pada loceng */
.notif-btn { position: relative; }

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid var(--bg);
}

/* Sorotan pemilih kawasan selepas onboarding "pilih sendiri" */
select.highlight { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Times list ---------- */
.times-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  transition: border-color 0.2s;
}

.time-row.active {
  border-color: var(--accent);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
}

.time-row .tr-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.time-row .tr-icon { font-size: 1.15rem; width: 1.6rem; text-align: center; }

.time-row .tr-name { font-weight: 600; font-size: 0.98rem; }

.time-row .tr-time {
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.time-row.active .tr-time { color: var(--accent); }

.time-row .tr-tag {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  border: 1px solid var(--border);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin-left: 0.6rem;
  vertical-align: middle;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 1.75rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  opacity: 0.8;
  line-height: 1.5;
}

/* ---------- Tetapan: bottom sheet (lokasi + notifikasi) ---------- */
body.no-scroll { overflow: hidden; }

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 20, 14, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
}

.settings-overlay[hidden] { display: none; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 1.1rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: sheet-up 0.25s ease-out;
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.settings-header h2 { font-size: 1.1rem; }

.settings-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-close:hover { background: var(--accent-soft); color: var(--accent); }
.settings-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.settings-section { margin-top: 0.8rem; }

.settings-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.settings-location-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.settings-location-row .select-wrap { flex: 1 1 160px; }

.settings-location-row select { width: 100%; max-width: none; }

.locate-wide {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.locate-wide:hover { background: var(--accent-soft); color: var(--accent); }
.locate-wide.active {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.settings-card .notif-panel {
  margin-top: 0;
  box-shadow: none;
  background: var(--surface-2);
}

.settings-btn { position: relative; }
.settings-btn.active { color: var(--accent); }

/* Petunjuk “Tambah ke Skrin Utama” (iPhone/iPad) */
.a2hs {
  margin-top: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  font-size: 0.78rem;
  text-align: left;
  line-height: 1.5;
}

.a2hs[hidden] { display: none; }

.a2hs .a2hs-title { display: block; color: #fcd34d; margin-bottom: 0.3rem; }

.a2hs ol { padding-left: 1.2rem; }

.a2hs li { margin-top: 0.15rem; }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 380px) {
  .np-name { font-size: 1.6rem; }
  .header { justify-content: center; }
}
