/* ============================================
   Pria — Habit Tracker (pria.co.id)
   Design system v3: tampilan mobile app —
   kolom selebar ponsel (di desktop tampil sebagai
   frame perangkat membulat), bottom tab bar,
   palet hangat, default terang.
   ============================================ */

/* ---------- Tokens ---------- */
:root {
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* gradien hangat (sunrise) */
  --grad-1: #f97316;
  --grad-2: #ec4899;
  --grad: linear-gradient(135deg, var(--grad-1), var(--grad-2));

  /* status "selesai" — hijau tervalidasi (icon ✓ / label selalu menyertainya) */
  --good: #0ca30c;
  --good-grad: linear-gradient(135deg, #22c55e, #0ca30c);

  --bg: #faf6f1;
  --text: #292524;
  --muted: #786f63;
  --card: rgba(255, 255, 255, .78);
  --card-solid: #fffdfa;
  --border: rgba(41, 37, 36, .08);
  --input-bg: rgba(41, 37, 36, .05);
  --ring-track: rgba(41, 37, 36, .10);
  --dot-off: rgba(41, 37, 36, .15);
  --dash: rgba(41, 37, 36, .22);
  --shadow: 0 8px 28px rgba(120, 80, 40, .10);
  --shadow-lg: 0 24px 70px rgba(120, 80, 40, .18);
  --danger: #e11d48;
}

[data-theme="dark"] {
  --bg: #141219;
  --text: #f5f0ea;
  --muted: #a89e91;
  --card: rgba(255, 255, 255, .05);
  --card-solid: #1d1a21;
  --border: rgba(255, 255, 255, .10);
  --input-bg: rgba(255, 255, 255, .07);
  --ring-track: rgba(255, 255, 255, .12);
  --dot-off: rgba(255, 255, 255, .16);
  --dash: rgba(255, 255, 255, .30);
  --shadow: 0 10px 34px rgba(0, 0, 0, .40);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .60);
  --danger: #fb7185;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font: 500 15px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 620px at 88% -12%, rgba(249, 115, 22, .13), transparent 62%),
    radial-gradient(860px 620px at -8% 108%, rgba(236, 72, 153, .11), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  transition: background-color .35s ease, color .35s ease;
}

::selection { background: rgba(249, 115, 22, .22); }

.muted { color: var(--muted); }

/* ---------- Bingkai "ponsel" (mobile-first) ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.wrap { flex: 1; width: 100%; padding: 0 18px 116px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 4px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px; background: var(--grad);
  display: grid; place-items: center; font-size: 19px;
  box-shadow: 0 6px 16px rgba(249, 115, 22, .35);
}
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 13px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.icon-btn:hover { transform: translateY(-2px); border-color: rgba(249, 115, 22, .5); box-shadow: var(--shadow); }

/* ---------- Tab switching ---------- */
.view { display: none; }
.view.active { display: block; animation: rise .35s cubic-bezier(.2, .7, .3, 1); }

/* ---------- Hero ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 24px; margin-top: 14px; border-radius: 24px;
}
.eyebrow {
  margin: 0 0 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.hero h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 5.5vw, 1.75rem); font-weight: 800; letter-spacing: -.02em; }
.hero .sub { margin: 0; color: var(--muted); font-size: 13.5px; }

.ring-wrap { position: relative; width: 100px; height: 100px; flex: none; }
.ring { width: 100px; height: 100px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 10; }
.ring-fill {
  fill: none; stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset .55s cubic-bezier(.4, 0, .2, 1);
  filter: drop-shadow(0 2px 6px rgba(236, 72, 153, .35));
}
.ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { padding: 13px 12px; border-radius: 18px; display: flex; flex-direction: column; gap: 2px; }
.stat-ico { font-size: 14px; }
.stat b { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-label { font-size: 10.5px; font-weight: 600; color: var(--muted); }

/* ---------- Kartu habit (compact, ala app) ---------- */
.habits { margin-top: 22px; display: grid; gap: 10px; }
.habit {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 48px 1fr 52px;
  align-items: center; gap: 12px;
  padding: 14px 14px 14px 16px; border-radius: 20px;
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i) * 55ms);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.habit:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--hc-soft); }
.habit::before {
  content: ''; position: absolute; inset: 14px auto 14px 0; width: 5px;
  background: var(--hc); opacity: .5; border-radius: 999px;
}
.h-tile {
  width: 46px; height: 46px; border-radius: 15px;
  background: var(--hc-soft); display: grid; place-items: center;
  font-size: 22px; transition: transform .2s ease;
}
.habit:hover .h-tile { transform: scale(1.06) rotate(-3deg); }
.h-info { min-width: 0; }
.h-info h3 {
  margin: 0 0 3px; font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.h-streak { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.h-streak .flame { color: #f59e0b; }

/* titik mingguan: 7 hari terakhir, kiri→kanan = 7 hari lalu → hari ini */
.h-week { grid-column: 1 / -1; padding-left: 60px; display: flex; flex-direction: column; gap: 7px; }
.dots { display: flex; gap: 6px; justify-content: flex-start; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--dot-off);
  transition: background .25s ease, box-shadow .25s ease;
}
.dot.done { background: var(--good-grad); box-shadow: 0 2px 7px rgba(34, 197, 94, .35); }
.dot.today:not(.done) { animation: pulse-dot 2.2s ease-in-out infinite; }
.dlabels { display: flex; gap: 6px; }
.dlabels span { width: 12px; text-align: center; font-size: 9.5px; font-weight: 700; color: var(--muted); }
.dlabels span.on { color: var(--text); font-weight: 800; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px var(--hc); }
  50%      { box-shadow: 0 0 0 5px var(--hc-soft); }
}

/* tombol centang: lembut & mengundang, bukan "checkbox tugas" */
.check-btn {
  width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--dash); background: var(--input-bg); color: #fff;
  display: grid; place-items: center;
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), background .25s ease,
              border-color .25s ease, box-shadow .25s ease;
}
.check-btn .check-ico { font-size: 1.3rem; font-weight: 800; line-height: 1; opacity: 0; transition: opacity .2s ease; }
.check-btn:hover { border-color: var(--hc); background: var(--hc-soft); transform: scale(1.08); box-shadow: var(--shadow); }
.check-btn:hover .check-ico { opacity: .35; color: var(--hc); }
.check-btn.done {
  border-color: transparent;
  background: var(--good-grad); box-shadow: 0 6px 18px rgba(34, 197, 94, .35);
}
.check-btn.done .check-ico { opacity: 1; color: #fff; }
.check-btn.pop { animation: pop .35s cubic-bezier(.34, 1.56, .64, 1); }

.del-btn {
  position: absolute; top: 10px; right: 12px;
  width: 28px; height: 28px; border-radius: 9px; border: none; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 12px;
  opacity: .55; transition: opacity .2s ease, background .2s ease, color .2s ease;
}
.habit:hover .del-btn, .del-btn:focus-visible { opacity: .85; }
.del-btn:hover { opacity: 1; background: rgba(225, 29, 72, .12); color: var(--danger); }

/* konfirmasi hapus 2 langkah (menutupi isi kartu) */
.h-confirm {
  display: none; position: absolute; inset: 0; z-index: 3;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; border-radius: inherit;
  background: var(--card-solid); border: 1px solid rgba(225, 29, 72, .30);
}
.habit.confirm .h-confirm { display: flex; }
.habit.confirm > :not(.h-confirm) { visibility: hidden; }
.h-confirm span { font-size: 13px; font-weight: 700; }
.h-confirm-actions { display: flex; gap: 8px; align-items: center; }
form.inline { display: inline; }

/* ---------- Tombol ---------- */
.btn {
  border: none; cursor: pointer; font: 700 14px var(--font);
  padding: 11px 18px; border-radius: 14px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(249, 115, 22, .35); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(236, 72, 153, .4); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.sm { padding: 8px 14px; font-size: 12.5px; border-radius: 11px; }
.btn.block { display: block; width: 100%; padding: 13px; font-size: 15px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 24px; border-radius: 24px; }
.empty-ico { font-size: 56px; line-height: 1; margin-bottom: 14px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.empty h2 { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
.empty p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }

/* ---------- Footer ---------- */
.foot {
  text-align: center; margin: 26px auto 0;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
}

/* ---------- Halaman auth (daftar / masuk) ---------- */
[hidden] { display: none !important; }
.wrap.auth { align-items: center; justify-content: center; padding-bottom: 40px; }
.auth-inner { width: 100%; max-width: 400px; margin: auto; padding: 40px 0 10px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.auth-brand .brand-mark { width: 46px; height: 46px; font-size: 23px; border-radius: 15px; }
.auth-brand .brand-name { font-size: 26px; }
.auth-tag { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 24px; }
.auth-card { padding: 22px 24px 24px; border-radius: 26px; }
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--input-bg); border-radius: 14px; padding: 5px; margin-bottom: 22px;
}
.auth-tab {
  border: none; background: none; cursor: pointer; padding: 10px 0; border-radius: 10px;
  font: 700 14px var(--font); color: var(--muted); transition: all .2s ease;
}
.auth-tab.active { background: var(--card-solid); color: var(--text); box-shadow: 0 2px 10px rgba(120, 80, 40, .12); }
.auth-form { display: flex; flex-direction: column; gap: 2px; }
.auth-fineprint { margin: 16px 0 0; text-align: center; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

/* ---------- Topbar kanan & avatar profil ---------- */
.topbar-right { display: flex; align-items: center; gap: 8px; }
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad); color: #fff;
  font: 800 14px var(--font); display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(249, 115, 22, .3);
  transition: transform .2s ease, box-shadow .2s ease;
}
.avatar-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 16px rgba(236, 72, 153, .4); }

