/* quick-input.css — FAB Beranda + bottom sheet input cepat */

/* ---------- FAB ---------- */
.quick-fab {
  position: fixed;
  right: 20px;
  bottom: 86px; /* tinggi bottom nav 74px + jarak 12px */
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 999;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--emerald);
  color: #fff;
  box-shadow: var(--shadow-fab);
  transition: transform .14s ease, background .14s ease;
}

/* Di layar lebar #app tetap 430px di tengah — FAB ikut kolom aplikasi. */
@media (min-width: 470px) {
  .quick-fab { right: calc((100vw - 430px) / 2 + 20px); }
}
.quick-fab::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(18, 113, 90, .18);
  border-radius: 50%;
  pointer-events: none;
}
.quick-fab:active {
  background: var(--deep-2);
  transform: scale(.94);
}

/* FAB tampil di semua tab, kecuali Pengaturan. */
body[data-route="pengaturan"] .quick-fab { display: none; }

/* Sembunyikan FAB saat bottom sheet terbuka (Input Cepat / Pilih Lokasi) */
body.is-sheet-open .quick-fab,
body.is-modal-open .quick-fab { display: none !important; }

/* Tab yang kini memakai FAB butuh ruang bawah ekstra supaya kontrol
   terakhir tidak tertutup tombol (FAB: 56px + 80px dari dasar). */
body[data-route="checklist"] .page,
body[data-route="hutang"] .page,
body[data-route="progress"] .page {
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

/* Ruang ekstra di dasar halaman: kartu terakhir (7 Hari Terakhir)
   tetap bisa di-scroll sampai bersih di atas FAB. */
.home-page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- bottom sheet ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 1000; /* di atas FAB (999) agar FAB tidak menembus backdrop */
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none !important; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 20, 15, .46);
  opacity: 0;
  transition: opacity .22s ease;
}
.sheet.is-open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(430px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  border-radius: 26px 26px 0 0;
  background: var(--bg);
  box-shadow: 0 -18px 42px rgba(4, 20, 15, .24);
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet.is-open .sheet-panel { transform: translateY(0); }

.sheet-grab {
  flex: 0 0 auto;
  width: 40px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: var(--r-pill);
  background: var(--line);
}

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px 12px;
}
.sheet-head-copy { min-width: 0; }
.sheet-head-copy h2 {
  margin-top: 2px;
  font-size: var(--fs-24);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.4px;
}
.qs-title-sub {
  color: var(--muted);
  font-size: var(--fs-11);
  font-weight: 650;
  letter-spacing: 0;
  white-space: nowrap;
}
.sheet-head-copy p {
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--fs-12);
  line-height: 1.45;
}
.sheet-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-card);
}
.sheet-close:active { background: var(--surface-2); }

/* ---------- form (area yang bisa di-scroll) ---------- */
.quick-form {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 80vh;
  max-height: 80dvh;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 2px 20px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.qs-block {
  padding: 14px 12px 12px;
  border: 1px solid rgba(230, 234, 231, .7);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.qs-block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}
.qs-block-head h3 {
  font-size: var(--fs-17);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -.2px;
}
.qs-block-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--fs-11);
  line-height: 1.4;
}
.qs-chip {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: var(--r-pill);
  background: var(--mint-soft-2);
  color: var(--emerald-2);
  font-size: var(--fs-10);
  font-weight: 800;
  white-space: nowrap;
}
.qs-chip.is-gold {
  background: var(--gold-soft);
  color: var(--amber-ink);
}

.qs-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.qs-grid.is-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.qs-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.qs-time {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--fs-10);
  font-weight: 750;
  letter-spacing: 0;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* toggle 3-state */
