/* Tambahan di atas styles.css + dashboard-data.css milik prototype.
   Hanya berisi yang belum ada di sana. */

/* Nav kini memakai <a>, bukan <button> seperti pada prototype statis. */
nav a.nav { text-decoration: none; }

.brand-logo {
  width: 44px; height: 44px; flex: 0 0 auto; object-fit: contain;
}
.sidebar .brand { padding-bottom: 22px; }
.sidebar .brand strong { font-size: 18px; }
.sidebar nav {
  flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px;
  align-content: start; grid-auto-rows: min-content;
  scrollbar-width: thin; scrollbar-color: #ffffff24 transparent;
}
.nav-group { margin: 0; }
.nav-group summary { list-style: none; user-select: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary > span:first-child { width: auto; font-size: inherit; }
.nav-group .nav-chevron {
  width: auto; margin-left: auto; font-size: 15px; transition: transform .18s ease;
}
.nav-group[open] .nav-chevron { transform: rotate(180deg); }
.nav.active-parent { color: #fff; }
.nav-submenu { display: grid; gap: 3px; padding: 3px 0 7px 13px; }
.nav-sub {
  display: flex; align-items: center; gap: 8px; min-height: 38px;
  padding: 9px 11px 9px 17px; border-left: 1px solid #ffffff24;
  color: #a9c1d7; font-size: 12px; font-weight: 600; text-decoration: none;
}
.nav-sub:hover, .nav-sub.active { color: #fff; border-left-color: #4ed4ca; }
.nav-sub.active { background: #ffffff10; border-radius: 0 8px 8px 0; }
.nav-count {
  margin-left: auto; color: #c8e5ff; font-size: 11px; font-weight: 800;
}

/* Tombol keluar pada kartu profil. */
.profile form { margin-left: auto; }
.profile form button {
  background: none; border: 0; color: #9db4c7; cursor: pointer; font-size: 15px;
}
.profile form button:hover { color: #fff; }

/* Flash message. */
.flash {
  border-radius: 10px; padding: 12px 16px; font-size: 13px; font-weight: 600;
  margin-bottom: 16px;
}
.flash-ok { background: #e4f7f1; color: #087d69; border: 1px solid #b7e6d8; }
.flash-error { background: #feecec; color: #c53d3d; border: 1px solid #f6c9c9; }

/* Halaman login. */
.login-shell {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, #092542, #0c3157);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 34px;
  width: min(410px, 100%); box-shadow: 0 25px 80px #09254255;
}
.login-card .brand { border-bottom: 0; padding: 0 0 24px; color: var(--ink); }
.login-card .brand-logo { width: 52px; height: 52px; }
.login-card .brand strong { font-size: 22px; letter-spacing: .1em; }
.login-card label {
  display: grid; gap: 6px; font-size: 12px; font-weight: 700;
  color: #536273; margin-bottom: 14px;
}
.login-card input {
  padding: 11px; border: 1px solid #d9e2ea; border-radius: 8px; outline: 0; font: inherit;
}
.login-card input:focus { border-color: var(--blue); }
.login-card .primary { width: 100%; margin-top: 6px; }
.login-error {
  background: #feecec; color: #c53d3d; border-radius: 8px;
  padding: 10px 12px; font-size: 12px; margin-bottom: 14px;
}
/* Panel detail case (Bab 22.2: kiri metadata, tengah timeline, kanan aksi). */
.case-grid { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1200px) { .case-grid { grid-template-columns: 1fr; } }

.meta-row {
  display: grid; gap: 3px; padding: 11px 0; border-bottom: 1px solid #edf1f5; font-size: 12px;
}
.meta-row:last-child { border-bottom: 0; }
.meta-row span { color: var(--muted); font-size: 11px; }
.meta-row strong { color: #1c2d3e; font-weight: 700; }

/* Timeline kronologis. */
.timeline { list-style: none; margin: 14px 0 0; padding: 0 0 0 18px; border-left: 2px solid #e7edf3; }
.timeline li { position: relative; padding: 0 0 18px 16px; font-size: 12px; }
.timeline li:before {
  content: ""; position: absolute; left: -25px; top: 3px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--blue); border: 2px solid #fff;
}
.timeline li.is-closed:before { background: var(--teal); }
.timeline li.is-alert:before { background: #ef4444; }
.timeline strong { display: block; color: #1c2d3e; }
.timeline small { display: block; color: #91a0ad; margin-top: 2px; }
.timeline em { font-style: normal; color: #536273; display: block; margin-top: 3px; }

/* Form aksi workflow. */
.action-form { display: grid; gap: 10px; margin-top: 12px; }
.action-form label { display: grid; gap: 5px; font-size: 11px; font-weight: 700; color: #536273; }
.action-form input, .action-form select, .action-form textarea {
  padding: 9px; border: 1px solid #d9e2ea; border-radius: 8px; outline: 0; font: inherit; font-size: 12px;
}
.action-form input:focus, .action-form select:focus, .action-form textarea:focus { border-color: var(--blue); }
.action-form .primary { padding: 9px 14px; font-size: 12px; }
.action-block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.action-block:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.action-block h4 { margin: 0; font-size: 12px; color: #1c2d3e; }
.action-block p { margin: 4px 0 0; font-size: 11px; color: var(--muted); }

.error-text { color: #c53d3d; font-size: 11px; font-weight: 600; }
.empty-state { text-align: center; padding: 35px; color: var(--muted); font-size: 12px; }

/* Filter bar daftar surat. */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.filter-bar input, .filter-bar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; outline: 0;
  font: inherit; font-size: 13px; background: #fff;
}
.filter-bar input { flex: 1; min-width: 220px; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--blue); }

/* Paginator. */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 12px; }
.pager a, .pager button, .pager span {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: #536273; text-decoration: none; font: inherit;
}
.pager button { cursor: pointer; }
.pager button:disabled { cursor: wait; opacity: .65; }
.pager .active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pager .disabled { opacity: .45; }

/* Catatan cakupan fase. */
.phase-note {
  background: #f7f9fb; border: 1px dashed #cfdae4; border-radius: 10px;
  padding: 12px 15px; font-size: 12px; color: #5b6b7c; margin-top: 16px;
}
.phase-note strong { color: #1c2d3e; display: block; margin-bottom: 3px; }

/* AI Assistant — .chat-result pada prototype berupa <div>, di sini <a>
   yang bisa diklik menuju detail case. */
.chat-result { display: block; text-decoration: none; cursor: pointer; }
.chat-result:hover { border-color: var(--blue); }
.chat-mode {
  display: inline-block; margin-top: 8px; font-size: 9px; letter-spacing: .06em;
  text-transform: uppercase; color: #8fa2b4; background: #f1f5f9;
  border-radius: 5px; padding: 2px 7px;
}
.chat-messages b { color: inherit; }
.chatbox[hidden] { display: none !important; }

/* ---- SI MERPATI: peluncur & kepala chatbox ---- */

/* Peluncur hanya memuat merpati putih, tanpa teks: tombolnya bulat supaya
   siluetnya jadi penanda, bukan labelnya. */
.chat-launcher {
  width: 58px; height: 58px; padding: 0; border-radius: 50%;
  justify-content: center;
  background: linear-gradient(140deg, #0b5fc6, #0b2746);
}
.chat-launcher img { width: 32px; height: 32px; display: block; }
.chat-launcher:hover { filter: brightness(1.08); }

.chat-title { display: flex; align-items: center; gap: 9px; }
.chat-title img { width: 22px; height: 22px; display: block; }
.chat-title strong { font-size: 14px; letter-spacing: .04em; }

/* ---- Jawaban cepat: satu tombol, lalu topik, lalu pertanyaan ---- */
.chat-quick { padding: 9px 12px; border-top: 1px solid #e5ebf1; background: #fbfdff; }

/* Keadaan tertutup — satu tombol selebar panel. */
.chat-quick-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  border: 1px solid #cbdbea; background: #f5f9ff; color: #245a94;
  border-radius: 10px; padding: 10px 12px; font: inherit; cursor: pointer;
  transition: .15s; text-align: left;
}
.chat-quick-toggle:hover { border-color: #2563eb; background: #eaf2ff; }
.chat-quick-toggle b { font-size: 11.5px; }
.chat-quick-chevron { margin-left: auto; font-size: 12px; color: #7e93a8; }

/* Keadaan terbuka — baris judul dengan tombol tutup di ujung. */
.chat-quick-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.chat-quick-label {
  font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: #8fa2b4;
}
.chat-quick-close {
  margin-left: auto; border: 0; background: none; color: #7e93a8;
  font: inherit; font-size: 15px; line-height: 1; padding: 0 2px; cursor: pointer;
}
.chat-quick-close:hover { color: #2563eb; }

/* Daftar tombol dibatasi tingginya: 31 pertanyaan tidak boleh mendorong
   percakapan keluar layar, jadi panel ini menggulir sendiri. */
.chat-topics {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 168px; overflow-y: auto; padding-right: 2px;
}

/* Tahap topik — dua kolom agar judulnya terbaca utuh. */
.chat-topics button {
  flex: 1 1 calc(50% - 6px); min-width: 0;
  /* Tinggi dipatok: tanpa ini, satu judul yang membungkus ke dua baris
     membuat seluruh tombol pada baris itu ikut meninggi (flex-wrap
     meregangkan item setinggi item tertinggi), sehingga kotak tampak
     berbeda ukuran padahal isinya sejenis. */
  min-height: 33px;
  display: flex; align-items: center; gap: 6px;
  border: 1px solid #cbdbea; background: #f5f9ff; color: #245a94;
  border-radius: 9px; padding: 8px 9px; font: inherit; font-size: 10.5px;
  font-weight: 700; text-align: left; cursor: pointer; transition: .15s;
}
.chat-topics button:hover { border-color: #2563eb; background: #eaf2ff; }

/* Kotak ikon berukuran TETAP dan sama untuk semua topik.
   Ikonnya bercampur dua jenis: glif teks (⚑ ▦ ⚠ ↓ ◫ ⌕ ⚙) dan satu SVG untuk
   jam pasir. Keduanya punya ukuran alami yang berbeda — .ui-icon 20px versus
   glif 13px — sehingga tanpa patokan ini satu tombol selalu tampak lebih
   besar daripada tetangganya.
   Jam pasir memakai SVG karena ⌛ (U+231B) berproperti Emoji_Presentation=Yes:
   peramban merendernya sebagai emoji berwarna, bukan glif garis. font-variant-emoji
   menjaga agar karakter lain yang bersifat serupa (mis. ⚠, ⚙) tetap tampil
   sebagai teks. */
.chat-topics button > span,
.chat-topics button > .chat-topic-icon {
  flex: 0 0 15px;
  width: 15px; height: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; line-height: 1;
  font-variant-emoji: text;
}
.chat-topics button > .chat-topic-icon { stroke-width: 2.2; }

/* Tahap pertanyaan — pil selebar isinya, satu kolom penuh bila panjang. */
.chat-topics.is-ask button { flex: 0 1 auto; font-weight: 600; border-radius: 14px; }

.chat-back {
  border: 0; background: none; color: #5b7793; font: inherit; font-size: 10px;
  font-weight: 700; padding: 0; cursor: pointer;
}
.chat-back:hover { color: #2563eb; }

.chat-message i { color: #7c8ea0; font-size: 11px; }

/* ---- Priority & Decision Center (Bab 12) ---- */
.queue-tabs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px; margin: 16px 0;
}
.queue-tab {
  text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 11px; padding: 13px 15px; cursor: pointer; font: inherit;
  display: grid; gap: 3px; transition: .15s;
}
.queue-tab:hover { border-color: #b9cbe0; }
.queue-tab.active { border-color: var(--blue); box-shadow: 0 0 0 2px #2563eb22; }
.queue-tab span { font-size: 12px; color: #536273; font-weight: 700; }
.queue-tab strong { font-size: 23px; color: #1c2d3e; }
.queue-tab small { font-size: 10px; color: var(--muted); line-height: 1.4; }

.queue-hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; }

.decision-card { margin-bottom: 12px; padding: 16px 18px; }
.dc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.dc-overview { min-width: 0; }
.dc-title { margin: 0; font-size: 16px; line-height: 1.35; color: #1c2d3e; }
.dc-status { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.dc-head .text-btn { flex: 0 0 auto; padding-top: 2px; }
.dc-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 16px; margin: 14px 0 10px; padding: 10px 0; border-top: 1px solid #edf1f5;
}
.dc-meta span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dc-meta strong { font-size: 12px; color: #1c2d3e; }
.dc-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 18px; }
@media (max-width: 900px) { .dc-body { grid-template-columns: 1fr; } }
.dc-body span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.dc-body p { margin: 0; font-size: 12px; color: #536273; line-height: 1.5; }
.dc-ask p { color: #1c2d3e; font-weight: 600; }
@media (max-width: 600px) {
  .dc-head { gap: 10px; }
  .dc-title { font-size: 14px; }
}

/* ---- Notification center (Bab 17) ---- */
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; right: 0; top: 48px; width: min(400px, 90vw);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 20px 50px #0925421f; z-index: 30; overflow: hidden;
}
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 15px; border-bottom: 1px solid var(--line);
}
.notif-head strong { font-size: 13px; }
.notif-head button { border: 0; background: none; color: var(--blue); font-weight: 700; font-size: 11px; cursor: pointer; }
.notif-list { max-height: 380px; overflow: auto; }
.notif-item {
  display: block; padding: 12px 15px; border-bottom: 1px solid #eef2f6;
  text-decoration: none; color: inherit;
}
.notif-item:hover { background: #f7f9fb; }
.notif-item strong { display: block; font-size: 12px; color: #1c2d3e; }
.notif-item p { margin: 3px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.notif-item time { display: block; margin-top: 4px; font-size: 10px; color: #9aa8b6; }
.notif-empty { padding: 30px 15px; text-align: center; color: var(--muted); font-size: 12px; }

/* ---- Modul tata ruang (Bab 14.4) ---- */
.spatial-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin: 16px 0;
}
.sc {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid #cfdae4;
  border-radius: 10px; padding: 13px 15px;
}
.sc span { display: block; font-size: 11px; color: var(--muted); }
.sc strong { display: block; font-size: 22px; color: #1c2d3e; margin-top: 3px; }

/* Grid item CSS Grid tidak boleh lebih sempit dari kontennya secara default,
   sehingga panel dengan form/tabel lebar meluber keluar kolom. */
.grid > *, .case-grid > * { min-width: 0; }
.action-form input, .action-form select, .action-form textarea { max-width: 100%; }

/* Flash message kini punya tombol tutup. */
.flash { display: flex; align-items: center; gap: 12px; }
.flash span { flex: 1; }
.flash button {
  border: 0; background: none; color: inherit; opacity: .55;
  font-size: 19px; line-height: 1; cursor: pointer;
}
.flash button:hover { opacity: 1; }

/* Ikon antarmuka memakai stroke currentColor agar bentuknya satu warna dan
   tetap mengikuti warna komponen yang sudah ada. */
.ui-icon {
  width: 20px; height: 20px; display: block; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.bell {
  color: #536273; display: grid; place-items: center; padding: 0; cursor: pointer;
}
.bell .ui-icon { width: 19px; height: 19px; }

.sidebar-backdrop { display: none; }
.sidebar-backdrop[hidden] { display: none; }

/* Tablet portrait dan ponsel: navigasi menjadi off-canvas supaya isi halaman
   tetap mendapat lebar penuh. iPad landscape tetap memakai layout desktop. */
@media (max-width: 900px) {
  body.sidebar-open { overflow: hidden; }
  .app { display: block; }
  .sidebar {
    width: min(286px, calc(100vw - 48px));
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 18px 0 45px #09254233;
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 9; border: 0;
    background: #09254280; opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .app main { width: 100%; }
  header { height: 72px; padding: 0 18px; }
  .menu {
    display: grid; place-items: center; width: 40px; height: 40px;
    padding: 0; margin-right: 10px; border: 0; background: transparent;
    color: var(--ink); font-size: 22px; cursor: pointer;
  }
  .content { padding: 18px 18px 36px; }
  .grid { grid-template-columns: 1fr !important; }
  .stats, .closure-kpis, .spatial-stats, .followup-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .briefing-grid { grid-template-columns: 1fr; }
  .panel-head { gap: 12px; flex-wrap: wrap; }
  .table-wrap { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .responsive-cards { display: block; min-width: 0; }
  .responsive-cards thead { display: none; }
  .responsive-cards tbody {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px; padding: 0 12px 12px;
  }
  .responsive-cards tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px 14px; padding: 13px; border: 1px solid var(--line);
    border-radius: 10px; background: #fff;
  }
  .responsive-cards td {
    display: block; min-width: 0; padding: 0; border: 0;
    overflow-wrap: anywhere;
  }
  .responsive-cards td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 4px;
    color: #718090; font-size: 9px; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
  }
  .responsive-cards td:first-child,
  .responsive-cards td[data-label="Email"],
  .responsive-cards td[data-label="Perihal"],
  .responsive-cards td[data-label="Aksi"] { grid-column: 1 / -1; }
  .responsive-cards td:first-child {
    padding-bottom: 10px; border-bottom: 1px solid #edf1f5;
  }
  .responsive-cards td[data-label="Aksi"] {
    padding-top: 9px; border-top: 1px solid #edf1f5; text-align: right;
  }
  .responsive-cards .empty-state { grid-column: 1 / -1; padding: 24px 8px; }
  .notif-panel { width: min(400px, calc(100vw - 36px)); }
  .chatbox { height: min(560px, calc(100dvh - 104px)); }
}

@media (max-width: 600px) {
  header h1 { max-width: calc(100vw - 140px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 14px 12px 30px; }
  .section-head { margin: 16px 0 12px; }
  .panel { padding: 15px; }
  .table-wrap { margin-left: -15px; margin-right: -15px; }
  .filter-bar { display: grid; grid-template-columns: 1fr; }
  .filter-bar input, .filter-bar select, .filter-bar button { width: 100%; min-width: 0; }
  .responsive-cards tbody { grid-template-columns: 1fr; }
  .queue-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .queue-tab { min-width: 0; padding: 11px 12px; }
  .dc-head { flex-direction: column; gap: 9px; }
  .dc-head .text-btn { padding-top: 0; }
  .notif-panel { position: fixed; top: 64px; right: 12px; left: 12px; width: auto; }
  .notif-head { align-items: flex-start; gap: 8px; }
  .notif-list { max-height: calc(100dvh - 130px); }
  .chat-launcher { right: 12px; bottom: 12px; }
  .chatbox {
    right: 8px; bottom: 76px; width: calc(100vw - 16px);
    height: min(600px, calc(100dvh - 88px)); border-radius: 12px;
  }
  .chat-topics button { flex-basis: 100%; }
  dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
  .login-shell { min-height: 100dvh; padding: 16px; }
  .login-card { padding: 24px; }
}

@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-backdrop, .nav-group .nav-chevron { transition: none; }
}
