/* ==========================================================================
   NOVA Dashboard — Kalender & dashboard
   ========================================================================== */

/* ---------- Kartu statistik ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  display: flex; align-items: center; gap: 14px;
  transition: transform var(--normal), box-shadow var(--normal), border-color var(--normal);
  cursor: pointer;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -22px; top: -22px;
  width: 76px; height: 76px; border-radius: 50%;
  background: currentColor; opacity: .05;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-icon {
  width: 40px; height: 40px; flex: none; border-radius: var(--r-md);
  display: grid; place-items: center; background: currentColor;
}
.stat-icon svg { width: 19px; height: 19px; color: #fff; }
[data-theme="dark"] .stat-icon svg { color: var(--bg-surface); }
.stat-body { min-width: 0; }
.stat-value { font-size: 23px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 540; margin-top: 1px; }

/* ---------- Tata letak dashboard ----------
   Dashboard memakai tinggi tetap: halaman tidak menggulir, kalender mengisi
   seluruh ruang yang tersisa, dan satu-satunya area yang menggulir adalah
   kolom kanan — dipakai ketika agenda hari itu banyak. */
.page-fill {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 22px;
  overflow: hidden;
}

.dash-greeting {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  flex: 0 0 auto; margin-bottom: 14px;
}

.dash-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 18px;
  flex: 1 1 auto;
  min-height: 0;
}

.dash-cal { min-width: 0; min-height: 0; display: flex; }

.dash-side {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
}
.dash-side > * { flex: 0 0 auto; }

/* ---------- Kartu kalender mengisi tinggi ---------- */
.cal-card {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0;
  overflow: hidden;
}
.cal-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.cal-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.cal-view-agenda { display: block; overflow-y: auto; padding: 16px; }

/* Layar sempit: kembali ke gulir halaman biasa agar tidak sesak */
@media (max-width: 1180px) {
  .page-fill {
    height: auto; overflow: visible;
    padding-bottom: max(72px, env(safe-area-inset-bottom, 0px));
  }
  .dash-layout { grid-template-columns: 1fr; flex: 0 0 auto; }
  .dash-cal { display: block; }
  .dash-side { overflow: visible; padding-right: 0; }
  .cal-card { flex: 0 0 auto; }
}

/* ---------- Toolbar kalender ---------- */
.cal-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-month {
  font-size: 17px; font-weight: 660; letter-spacing: -.022em;
  min-width: 172px; padding: 0 6px;
}
.cal-month .year { color: var(--text-muted); font-weight: 550; }

/* ---------- Grid bulan ---------- */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2);
  flex: 0 0 auto;
}
.cal-weekday {
  padding: 8px 6px; text-align: center;
  font-size: 11px; font-weight: 640; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
}
.cal-weekday.weekend { color: var(--danger); }

/* Baris membagi rata tinggi yang tersedia, dengan batas bawah agar sel tetap
   terbaca di jendela pendek — di situ grid punya gulir sendiri sebagai katup. */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(78px, 1fr);
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
}
@media (max-width: 1180px) {
  .cal-grid { grid-auto-rows: minmax(104px, auto); flex: 0 0 auto; overflow: visible; }
}
.cal-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px 5px 5px;
  min-width: 0; min-height: 0;
  cursor: pointer; position: relative;
  transition: background var(--fast);
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--bg-hover); }
.cal-cell.other-month { background: var(--bg-surface-2); }
.cal-cell.other-month .cal-daynum { color: var(--text-muted); opacity: .6; }
.cal-cell.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.cal-cell.today .cal-daynum {
  background: var(--accent); color: var(--accent-contrast);
  font-weight: 700;
}
.cal-cell.weekend:not(.other-month) .cal-daynum { color: var(--danger); }
.cal-cell.today.weekend .cal-daynum { color: var(--accent-contrast); }

