/* ==========================================================================
   MyFamily — Jadwal Kegiatan Harian
   Konsep desain: "Day Arc" — jadwal digambarkan sebagai lengkung hari,
   dari fajar ke malam, sebagai pengingat ritme harian.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Warna dasar — kertas hangat, bukan krem klise */
  --paper: #F5F1E6;
  --paper-2: #ECE4D2;
  --card: #FBF9F3;
  --ink: #2A2724;
  --ink-soft: #6E6656;
  --line: #DCD1B8;

  /* Aksen ritme hari */
  --dawn: #E8935A;   /* pagi */
  --noon: #3F7D6E;   /* siang — aksen utama, fokus/produktivitas */
  --dusk: #7A5FA0;   /* sore/malam */

  /* Status */
  --done: #3F7D6E;
  --pending: #C9BEA6;
  --missed: #B5503F;
  --skip: #A79A82;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --shadow: 0 1px 2px rgba(42,39,36,0.06), 0 6px 20px rgba(42,39,36,0.05);

  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--noon);
  outline-offset: 2px;
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--card);
  color: var(--ink);
  width: 100%;
}

/* ---------------- Auth screens ---------------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}
.auth-arc { position: relative; width: 100%; height: 70px; margin-bottom: 8px; }
.auth-arc svg { width: 100%; height: 100%; overflow: visible; }
.auth-arc path { fill: none; stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.auth-sun { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); font-size: 20px; }
.auth-card h1 { margin: 4px 0 6px; font-size: 24px; }
.auth-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 20px; line-height: 1.5; }
.auth-error { color: var(--missed); font-size: 13px; margin: -8px 0 14px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { text-align: left; font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 6px; }
.auth-form button {
  margin-top: 6px;
  background: var(--noon);
  color: #fff;
  padding: 12px;
  border-radius: var(--radius-s);
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.auth-form button:hover { background: #356a5d; }
.auth-form button:active { transform: scale(0.98); }

/* ---------------- App shell ---------------- */
#app { max-width: 720px; margin: 0 auto; padding: 0 0 96px; min-height: 100vh; position: relative; }

.app-header {
  padding: 22px 20px 8px;
}
.app-header .greeting { font-size: 13px; color: var(--ink-soft); margin: 0 0 2px; }
.app-header .date-nav { display: flex; align-items: center; gap: 10px; }
.app-header .date-nav h1 { font-size: 26px; margin: 0; flex: 1; }
.date-nav button.nav-arrow {
  width: 34px; height: 34px; border-radius: 50%; background: var(--card);
  box-shadow: var(--shadow); font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.streak-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--paper-2); color: var(--ink-soft);
  font-size: 12px; padding: 4px 10px; border-radius: 999px; margin-top: 8px;
  font-family: var(--font-mono);
}