/* ---------- Menu profil (div, di-anchor ke .app — bukan dialog top-layer) ----------
   top/right disamakan dengan geometri avatar (38px, padding topbar 18px):
   menu muncul pas di bawah lingkaran, rata kanan dengan lingkaran. */
.profile-menu {
  position: absolute; top: 58px; right: 18px; z-index: 50;
  width: min(300px, calc(100% - 36px));
  background: var(--card-solid); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 18px; animation: pop .2s cubic-bezier(.2, .8, .3, 1);
}
.profile-menu::before {
  /* panah kecil mengarah ke avatar */
  content: ''; position: absolute; top: -6px; right: 28px;
  width: 12px; height: 12px; background: var(--card-solid);
  border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.profile-menu form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.profile-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.avatar-big {
  width: 42px; height: 42px; border-radius: 50%; background: var(--grad); color: #fff;
  display: grid; place-items: center; font: 800 16px var(--font); flex: none;
}
.profile-head b { display: block; font-size: 14.5px; letter-spacing: -.01em; }
.profile-head small { color: var(--muted); font-size: 11.5px; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: 1fr 84px 1fr; align-items: center;
  padding: 8px 22px calc(8px + env(safe-area-inset-bottom));
  background: var(--card-solid); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .06);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; padding: 6px 0;
  font: 600 11px var(--font); color: var(--muted);
  transition: color .2s ease;
}
.tab .t-ico { font-size: 20px; line-height: 1; }
.tab.active { color: var(--text); }
.tab.active::after { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--grad-2); }
.tab-add {
  width: 58px; height: 58px; margin: 0 auto; border: none; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 1.7rem; font-weight: 600;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 10px 24px rgba(249, 115, 22, .4);
  transform: translateY(-16px);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s ease;
}
.tab-add:hover { transform: translateY(-16px) scale(1.05); box-shadow: 0 14px 30px rgba(236, 72, 153, .45); }
.tab-add span { transition: transform .3s ease; }
.tab-add.open span { transform: rotate(45deg); }