.cal-cell-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex: none; }
.cal-daynum {
  min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: var(--r-pill);
  display: inline-grid; place-items: center;
  font-size: 12.5px; font-weight: 570; color: var(--text);
  transition: background var(--fast);
}
.cal-daynum-holiday { color: var(--danger); }
.cal-add-btn {
  width: 20px; height: 20px; border-radius: var(--r-xs);
  display: grid; place-items: center; color: var(--text-muted);
  opacity: 0; transition: all var(--fast); flex: none;
  background: var(--bg-surface); border: 1px solid var(--border);
}
.cal-add-btn svg { width: 12px; height: 12px; }
.cal-cell:hover .cal-add-btn { opacity: 1; }
.cal-add-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.cal-events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; flex: 1; min-height: 0; }
.cal-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 1px 6px; border-radius: 5px;
  font-size: 11.2px; line-height: 1.5; font-weight: 540;
  background: var(--pill-bg, var(--bg-sunken));
  color: var(--pill-fg, var(--text));
  cursor: pointer; transition: filter var(--fast), transform var(--fast);
  min-width: 0; flex: none;
  border-left: 2.5px solid var(--pill-dot, var(--accent));
}
.cal-pill:hover { filter: brightness(.96); transform: translateX(1px); }
[data-theme="dark"] .cal-pill:hover { filter: brightness(1.16); }
.cal-pill .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cal-pill.done .n { text-decoration: line-through; opacity: .55; }
.cal-pill-more {
  font-size: 10.5px; color: var(--text-muted); font-weight: 570;
  padding: 1px 6px; text-align: left; border-radius: 4px;
  flex: none;
}
.cal-pill-more:hover { background: var(--bg-active); color: var(--text); }

/* Dipakai fitMonthCells untuk menyembunyikan pil yang tidak muat */
.cal-pill.is-hidden, .cal-pill-more.is-hidden { display: none; }

.cal-dots { display: flex; gap: 2.5px; padding: 1px 2px; flex-wrap: wrap; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; }

/* ---------- Tampilan minggu / hari ---------- */
/* Kisi 24 jam memang panjang, jadi ia punya area gulir sendiri yang mengisi
   sisa tinggi kartu kalender. */
.cal-time-grid {
  display: grid;
  grid-template-columns: 58px 1fr;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  position: relative;
}
@media (max-width: 1180px) {
  .cal-time-grid { flex: 0 0 auto; max-height: clamp(360px, calc(100dvh - 320px), 720px); }
}
.cal-time-col { border-right: 1px solid var(--border); }
.cal-time-slot {
  height: 52px; padding: 0 8px; text-align: right;
  font-size: 10.5px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  position: relative; top: -7px;
}
.cal-day-cols { display: grid; position: relative; }
.cal-day-col { border-right: 1px solid var(--border); position: relative; min-width: 0; }
.cal-day-col:last-child { border-right: none; }
.cal-hour-line { height: 52px; border-bottom: 1px solid var(--border); }
.cal-hour-line:nth-child(odd) { background: var(--bg-surface-2); }

.cal-day-head {
  display: grid; z-index: 5; flex: 0 0 auto;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.cal-day-head-cell {
  padding: 8px 6px; text-align: center; border-right: 1px solid var(--border); cursor: pointer;
  transition: background var(--fast);
}
.cal-day-head-cell:hover { background: var(--bg-hover); }
.cal-day-head-cell:last-child { border-right: none; }
.cal-day-head-name { font-size: 10.5px; font-weight: 640; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted); }
.cal-day-head-num {
  font-size: 17px; font-weight: 660; margin-top: 2px;
  width: 31px; height: 31px; border-radius: 50%;
  display: inline-grid; place-items: center;
}
.cal-day-head-cell.today .cal-day-head-num { background: var(--accent); color: var(--accent-contrast); }
.cal-day-head-cell.today .cal-day-head-name { color: var(--accent-text); }

.cal-block {
  position: absolute; left: 3px; right: 3px;
  border-radius: 6px; padding: 3px 6px;
  font-size: 11.2px; overflow: hidden; cursor: pointer;
  background: var(--pill-bg); color: var(--pill-fg);
  border-left: 3px solid var(--pill-dot);
  transition: filter var(--fast), box-shadow var(--fast);
  z-index: 2;
}
.cal-block:hover { filter: brightness(.96); box-shadow: var(--shadow-sm); z-index: 3; }
[data-theme="dark"] .cal-block:hover { filter: brightness(1.16); }
.cal-block .bt { font-weight: 600; line-height: 1.3; }
.cal-block .bs { font-size: 10.2px; opacity: .8; }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 6; pointer-events: none; }
.now-line::before {
  content: ""; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}

