/* =====================================================================
   Fokusin - CSS murni (tanpa framework)
   Prinsip desain: tenang, kontras cukup, ruang lega, minim animasi.
   ===================================================================== */

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #1d2321;
  --ink-soft: #55635f;
  --muted: #8b9894;
  --line: #e4eae8;
  --brand: #0f766e;
  --brand-soft: #e6f4f2;
  --brand-ink: #0b5c55;
  --warn-bg: #fff8e6;
  --warn-line: #f5e2b0;
  --warn-ink: #8a6516;
  --danger: #c0392b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 34, 30, .04), 0 4px 14px rgba(16, 34, 30, .05);
  --maxw: 40rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  /* aman untuk notch / gesture bar Android */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem 1rem 6rem;
}

/* ---------- Tipografi ---------- */
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.15rem; }
h2 { font-size: .95rem; }
p  { margin: 0 0 .75rem; }
a  { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.tiny  { font-size: .72rem; }

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.1rem;
}
.topbar .brand-kicker {
  font-size: .68rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}
.topbar-actions { display: flex; gap: .5rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: #f7faf9; }

/* ---------- Kartu ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .85rem;
  box-shadow: var(--shadow);
}
.card > h2 { margin-bottom: .6rem; }
.card-flush { padding: .9rem 1rem; }

/* ---------- Navigasi tanggal ---------- */
.datenav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.datenav .date-label { text-align: center; flex: 1; }
.datenav .date-label strong { display: block; font-size: .95rem; font-weight: 600; }
.datenav a.nav-arrow {
  text-decoration: none;
  color: var(--ink-soft);
  width: 2.25rem; height: 2.25rem;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
}
.datenav a.nav-arrow:hover { background: #f1f5f4; }

.progress-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-top: .8rem;
  font-size: .78rem; color: var(--muted);
}
.progress-track { flex: 1; max-width: 11rem; height: 6px; background: #eef2f1; border-radius: 99px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--brand); border-radius: 99px; transition: width .25s ease; }

/* ---------- Blok jam ---------- */
.hour-block { position: relative; }
.hour-block.is-now { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow); }
.hour-block.is-past { opacity: .62; }

.hour-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem; }
.hour-chip {
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: #f1f5f4; color: var(--ink-soft);
  padding: .2rem .55rem; border-radius: 99px;
}
.hour-block.is-now .hour-chip { background: var(--brand); color: #fff; }
.now-tag { font-size: .72rem; font-weight: 600; color: var(--brand); }

/* ---------- Daftar item ---------- */
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }

.item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .4rem;
  border-radius: var(--radius-sm);
}
.item:hover { background: #f8faf9; }

/* Tombol centang besar supaya mudah ditekan di HP */
.check {
  flex: 0 0 auto;
  width: 1.5rem; height: 1.5rem;
  border: 2px solid #cdd8d5;
  border-radius: 50%;
  background: transparent;
  color: transparent;
  display: grid; place-items: center;
  font-size: .7rem; line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background-color .12s ease, border-color .12s ease;
}
.check:hover { border-color: var(--brand); }
.item.done .check { background: var(--brand); border-color: var(--brand); color: #fff; }

.item-icon { font-size: 1.05rem; line-height: 1; }
.item-title { flex: 1; font-size: .93rem; word-break: break-word; }
.item.done .item-title { color: var(--muted); text-decoration: line-through; }

.badge {
  font-size: .65rem; font-weight: 600; padding: .15rem .45rem;
  border-radius: 99px; background: #f1f5f4; color: var(--muted);
  white-space: nowrap;
}
.badge.repeat { background: var(--brand-soft); color: var(--brand-ink); }

.del-btn {
  background: none; border: 0; cursor: pointer;
  color: #cbd5d2; font-size: .95rem; padding: .2rem .3rem; line-height: 1;
}
.del-btn:hover { color: var(--danger); }

.empty-hour { color: #c3cecb; font-size: .85rem; padding: .15rem .4rem; }

/* ---------- Tombol tambah ---------- */
.add-link {
  display: inline-block; margin-top: .45rem;
  background: none; border: 0; padding: .3rem .4rem;
  font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--brand); cursor: pointer; border-radius: 8px;
}
.add-link:hover { background: var(--brand-soft); }
.limit-note { margin-top: .45rem; font-size: .75rem; color: #c3cecb; padding: 0 .4rem; }

/* ---------- Form inline ---------- */
.inline-form {
  margin-top: .6rem; padding: .75rem;
  background: #f7faf9; border: 1px solid var(--line); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: .55rem;
}
.field-row { display: flex; gap: .5rem; align-items: center; }
.chip-row  { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  font: inherit; font-size: .9rem;
  padding: .55rem .65rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink);
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid #99f6e4; outline-offset: 1px; border-color: var(--brand);
}
input[type="number"] { width: 4.5rem; }
select.emoji-select { width: auto; min-width: 3.75rem; text-align: center; }

.chip {
  font: inherit; font-size: .75rem; font-weight: 600;
  padding: .3rem .65rem; border-radius: 99px; cursor: pointer;
  background: #fff; color: var(--ink-soft); border: 1px solid var(--line);
}
.chip[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }

.btn {
  font: inherit; font-size: .85rem; font-weight: 600;
  padding: .5rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: #eef2f1; color: var(--ink); }
.btn-soft { background: #f1f5f4; color: var(--ink-soft); }
.btn-soft:hover { background: #e6ecea; color: var(--ink); }
.btn-block { display: block; width: 100%; padding: .75rem; font-size: .95rem; }

/* ---------- Notice ---------- */
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem .9rem; border-radius: var(--radius);
  font-size: .85rem; margin-bottom: .85rem;
}
.notice.warn  { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.notice.error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.notice.ok    { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.notice button { flex: 0 0 auto; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 2.4rem; height: 1.4rem; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #d7e0dd; border-radius: 99px;
  transition: background-color .15s ease;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px;
  width: 1.05rem; height: 1.05rem; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track + .thumb { transform: translateX(1rem); }
.switch input:focus-visible + .track { outline: 2px solid #99f6e4; outline-offset: 2px; }

/* ---------- Baris pengaturan ---------- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .6rem 0;
  font-size: .9rem; color: var(--ink-soft);
}
.setting-row + .setting-row { border-top: 1px solid var(--line); }

.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-size: .8rem; font-weight: 500; color: var(--ink-soft); margin-bottom: .3rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ---------- Daftar kelola (settings) ---------- */
.manage-list { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.manage-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.manage-item .meta { flex: 1; min-width: 0; }
.manage-item .meta strong { display: block; font-size: .88rem; font-weight: 500; }
.manage-item.off .meta strong { color: var(--muted); }
.manage-item .meta span { font-size: .72rem; color: var(--muted); }

/* ---------- Halaman auth ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-box { width: 100%; max-width: 22rem; }
.auth-logo {
  width: 3.25rem; height: 3.25rem; margin: 0 auto .75rem;
  display: grid; place-items: center; border-radius: 16px;
  background: var(--brand); color: #fff; font-size: 1.5rem;
}
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head h1 { font-size: 1.4rem; }
.auth-head p { color: var(--muted); font-size: .88rem; margin-top: .25rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .88rem; color: var(--muted); }

/* ---------- Prompt install PWA ---------- */
.install-bar {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom));
  max-width: 26rem; margin: 0 auto; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: #18211f; color: #fff;
  padding: .75rem .9rem; border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.22);
  font-size: .85rem;
}
.install-bar .btn-soft { background: rgba(255,255,255,.14); color: #fff; }
.install-bar .btn-soft:hover { background: rgba(255,255,255,.24); }
.install-bar .btn-ghost { color: #b9c4c1; }
.install-bar .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #18211f; color: #fff;
  padding: .6rem 1rem; border-radius: 99px;
  font-size: .82rem; z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

[hidden] { display: none !important; }

/* ---------- Aksesibilitas ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  .wrap { padding-left: .75rem; padding-right: .75rem; }
}

/* ---------- Mode gelap ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a19;
    --surface: #1b2322;
    --ink: #e8efed;
    --ink-soft: #aebbb7;
    --muted: #7d8c88;
    --line: #2a3533;
    --brand: #2dd4bf;
    --brand-soft: #123531;
    --brand-ink: #5eead4;
    --shadow: none;
  }
  .item:hover, .icon-btn:hover, .datenav a.nav-arrow:hover { background: #222b29; }
  .hour-chip { background: #263130; }
  .badge { background: #263130; }
  .inline-form { background: #19201f; }
  input, select { background: #19201f; color: var(--ink); }
  .chip { background: #19201f; }
  .chip[aria-pressed="true"] { color: #06221f; }
  .btn { color: #06221f; }
  .btn-soft, .btn-ghost { color: var(--ink-soft); }
  .btn-soft { background: #263130; }
  .progress-track { background: #263130; }
  .check { border-color: #3a4644; }
  .item.done .check { color: #06221f; }
}