/* ---------- Tab Minggu Ini: grid 7 hari × habit ---------- */
.week-head { padding: 18px 22px; border-radius: 22px; margin-top: 14px; }
.week-head h2 { margin: 0 0 4px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.week-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.week-head b { color: var(--text); }

.week-card { margin-top: 12px; padding: 18px 14px; border-radius: 22px; }
.week-grid { display: grid; gap: 9px; min-width: 360px; }
.week-row {
  display: grid; grid-template-columns: minmax(0, 1fr) repeat(7, 30px) 40px;
  gap: 4px; align-items: center;
}
.week-name {
  font-size: 12.5px; font-weight: 600; padding-right: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.week-cell {
  height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--dot-off); font-size: 11px; font-weight: 800; color: transparent;
  transition: background .25s ease, box-shadow .25s ease;
}
.week-cell.done { background: var(--good-grad); color: #fff; box-shadow: 0 2px 7px rgba(34, 197, 94, .3); }
.week-cell.today:not(.done) { box-shadow: inset 0 0 0 1.5px var(--dash); }
.week-cell.head {
  background: none; height: auto; display: flex; flex-direction: column;
  align-items: center; gap: 1px; color: var(--muted); font-weight: 700;
}
.week-cell.head b { font-size: 9.5px; }
.week-cell.head i { font-size: 9px; font-style: normal; opacity: .7; font-weight: 600; }
.week-count {
  font-size: 11px; font-weight: 700; color: var(--muted); text-align: right;
  font-variant-numeric: tabular-nums;
}
.week-row.head .week-count { font-size: 9.5px; font-weight: 700; }

/* ---------- Modal ---------- */
dialog.modal {
  border: none; padding: 0; background: transparent;
  width: min(92vw, 440px); color: var(--text);
}
dialog.modal::backdrop { background: rgba(41, 30, 22, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog.modal[open] { animation: pop .3s cubic-bezier(.2, .8, .3, 1); }
.modal form {
  background: var(--card-solid); border: 1px solid var(--border);
  border-radius: 26px; padding: 26px 26px 24px; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.modal-x {
  border: none; background: var(--input-bg); color: var(--muted);
  width: 32px; height: 32px; border-radius: 11px; cursor: pointer; font-size: 13px;
}
.modal-x:hover { color: var(--text); }

.field { display: block; margin-bottom: 18px; }
.field > span {
  display: block; margin-bottom: 9px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
input[type="text"],
input[type="password"] {
  width: 100%; padding: 12px 14px; border-radius: 14px; outline: none;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font: 600 15px var(--font);
  transition: border-color .2s ease, box-shadow .2s ease;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder { color: var(--muted); opacity: .75; }
input[type="text"]:focus,
input[type="password"]:focus { border-color: var(--grad-1); box-shadow: 0 0 0 3px rgba(249, 115, 22, .2); }
/* autofill browser (sering muncul di field password) supaya tetap sesuai tema */
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--card-solid) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-opt {
  aspect-ratio: 1; border-radius: 13px; border: 1px solid var(--border);
  background: var(--input-bg); font-size: 21px; cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.emoji-opt:hover { transform: scale(1.08); }
.emoji-opt.sel {
  background: var(--grad); border-color: transparent; transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(249, 115, 22, .35);
}

.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.color-opt {
  aspect-ratio: 1; border-radius: 50%; border: none; cursor: pointer;
  background: var(--c);
  transition: transform .15s ease, box-shadow .15s ease;
}
.color-opt:hover { transform: scale(1.12); }
.color-opt.sel { box-shadow: 0 0 0 3px var(--card-solid), 0 0 0 5px var(--c); transform: scale(1.05); }

/* ---------- Toast & confetti ---------- */
.toast {
  position: fixed; top: 20px; left: 50%; z-index: 60;
  transform: translateX(-50%) translateY(-10px);
  background: var(--card-solid); border: 1px solid var(--border); color: var(--text);
  padding: 11px 20px; border-radius: 999px; font: 600 13.5px var(--font);
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  max-width: min(88vw, 440px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(225, 29, 72, .45); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- Animasi ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop {
  0%   { transform: scale(.6); opacity: 0; }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Desktop: bingkai perangkat ---------- */
@media (min-width: 540px) {
  .app {
    margin: 24px auto;
    min-height: calc(100dvh - 48px);
    border: 1px solid var(--border);
    border-radius: 40px;
    overflow: clip;
    box-shadow: var(--shadow-lg);
  }
  .wrap { padding-bottom: 34px; }
  .tabbar { position: static; border-radius: 0 0 40px 40px; box-shadow: none; }
  .tab-add { transform: translateY(-10px); }
  .tab-add:hover { transform: translateY(-10px) scale(1.05); }
  .icon-btn, .brand-mark { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
