/* ============================================================
   Maping — Shared Design System
   Mobile-first, modern UI
   ============================================================ */

/* ── Variables ── */
:root {
  --primary:       #6366f1;
  --primary-50:    #eef2ff;
  --primary-100:   #e0e7ff;
  --primary-600:   #4f46e5;
  --primary-700:   #4338ca;

  --purple:        #8b5cf6;
  --purple-50:     #f5f3ff;
  --purple-100:    #ede9fe;

  --success:       #10b981;
  --success-50:    #f0fdf4;
  --success-100:   #d1fae5;

  --danger:        #ef4444;
  --danger-50:     #fef2f2;
  --danger-100:    #fee2e2;

  --warning:       #f59e0b;
  --warning-50:    #fffbeb;
  --warning-100:   #fef3c7;

  --bg:            #e8ecf6;
  --surface:       #ffffff;
  --surface-2:     #edf0fa;

  --text-1:        #0f172a;
  --text-2:        #475569;
  --text-3:        #94a3b8;

  --border:        #e2e8f0;
  --border-2:      #cbd5e1;

  --shadow-xs:     0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow:        0 2px 8px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.07);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.09), 0 20px 48px rgba(0,0,0,.12);

  --r-sm:  8px;
  --r:     14px;
  --r-lg:  20px;
  --r-xl:  28px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img, audio { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #312e81 0%, #6d28d9 100%);
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 3px 16px rgba(49,46,129,.35);
}
.topbar-brand {
  font-weight: 900;
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand-dot {
  width: 10px; height: 10px;
  background: #fbbf24;
  border-radius: 50%;
  flex-shrink: 0;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav a {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  padding: 7px 14px;
  border-radius: 99px;
  white-space: nowrap;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.topbar-nav a:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}
.topbar-nav a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.35);
}

/* ── Hide desktop nav on mobile, add bottom padding ── */
@media (max-width: 640px) {
  .topbar-nav { display: none; }
  body { padding-bottom: 74px; }
}

/* ── Bottom Tab Nav (mobile only) ── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: #fff;
  border-top: 2px solid #e5e7eb;
  box-shadow: 0 -4px 24px rgba(0,0,0,.10);
  padding: 6px 0 env(safe-area-inset-bottom, 4px);
  justify-content: space-around;
  align-items: stretch;
}
@media (max-width: 640px) { .bottom-nav { display: flex; } }

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  text-decoration: none;
  color: #9ca3af;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  transition: color .15s;
  position: relative;
  border-top: 3px solid transparent;
}
.bottom-nav a:hover { color: #4338ca; text-decoration: none; }
.bottom-nav a.active {
  color: #4338ca;
  border-top-color: #4338ca;
}
.bottom-nav a.disabled {
  color: #d1d5db;
  pointer-events: none;
  cursor: default;
}
.bn-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: block;
}

/* ── Page container ── */
.page { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.page-lg { max-width: 900px; margin: 0 auto; padding: 24px 16px 48px; }

/* ── Breadcrumb ── */
.crumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px;
  font-size: 0.8rem; color: var(--text-3); margin-bottom: 8px;
}
.crumb a { color: var(--text-2); font-weight: 500; }
.crumb a:hover { color: var(--primary); text-decoration: none; }
.crumb-sep { color: var(--border-2); }

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text-1); line-height: 1.3; }
.page-sub { font-size: 0.85rem; color: var(--text-2); margin-top: 4px; }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-header h2 { font-size: 0.9rem; font-weight: 600; color: var(--text-1); }
.card-body { padding: 16px 18px; }

/* ── Inputs ── */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.input-wrap { position: relative; }
input[type=text],
input[type=number],
input[type=file],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  color: var(--text-1);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
input[type=text]:focus,
input[type=number]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.14);
  outline: none;
}
input[type=file] { padding: 8px 12px; cursor: pointer; font-size: 0.875rem; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }

.input-row { display: flex; gap: 10px; }
.input-row input { flex: 1; min-width: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border: none; border-radius: var(--r-sm);
  font-size: 0.875rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all .15s; white-space: nowrap;
  min-height: 42px;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-purple   { background: var(--purple);   color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); filter: none; }
.btn-soft-primary { background: var(--primary-50); color: var(--primary-600); }
.btn-soft-danger  { background: var(--danger-50);  color: var(--danger); }
.btn-full { width: 100%; }
.btn-sm   { padding: 7px 12px; font-size: 0.8rem; min-height: 34px; }
.btn-add  {
  background: transparent; color: var(--primary);
  border: 1.5px dashed rgba(99,102,241,.4);
  width: 100%; margin-top: 10px;
  font-size: 0.875rem; font-weight: 500;
}
.btn-add:hover { background: var(--primary-50); filter: none; border-color: var(--primary); }

/* Icon button */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: none; border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
  color: var(--text-3); font-size: 0.95rem;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text-2); }