.qs-seg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.qs-seg-btn {
  min-height: 46px;
  padding: 0 1px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  /* 15px: "Tinggal"/"Sendiri" tetap utuh di kolom 1/5 sheet (~60px). */
  font-size: 15px;
  font-weight: 750;
  line-height: 1.1;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.qs-seg-btn:active { transform: scale(.96); }
.qs-seg-btn.is-masjid.is-active {
  border-color: var(--mint);
  background: var(--mint-soft-2);
  color: var(--emerald-2);
}
.qs-seg-btn.is-sendiri.is-active {
  border-color: var(--gold-d);
  background: var(--gold-soft);
  color: var(--amber-ink);
}
.qs-seg-btn.is-tinggal.is-active {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

/* stepper qadha & shalat sunnah — nilai penuh di atas, tombol −/+
   di bawah supaya angka tetap terbaca di kolom yang sempit. */
.qs-stepper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-items: stretch;
}
.qs-stepper button {
  grid-row: 2;
  display: grid;
  place-items: center;
  height: 44px;
  padding: 0;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}
.qs-stepper button[data-quick-step="1"],
.qs-stepper button[data-amalan-step="1"] {
  background: var(--mint-soft);
  color: var(--emerald);
}
.qs-stepper button[data-quick-step="-1"],
.qs-stepper button[data-amalan-step="-1"] {
  background: var(--danger-soft);
  color: var(--danger);
}
.qs-stepper button:disabled {
  opacity: .35;
  transform: none;
}
.qs-stepper output {
  grid-column: 1 / -1;
  grid-row: 1;
  display: grid;
  place-items: center;
  height: 42px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--fs-16);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
}
.qs-sisa {
  overflow: hidden;
  color: var(--muted-3);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- section C–E: field teks & angka ---------- */
.qs-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qs-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.qs-field {
  gap: 5px;
}
.qs-field > span {
  color: var(--ink-2);
  font-size: var(--fs-13);
  font-weight: 650;
  letter-spacing: 0;
}
.qs-field input,
.qs-field select,
.qs-field textarea {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: var(--fs-16);
}
.qs-field select { padding-right: 8px; }

/* Petunjuk jumlah ayat + validasi rentang ayat. */
.qs-ayat-hint {
  color: var(--emerald-2);
  font-size: var(--fs-11);
  font-weight: 650;
  line-height: 1.35;
}
.qs-field input.is-invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 3px rgba(176, 74, 62, .1);
}
.qs-field textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.45;
}
/* Spinner bawaan browser disembunyikan; angka diketik langsung. */
.qs-field input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.qs-field input[type="number"]::-webkit-outer-spin-button,
.qs-field input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* ---------- section F: azan ---------- */
.qs-azan {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.qs-azan-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1.5px solid transparent;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-13);
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.qs-azan-item input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--emerald);
}
.qs-azan-item:has(input:checked) {
  border-color: var(--mint);
  background: var(--mint-soft-2);
  color: var(--emerald-2);
}
.qs-azan-item:has(input:focus-visible) {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}

/* Footer simpan berdiri di luar area scroll, jadi tombol tidak pernah
   tertutup konten section A–E. */
.qs-save-wrap {
  flex: 0 0 auto;
  padding: 10px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 -8px 16px rgba(11, 61, 46, .05);
}
.qs-save { margin-top: 0; }

body.is-sheet-open { overflow: hidden; }

@media (max-width: 360px) {
  .sheet-head { padding-left: 14px; padding-right: 14px; }
  .sheet-head-copy h2 { font-size: 26px; }
  .quick-form { padding-left: 14px; padding-right: 14px; }
  .qs-block { padding-left: 9px; padding-right: 9px; }
  .qs-grid { gap: 4px; }
  .qs-grid.is-3 { gap: 5px; }
  .qs-time { font-size: var(--fs-10); }
  .qs-seg-btn { min-height: 44px; font-size: 15px; }
  .qs-stepper { grid-template-columns: 1fr 1fr; gap: 3px; }
  .qs-stepper button { height: 40px; font-size: 21px; }
  .qs-stepper output { height: 38px; font-size: var(--fs-13); }
  .qs-sisa { font-size: 13px; }
  .qs-save-wrap {
    padding-left: 14px;
    padding-right: 14px;
  }
  .qs-field-row { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-panel,
  .sheet-backdrop,
  .quick-fab { transition: none; }
}