/* ---------------- Day Arc (signature element) ---------------- */
.day-arc-wrap { padding: 6px 20px 4px; }
.day-arc { position: relative; width: 100%; }
.day-arc svg { width: 100%; height: auto; display: block; }
.day-arc .arc-track { fill: none; stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.day-arc .arc-fill { fill: none; stroke: var(--dawn); stroke-width: 2; stroke-linecap: round; opacity: 0.55; }
.day-arc .arc-dot { cursor: pointer; transition: r 0.15s ease; }
.day-arc .arc-dot:hover { r: 7; }
.day-arc .arc-sun { transition: transform 0.3s ease; }
.day-arc .arc-label { font-family: var(--font-mono); font-size: 9px; fill: var(--ink-soft); }

/* ---------------- Quick stats ---------------- */
.quick-stats { display: flex; gap: 8px; padding: 10px 20px 4px; }
.quick-stat {
  flex: 1; background: var(--card); border-radius: var(--radius-m); padding: 10px 12px;
  box-shadow: var(--shadow);
}
.quick-stat .num { font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1; }
.quick-stat .lbl { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.quick-stat.done .num { color: var(--done); }
.quick-stat.missed .num { color: var(--missed); }

/* ---------------- Timeline ---------------- */
.timeline { padding: 12px 20px 20px; }
.timeline-section { margin-bottom: 6px; }
.timeline-section .divider {
  display: flex; align-items: center; gap: 8px; margin: 18px 0 10px; color: var(--ink-soft);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.timeline-section .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.activity-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); border-radius: var(--radius-m); padding: 12px 14px;
  margin-bottom: 8px; box-shadow: var(--shadow);
  border-left: 3px solid var(--pending);
  transition: opacity 0.2s ease;
}
.activity-row[data-status="done"] { border-left-color: var(--done); }
.activity-row[data-status="missed"] { border-left-color: var(--missed); }
.activity-row[data-status="skipped"] { border-left-color: var(--skip); opacity: 0.65; }

.activity-time { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); width: 44px; flex-shrink: 0; line-height: 1.3; padding-top: 2px; }
.activity-body { flex: 1; min-width: 0; }
.activity-body .title-line { display: flex; align-items: center; gap: 6px; }
.activity-body .cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.activity-body .title { font-weight: 600; font-size: 14.5px; }
.activity-row[data-status="done"] .title { text-decoration: line-through; color: var(--ink-soft); }
.activity-body .notes { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.activity-body .cat-name { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

.activity-actions { display: flex; gap: 6px; flex-shrink: 0; }
.act-btn {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--paper-2); font-size: 14px; transition: background 0.15s ease, transform 0.1s ease;
}
.act-btn:active { transform: scale(0.9); }
.act-btn.done-btn.active { background: var(--done); color: #fff; }
.act-btn.skip-btn.active { background: var(--skip); color: #fff; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state .emoji { font-size: 36px; display: block; margin-bottom: 10px; }
.empty-state a { color: var(--noon); font-weight: 600; }

/* ---------------- Bottom nav ---------------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; z-index: 50;
}
.bottom-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--ink-soft); padding: 4px 10px; border-radius: var(--radius-s);
}
.bottom-nav button .icon { font-size: 19px; }
.bottom-nav button.active { color: var(--noon); }

/* ---------------- Calendar view ---------------- */
.cal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 10px; }
.cal-header h2 { margin: 0; font-size: 20px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 6px 20px 24px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--ink-soft); font-weight: 600; }
.cal-day {
  aspect-ratio: 1; border-radius: var(--radius-s); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; background: var(--card); box-shadow: var(--shadow);
  font-size: 12px; position: relative;
}
.cal-day.empty { background: transparent; box-shadow: none; }
.cal-day.today { outline: 2px solid var(--noon); }
.cal-day .ring {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.cal-day .daynum { font-family: var(--font-mono); font-size: 11px; }

/* ---------------- Routines view ---------------- */
.routines-list { padding: 8px 20px 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 6px; }
.section-title h2 { margin: 0; font-size: 20px; }
.add-btn { background: var(--noon); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600; }

.routine-card {
  background: var(--card); border-radius: var(--radius-m); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.routine-card .cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.routine-card .info { flex: 1; min-width: 0; }
.routine-card .info .rtitle { font-weight: 600; font-size: 14px; }
.routine-card .info .rmeta { font-size: 11.5px; color: var(--ink-soft); font-family: var(--font-mono); }
.routine-card .rcontrols { display: flex; gap: 4px; }
.routine-card .rcontrols button { width: 28px; height: 28px; border-radius: 50%; background: var(--paper-2); font-size: 13px; }

/* ---------------- Stats view ---------------- */
.stats-wrap { padding: 8px 20px 24px; }
.stats-toggle { display: flex; gap: 8px; margin: 10px 0 16px; }
.stats-toggle button { background: var(--paper-2); padding: 6px 14px; border-radius: 999px; font-size: 12.5px; }
.stats-toggle button.active { background: var(--noon); color: #fff; }

.stat-hero { display: flex; gap: 12px; margin-bottom: 16px; }
.hero-card { flex: 1; background: var(--card); border-radius: var(--radius-l); padding: 18px; box-shadow: var(--shadow); text-align: center; }
.hero-card .ring-wrap { width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.hero-card .ring-wrap .center { background: var(--card); width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.hero-card .streak-num { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--dawn); line-height: 1; }
.hero-card .lbl { font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; }

.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 110px; padding: 10px 4px 0; background: var(--card); border-radius: var(--radius-m); box-shadow: var(--shadow); margin-bottom: 16px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar-chart .bar { width: 60%; border-radius: 4px 4px 0 0; background: var(--pending); min-height: 3px; transition: height 0.3s ease; }
.bar-chart .bar.has-done { background: var(--done); }
.bar-chart .day-lbl { font-size: 9px; color: var(--ink-soft); font-family: var(--font-mono); }

.cat-breakdown .cat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12.5px; }
.cat-breakdown .cat-row .track { flex: 1; height: 6px; background: var(--paper-2); border-radius: 3px; overflow: hidden; }
.cat-breakdown .cat-row .fill { height: 100%; border-radius: 3px; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(42,39,36,0.4); display: flex; align-items: flex-end;
  justify-content: center; z-index: 100;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal-card {
  background: var(--paper); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 22px 20px 26px;
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 640px) { .modal-card { border-radius: var(--radius-l); } }
.modal-card h2 { margin: 0 0 16px; font-size: 19px; }
.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.form-row.two-col { flex-direction: row; gap: 10px; }
.form-row.two-col > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.recurrence-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.recurrence-tabs button { flex: 1; padding: 8px; border-radius: var(--radius-s); background: var(--paper-2); font-size: 12.5px; }
.recurrence-tabs button.active { background: var(--noon); color: #fff; }
.day-picker { display: flex; gap: 5px; flex-wrap: wrap; }
.day-picker button {
  width: 34px; height: 34px; border-radius: 50%; background: var(--paper-2); font-size: 11px; font-weight: 600;
}
.day-picker button.active { background: var(--dusk); color: #fff; }
.category-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.category-picker button { padding: 6px 10px; border-radius: 999px; background: var(--paper-2); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.category-picker button.active { outline: 2px solid var(--ink); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: var(--radius-s); font-weight: 600; font-size: 14px; }
.modal-actions .cancel-btn { background: var(--paper-2); }
.modal-actions .save-btn { background: var(--noon); color: #fff; }

.toast {
  position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------------- Responsive: desktop sidebar ---------------- */
@media (min-width: 860px) {
  body { display: flex; }
  #app { max-width: none; flex: 1; padding-bottom: 24px; margin: 0; }
  .bottom-nav {
    position: sticky; top: 0; height: 100vh; width: 220px; flex-direction: column; justify-content: flex-start;
    align-items: stretch; border-top: none; border-right: 1px solid var(--line); padding: 24px 12px;
    gap: 6px; max-width: none; margin: 0;
  }
  .bottom-nav button { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 13.5px; padding: 10px 12px; }
  .bottom-nav button .icon { font-size: 17px; }
  .view-wrap { max-width: 640px; margin: 0 auto; }
}