.btn-icon.edit:hover  { background: var(--primary-50); color: var(--primary); }
.btn-icon.del:hover   { background: var(--danger-50);  color: var(--danger); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 99px; font-size: 0.72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-blue    { background: var(--primary-50);  color: var(--primary-600); }
.badge-purple  { background: var(--purple-50);   color: #6d28d9; }
.badge-green   { background: var(--success-50);  color: #047857; }
.badge-orange  { background: var(--warning-50);  color: #92400e; }
.badge-gray    { background: var(--surface-2);   color: var(--text-2); }

/* ── Alerts ── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-sm);
  font-size: 0.875rem; margin-bottom: 16px;
  line-height: 1.5;
}
.alert-ok   { background: var(--success-50);  color: #065f46; border: 1px solid var(--success-100); }
.alert-warn { background: var(--warning-50);  color: #78350f; border: 1px solid var(--warning-100); }
.alert-err  { background: var(--danger-50);   color: #991b1b; border: 1px solid var(--danger-100); }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.875rem; min-width: 400px; }
.tbl thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl tbody td { padding: 12px 16px; vertical-align: middle; }
.tbl .actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.empty-row td { text-align: center; color: var(--text-3); padding: 40px 16px; font-size: 0.875rem; }

/* Mobile cards (table → card) */
@media (max-width: 580px) {
  .tbl-wrap { overflow: visible; }
  .tbl { min-width: unset; }
  .tbl thead { display: none; }
  .tbl tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    padding: 4px 0;
  }
  .tbl tbody tr:hover { background: var(--surface); }
  .tbl tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
  }
  .tbl tbody td:last-child { border-bottom: none; }
  .tbl tbody td::before {
    content: attr(data-label);
    font-size: 0.72rem; font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase; letter-spacing: 0.4px;
    margin-right: 12px; flex-shrink: 0;
  }
  .tbl .actions { justify-content: flex-start; }
  .empty-row td { display: block; }
  .empty-row td::before { display: none; }
}

/* ── Item Card (list → individual cards) ── */
.item-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 10px;
  text-decoration: none; color: inherit;
  transition: box-shadow .18s, border-color .18s, transform .18s;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
.item-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary-100);
  transform: translateY(-2px);
  text-decoration: none;
}
.item-card:active { transform: translateY(0); box-shadow: var(--shadow-xs); }

/* Nomor / icon bulat kiri */
.ic-num {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-50); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem;
}

/* Teks tengah */
.ic-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ic-title {
  font-weight: 600; font-size: 0.95rem; color: var(--text-1);
  word-break: break-word; line-height: 1.4;
}

/* Baris bawah: meta + aksi */
.ic-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ic-meta { font-size: 0.78rem; color: var(--text-3); }

/* Kanan: aksi + panah */
.ic-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Tombol panah kanan — penanda navigasi */
.ic-arrow {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; flex-shrink: 0;
  transition: background .15s;
}
.item-card:hover .ic-arrow { background: var(--primary-600); }

/* Separator antara card list dan card container */
.card-list { margin-bottom: 0; }
.card-list .card-body { padding: 16px 18px; }

/* ── Sub item (subtitle form rows) ── */
.sub-item {
  background: #fafbff;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
.sub-item-header {
  font-size: 0.75rem; font-weight: 700;
  color: var(--primary); text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sub-grid .full { grid-column: 1 / -1; }
.sub-item .remove-btn { position: absolute; top: 10px; right: 10px; }

@media (max-width: 480px) {
  .sub-grid { grid-template-columns: 1fr; }
  .sub-grid .full { grid-column: 1; }
}

/* ── Modal ── */
.modal { display: none; position: fixed; inset: 0; z-index: 300; align-items: flex-end; justify-content: center; }
.modal.open { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); }
.modal-box {
  position: relative;
  background: var(--surface);
  width: 100%; max-width: 460px;
  margin: 0 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(.32,.72,0,1);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Pull bar */
.modal-box::before {
  content: '';
  display: block; margin: 10px auto 0;
  width: 36px; height: 4px;
  background: var(--border); border-radius: 99px;
}
.modal-head {
  padding: 14px 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: var(--surface-2); border: none; cursor: pointer;
  color: var(--text-2); font-size: 0.9rem; font-weight: 600;
  width: 28px; height: 28px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
}
.modal-foot .btn { flex: 1; }

/* Mobile: angkat modal-box di atas bottom nav */
@media (max-width: 639px) {
  .modal-box {
    margin-bottom: 64px;
    max-height: calc(92vh - 64px);
  }
}

/* Desktop: centered modal */
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-box { border-radius: var(--r-lg); margin: 16px; }
  .modal-box::before { display: none; }
}

/* ── Confirm modal ── */
.confirm-body { padding: 28px 24px; text-align: center; }
.confirm-emoji { font-size: 2.5rem; margin-bottom: 14px; }
.confirm-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.confirm-desc  { font-size: 0.875rem; color: var(--text-2); margin-bottom: 24px; line-height: 1.6; }

/* ── Num pill ── */
.num-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  background: var(--purple-50); color: #6d28d9;
  border-radius: 8px; font-size: 0.8rem; font-weight: 700;
}

/* ── Audio ── */
audio { height: 32px; width: 100%; max-width: 220px; }
.audio-label { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; word-break: break-all; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.check-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; accent-color: var(--danger); }
.check-row span { font-size: 0.82rem; color: var(--text-2); }

/* ── Collapse ── */
.collapse-btn { cursor: pointer; user-select: none; }
.collapse-arrow { transition: transform .2s; display: inline-block; }
.collapse-arrow.open { transform: rotate(90deg); }
.collapse-body { display: none; }
.collapse-body.open { display: block; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 60px 24px;
  background: var(--surface); border-radius: var(--r); border: 1px solid var(--border);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p  { font-size: 0.875rem; color: var(--text-2); }

/* ── Utility ── */
.text-muted { color: var(--text-2); }
.text-subtle { color: var(--text-3); }
.fw-600 { font-weight: 600; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.flex-end { display: flex; justify-content: flex-end; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.w-full { width: 100%; }
