/* =========================================================
   Case Management — tema pastel earthy (terracotta + sage)
   Mobile-only layout, dirender sebagai kolom sempit di layar besar.
   ========================================================= */

:root {
  color-scheme: light;

  /* Netral hangat */
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-alt: #f3ede3;
  --border: #e8ddce;
  --text: #2e2a26;
  --text-muted: #8a8175;
  --text-faint: #b3a99a;

  /* Brand */
  --primary: #b9704f;
  --primary-dark: #965a3d;
  --primary-light: #f0dccf;
  --accent: #7c9473;
  --accent-dark: #5f7657;
  --accent-light: #e3ead9;

  /* Semantik */
  --success: #5b8c5a;
  --danger: #b5564a;
  --danger-light: #f7e1de;
  --warning: #c99a3e;
  --warning-light: #fbf0dc;
  --info: #4e7196;
  --info-light: #e4edf5;

  /* Status badge */
  --status-open-bg: #e4edf5;    --status-open-fg: #4e7196;
  --status-closed-bg: #eceae6; --status-closed-fg: #6b6459;

  /* Prioritas badge */
  --prio-low-bg: #e7f0e5;    --prio-low-fg: #55804f;
  --prio-medium-bg: #fbf0dc; --prio-medium-fg: #9c7b2e;
  --prio-high-bg: #f6e6d9;   --prio-high-fg: #b06a35;
  --prio-urgent-bg: #f7e1de; --prio-urgent-fg: #a33f35;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-card: 0 1px 2px rgba(46, 42, 38, 0.06), 0 2px 8px rgba(46, 42, 38, 0.04);
  --shadow-float: 0 6px 20px rgba(185, 112, 79, 0.28);
  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* Bungkus seluruh app dalam kolom lebar HP, dipusatkan kalau layar lebar */
.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(46, 42, 38, 0.06);
}

@media (min-width: 481px) {
  body { background: var(--surface-alt); padding: 0; }
  .app-shell { box-shadow: 0 0 0 1px var(--border), 0 20px 60px rgba(46, 42, 38, 0.12); }
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.icon-btn svg { width: 20px; height: 20px; }

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg);
}

/* ===== Konten ===== */
.page-content {
  flex: 1;
  padding: 16px 20px calc(var(--nav-height) + 28px);
}

.page-content.no-nav {
  padding-bottom: 28px;
}

/* ===== Bottom navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 30;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  flex: 1;
  padding: 6px 0;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--primary); }

.nav-fab-wrap {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  margin-top: -30px;
}

.nav-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: 4px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-float);
}

.nav-fab svg { width: 24px; height: 24px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

.case-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.case-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.case-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

.case-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 2px 0 0;
  line-height: 1.35;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.case-meta-divider { color: var(--text-faint); }

.case-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-open { background: var(--status-open-bg); color: var(--status-open-fg); }
.badge-closed { background: var(--status-closed-bg); color: var(--status-closed-fg); }

.badge-prio-low { background: var(--prio-low-bg); color: var(--prio-low-fg); }
.badge-prio-medium { background: var(--prio-medium-bg); color: var(--prio-medium-fg); }
.badge-prio-high { background: var(--prio-high-bg); color: var(--prio-high-fg); }
.badge-prio-urgent { background: var(--prio-urgent-bg); color: var(--prio-urgent-fg); }

.sla-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.sla-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.sla-tag.ok .sla-dot { background: var(--success); }
.sla-tag.warning .sla-dot { background: var(--warning); }
.sla-tag.warning { color: var(--warning); }
.sla-tag.overdue .sla-dot { background: var(--danger); }
.sla-tag.overdue { color: var(--danger); }

/* ===== Avatar ===== */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:active { background: var(--accent-dark); }

.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary-light); }
.btn-ghost { background: var(--surface-alt); color: var(--text); }
.btn-danger { background: var(--danger-light); color: var(--danger); }

.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control { resize: vertical; min-height: 90px; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%238A8175' stroke-width='2' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.chip.active { background: var(--primary-light); border-color: var(--primary-light); color: var(--primary-dark); }

.file-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface-alt);
}