.allday-row {
  display: grid; border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2); min-height: 30px;
  flex: 0 0 auto; max-height: 118px; overflow-y: auto;
}
.allday-cell { border-right: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; }
.allday-cell:last-child { border-right: none; }

/* ---------- Panel agenda ----------
   Panel tidak dibatasi tingginya dan tidak sticky; yang menggulir adalah
   kolom pembungkusnya (.dash-side), sehingga hanya ada satu area gulir. */
.agenda-head {
  padding: 15px 17px 11px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 4;
  background: var(--bg-surface);
  border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg);
}
.agenda-date { font-size: 16.5px; font-weight: 660; letter-spacing: -.02em; }
.agenda-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.agenda-list { padding: 11px; display: flex; flex-direction: column; gap: 8px; }

.event-row {
  display: flex; gap: 11px; padding: 11px 12px;
  border-radius: var(--r-md); cursor: pointer;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  transition: all var(--fast); text-align: left; width: 100%;
  position: relative; overflow: hidden;
}
.event-row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--ev-color, var(--accent));
}
.event-row:hover { background: var(--bg-hover); border-color: var(--border-strong); transform: translateX(2px); }
.event-row.is-done { opacity: .58; }
.event-row.is-done .event-title { text-decoration: line-through; }
.event-row.overdue { border-color: var(--danger); background: var(--danger-soft); }

.event-check {
  width: 19px; height: 19px; flex: none; margin-top: 1px;
  border: 1.8px solid var(--border-strong); border-radius: 50%;
  display: grid; place-items: center; transition: all var(--fast);
  background: var(--bg-surface);
}
.event-check svg { width: 11px; height: 11px; color: #fff; opacity: 0; transition: opacity var(--fast); }
.event-check:hover { border-color: var(--success); }
.event-check.checked { background: var(--success); border-color: var(--success); }
.event-check.checked svg { opacity: 1; }

.event-main { flex: 1; min-width: 0; }
.event-title { font-size: 13.6px; font-weight: 580; line-height: 1.4; }
.event-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-muted); margin-top: 3px;
}
.event-meta .m { display: inline-flex; align-items: center; gap: 4px; }
.event-meta svg { width: 12px; height: 12px; }
.event-notes { font-size: 12px; color: var(--text-soft); margin-top: 5px; line-height: 1.5; }
.event-type-icon {
  width: 26px; height: 26px; flex: none; border-radius: var(--r-xs);
  display: grid; place-items: center; font-size: 13px;
  background: var(--ev-soft, var(--bg-sunken)); color: var(--ev-color, var(--text-soft));
}
.event-type-icon svg { width: 14px; height: 14px; }

.prio-flag { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.prio-urgent { color: var(--danger); }
.prio-high { color: var(--warning); }
.prio-normal { color: var(--info); }
.prio-low { color: var(--text-muted); }

/* ==========================================================================
   Pratinjau acara (modal baca-saja)
   ========================================================================== */
.ev-preview { display: flex; flex-direction: column; gap: 14px; }

.ev-status {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  font-size: 13.5px; font-weight: 550; text-align: left;
  cursor: pointer; transition: all var(--fast);
}
.ev-status:hover { border-color: var(--success); background: var(--bg-hover); }
.ev-status-check {
  width: 20px; height: 20px; flex: none;
  border: 1.9px solid var(--border-strong); border-radius: 50%;
  display: grid; place-items: center; transition: all var(--fast);
}
.ev-status-check svg { width: 12px; height: 12px; color: #fff; opacity: 0; transition: opacity var(--fast); }
.ev-status.is-done { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 32%, transparent); }
.ev-status.is-done .ev-status-check { background: var(--success); border-color: var(--success); }
.ev-status.is-done .ev-status-check svg { opacity: 1; }

.ev-when {
  padding: 13px 15px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ev-color, var(--accent)) 10%, transparent);
  border-left: 3px solid var(--ev-color, var(--accent));
}
.ev-when-date { font-size: 15px; font-weight: 620; letter-spacing: -.015em; }
.ev-when-time { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

.ev-deadline {
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--warning-soft);
  border: 1px solid color-mix(in srgb, var(--warning) 26%, transparent);
  font-size: 13px;
}
.ev-deadline.is-late {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

.ev-rows { display: flex; flex-direction: column; }
.ev-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
  font-size: 13.3px;
}
.ev-row:last-child { border-bottom: none; }
.ev-row-ico { flex: none; color: var(--text-muted); padding-top: 2px; }
.ev-row-key { flex: none; width: 92px; color: var(--text-muted); }
.ev-row-val { flex: 1; min-width: 0; word-break: break-word; }
.ev-link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }

.ev-section { display: flex; flex-direction: column; gap: 8px; }
.ev-section-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
}
.ev-section-head svg { color: var(--text-muted); }

.ev-subtasks { display: flex; flex-direction: column; gap: 5px; }
.ev-subtask {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-surface-2);
  font-size: 13.2px; text-align: left; cursor: pointer;
  transition: background var(--fast), border-color var(--fast);
}
.ev-subtask:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.ev-subtask-check {
  width: 17px; height: 17px; flex: none;
  border: 1.8px solid var(--border-strong); border-radius: 5px;
  display: grid; place-items: center; transition: all var(--fast);
}
.ev-subtask-check svg { width: 11px; height: 11px; color: #fff; opacity: 0; transition: opacity var(--fast); }
.ev-subtask.done .ev-subtask-check { background: var(--success); border-color: var(--success); }
.ev-subtask.done .ev-subtask-check svg { opacity: 1; }
.ev-subtask.done > .grow { text-decoration: line-through; color: var(--text-muted); }

.ev-notes {
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--bg-surface-2); border: 1px solid var(--border);
  font-size: 13.3px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Sub-tugas ---------- */
.subtask-list { display: flex; flex-direction: column; gap: 5px; }
.subtask-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: var(--r-xs);
  background: var(--bg-surface-2); border: 1px solid var(--border);
}
.subtask-row:hover { background: var(--bg-hover); }
.subtask-row input[type="text"] {
  flex: 1; border: none; background: none; font-size: 13px; outline: none; min-width: 0; padding: 0;
}
.subtask-row.done input[type="text"] { text-decoration: line-through; color: var(--text-muted); }

/* ---------- Progress deadline ---------- */
.deadline-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.deadline-bar .progress { flex: 1; height: 5px; }
.deadline-label { font-size: 11px; font-weight: 570; white-space: nowrap; }

/* ---------- Mini kalender ---------- */
.mini-cal { padding: 11px; }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mini-cal-title { font-size: 13px; font-weight: 620; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-wd { text-align: center; font-size: 9.5px; font-weight: 640; color: var(--text-muted); padding: 3px 0; }
.mini-day {
  aspect-ratio: 1; display: grid; place-items: center; position: relative;
  font-size: 11.5px; border-radius: var(--r-xs); cursor: pointer;
  transition: background var(--fast);
}
.mini-day:hover { background: var(--bg-hover); }
.mini-day.other { color: var(--text-muted); opacity: .5; }
.mini-day.today { background: var(--accent); color: var(--accent-contrast); font-weight: 660; }
.mini-day.selected:not(.today) { background: var(--accent-soft); color: var(--accent-text); font-weight: 620; }
.mini-day.has-event::after {
  content: ""; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 3.5px; height: 3.5px; border-radius: 50%; background: var(--accent);
}
.mini-day.today.has-event::after { background: var(--accent-contrast); }

/* ---------- Daftar agenda (tampilan list) ---------- */
.agenda-group { margin-bottom: 22px; }
.agenda-group-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 9px;
  position: sticky; top: 0; background: var(--bg-app); padding: 5px 0; z-index: 3;
}
.agenda-group-date {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: var(--r-md); background: var(--bg-surface); border: 1px solid var(--border);
}
.agenda-group-date .d { font-size: 16px; font-weight: 700; line-height: 1; }
.agenda-group-date .m { font-size: 9.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 620; }
.agenda-group-date.is-today { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.agenda-group-date.is-today .m { color: var(--accent-contrast); opacity: .82; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2);
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 550;
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text-soft); cursor: pointer; transition: all var(--fast);
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chip.active {
  background: var(--accent-soft); border-color: transparent; color: var(--accent-text);
}
.filter-chip .chip-dot { width: 8px; height: 8px; }