/* ===== Stat tiles (dashboard) ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-tile .stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-tile .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }
.stat-tile.accent-primary { background: var(--primary-light); }
.stat-tile.accent-primary .stat-value { color: var(--primary-dark); }
.stat-tile.accent-warn { background: var(--warning-light); }
.stat-tile.accent-warn .stat-value { color: var(--warning); }
.stat-tile.accent-danger { background: var(--danger-light); }
.stat-tile.accent-danger .stat-value { color: var(--danger); }
.stat-tile.accent-success { background: var(--accent-light); }
.stat-tile.accent-success .stat-value { color: var(--accent-dark); }

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title a.see-all { font-size: 12px; color: var(--primary); font-weight: 700; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; color: var(--text-faint); margin-bottom: 10px; }
.empty-state p { margin: 0; font-size: 13px; }

/* ===== Flash / alert ===== */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.alert-success { background: var(--accent-light); color: var(--accent-dark); }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-info { background: var(--info-light); color: var(--info); }

/* ===== Login page ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 26px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(155deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  margin-bottom: 18px;
}

.auth-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

.auth-demo {
  margin-top: 24px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Comments ===== */
.comment-item { display: flex; gap: 10px; margin-bottom: 16px; }
.comment-body { flex: 1; }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.comment-name { font-size: 13px; font-weight: 700; }
.comment-time { font-size: 11px; color: var(--text-faint); }
.comment-text { font-size: 13.5px; color: var(--text); line-height: 1.5; background: var(--surface-alt); padding: 10px 12px; border-radius: var(--radius-sm); border-top-left-radius: 4px; }

.comment-input-row {
  position: sticky;
  bottom: calc(var(--nav-height) + 10px);
  display: flex;
  gap: 8px;
  background: var(--bg);
  padding-top: 8px;
}

.comment-input-row .form-control { flex: 1; }

/* ===== Timeline (activity log) ===== */
.timeline-item { display: flex; gap: 10px; padding-bottom: 16px; position: relative; }
.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: -4px;
  width: 1.5px;
  background: var(--border);
}

.timeline-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--primary-light); border: 2px solid var(--primary); flex: none; margin-top: 3px; }
.timeline-text { font-size: 12.5px; color: var(--text); line-height: 1.5; }
.timeline-text b { font-weight: 700; }
.timeline-time { font-size: 11px; color: var(--text-faint); }

/* ===== Tabs (detail page) ===== */
.tabs { display: flex; gap: 4px; background: var(--surface-alt); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.tab-btn { flex: 1; text-align: center; padding: 9px 0; font-size: 12.5px; font-weight: 700; color: var(--text-muted); border-radius: 8px; cursor: pointer; }
.tab-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-card); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Sheet / modal ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(46, 42, 38, 0.4);
  z-index: 40;
  display: none;
  justify-content: center;
}

.sheet-overlay.open { display: flex; }

.sheet {
  align-self: flex-end;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  max-height: 82vh;
  overflow-y: auto;
}

.sheet-handle { width: 40px; height: 4px; border-radius: 3px; background: var(--border); margin: 0 auto 16px; }
.sheet-title { font-size: 16px; font-weight: 800; margin: 0 0 14px; }

/* ===== List rows (users, notifications, menu) ===== */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child { border-bottom: none; }
.list-row-body { flex: 1; min-width: 0; }
.list-row-title { font-size: 14px; font-weight: 700; }
.list-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.notif-row.unread { background: var(--primary-light); border-radius: var(--radius-sm); }
.notif-row.unread .list-row-title::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 6px;
}

/* ===== Chart canvas wrapper ===== */
.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; margin-bottom: 16px; }
.chart-wrap canvas { width: 100% !important; height: 180px !important; }

/* ===== Profile ===== */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 8px 0 20px; }
.profile-name { font-size: 17px; font-weight: 800; }
.profile-role { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

/* ===== Utility ===== */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }

/* ===== Print (halaman laporan) ===== */
@media print {
  .bottom-nav, .topbar .icon-btn, .no-print { display: none !important; }
  .app-shell { box-shadow: none; max-width: 100%; }
  body { background: #fff; }
}
