/* ==========================================================================
   SIMPEL-U UI Theme — Fase 1 (port bahasa visual SIMAPRO)
   --------------------------------------------------------------------------
   Satu-satunya sumber kebenaran untuk token global:
   - Palet brand biru/navy SIMAPRO (:root --primary dkk).
   - Hirarki tipografi Plus Jakarta Sans (body 14px/1.5, h1 20px/600,
     h2 18px/600 — nilai yang dikunci ui-theme SIMAPRO).
   - Status pill dengan SEMANTIK YANG SAMA, hanya hex diseragamkan
     (menunggu = kuning, diproses = biru, disetujui/selesai = hijau,
     revisi/tolak/ditolak = merah).

   Aturan main:
   - theme-styles.php memuat file ini di akhir head operasional, sesudah
     stylesheet modul. Carrier favicon hanya memuat font bersama.
   - app-shell-theme.css dan admin-events-theme.css mengatasi literal
     legacy tanpa menyentuh sumber bersama publik atau encoding ikon.
   - Class/kunci spesifik per modul TIDAK didefinisikan ulang di sini;
     modul tetap memakai stylesheet-nya sendiri untuk hal yang memang
     khas modul.
   - DILARANG mengubah controller/repository/route/permission/guard.
   ========================================================================== */

:root {
  /* Brand SIMAPRO (menggantikan marun). Nama --primary* dipertahankan agar
     selaras dengan konvensi ui-theme SIMAPRO. */
  --primary: #0056a6;
  --primary-dark: #003b73;
  --primary-light: #0a6ed1;
  --ui-navy: #16295c;
  --ui-background: #f1f4fa;
  --ui-border: #dbe3f0;
  --ui-muted: #5b6b86;
  --ui-radius: 12px;
  --ui-font: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;

  /* Alias ke token app-shell SIMPEL-U agar seluruh komponen lama yang
     memakai var(--accent)/var(--bg-*) ikut berpindah palet otomatis. */
  --bg-main: var(--ui-background);
  --bg-surface: #ffffff;
  --bg-sidebar: var(--ui-navy);
  --bg-sidebar-soft: #1e3a6e;
  --text-main: #212529;
  --text-soft: var(--ui-muted);
  --line: var(--ui-border);
  --accent: var(--primary);
  --accent-strong: var(--primary-dark);
  --dash-brand-ink: var(--ui-navy);
  --dash-brand-primary: var(--primary);
  --dash-brand-primary-soft: #edf6fe;
  --dash-brand-cyan: var(--primary-light);
}

/* -- Tipografi global (SIMAPRO: satu font untuk semua) ------------------- */
.questionnaire-page,
body.app-shell,
body.app-shell button,
body.app-shell input,
body.app-shell select,
body.app-shell textarea {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
}

body.app-shell {
  font-size: 14px;
  line-height: 1.5;
  color: #212529;
  background: var(--ui-background);
}

/* Hirarki heading ala SIMAPRO (h1 20px/600, h2 18px/600).
   !important diperlukan karena banyak stylesheet modul memakai
   specificity tinggi untuk .page-title dkk. */
.questionnaire-page h1,
.shell-main h1,
.shell-main .page-title {
  font-size: 20px !important;
  font-weight: 600 !important;
  line-height: 1.4;
}

.questionnaire-page h2,
.shell-main h2 {
  font-size: 18px !important;
  font-weight: 600 !important;
  line-height: 1.4;
}

.shell-main h3,
.shell-main h4 {
  font-weight: 600 !important;
}

/* SIMAPRO menormalkan .font-bold dkk ke 600 */
.shell-main .font-bold,
.shell-main .font-extrabold,
.shell-main .font-black {
  font-weight: 600;
}

.shell-main .text-xs {
  font-size: 12px;
}

.shell-main .text-sm {
  font-size: 14px;
}

/* -- Permukaan kartu: radius/border/shadow SIMAPRO ------------------------ */
.questionnaire-page .card,
.questionnaire-page .stat,
.shell-main .panel,
.shell-main .dashboard-panel,
.shell-main .proposal-panel,
.shell-main .surat-panel,
.shell-main .disposisi-panel {
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius) !important;
  box-shadow: 0 3px 12px rgba(22, 41, 92, 0.035) !important;
}

.questionnaire-page {
  background-color: var(--ui-background);
  font-size: 14px;
  line-height: 1.5;
}

/* -- Kontrol form & tombol: min-height 44px, radius 8px ------------------ */
.shell-main input:not([type='checkbox']):not([type='radio']):not([type='hidden']):not([type='file']),
.shell-main select,
.shell-main textarea {
  min-height: 44px;
  border-radius: 8px;
  font-size: 14px;
  border-color: #c4cfe4;
  background-color: #fff;
}

.shell-main button,
.shell-main .filter-chip,
.shell-main .preset-filter-chip,
.shell-main .type-filter,
.shell-main .role-filter,
.shell-main .fin-filter,
.shell-main .tab-chip {
  border-radius: 8px;
}

.shell-main button:not([class*='absolute']):not([class*='rounded-full']) {
  min-height: 44px;
}

/* -- Tabel: 14px, thead terang, th muted uppercase ------------------------ */
.shell-main table {
  font-size: 14px;
}

.shell-main thead {
  background: #f7f9fd;
}

.shell-main th {
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.shell-main th,
.shell-main td {
  border-color: var(--ui-border);
}

.shell-main td {
  line-height: 1.5;
}

/* Fokus keyboard yang terlihat (SIMAPRO memakai outline #85b7e6) */
.shell-main a:focus-visible,
.shell-main button:focus-visible,
.shell-main summary:focus-visible,
.shell-main input:focus-visible,
.shell-main select:focus-visible,
.shell-main textarea:focus-visible {
  outline: 3px solid #85b7e6;
  outline-offset: 3px;
}

/* -- Status pill: semantik dikunci, hanya hex diseragamkan ----------------
   menunggu = kuning | diproses = biru | disetujui/selesai = hijau |
   revisi/tolak/ditolak = merah. Mencakup varian class yang dipakai
   modul-modul SIMPEL-U (.status-*, .pill.surat-status.*, .status-badge.*). */
.shell-main .status-menunggu,
.shell-main .badge-menunggu,
.shell-main .pill.surat-status.status-menunggu,
.shell-main .status-badge.status-menunggu {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}

.shell-main .status-diproses,
.shell-main .badge-diproses,
.shell-main .pill.surat-status.status-diproses {
  background: #edf6fe !important;
  color: #0056a6 !important;
  border-color: #c4dff6 !important;
}

.shell-main .status-diterima,
.shell-main .status-disetujui,
.shell-main .status-selesai,
.shell-main .badge-disetujui,
.shell-main .badge-selesai,
.shell-main .pill.surat-status.status-disetujui,
.shell-main .status-badge.status-disetujui {
  background: #e7f6ec !important;
  color: #237452 !important;
  border-color: #a7e3c0 !important;
}

.shell-main .status-revisi,
.shell-main .status-tolak,
.shell-main .status-ditolak,
.shell-main .badge-revisi,
.shell-main .badge-ditolak,
.shell-main .pill.surat-status.status-revisi,
.shell-main .pill.surat-status.status-ditolak,
.shell-main .status-badge.status-revisi,
.shell-main .status-badge.status-ditolak {
  background: #fee4e2 !important;
  color: #b42318 !important;
  border-color: #fecdca !important;
}

/* Halaman tanpa shell (login, error): font + heading yang sama.
   Halaman publik (landing/kip-calon) TIDAK disentuh — identitas publik
   tetap milik modul masing-masing. Tidak menyentuh layout/markup. */
.auth-page {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
}

.auth-page h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

/* -- Topbar ala SIMAPRO (port dari ui-theme.css SIMAPRO) --------------------
   Sticky navy #16295C 72px; grup 1 item = link langsung, >1 item =
   <details> dropdown; hamburger membuka menu vertikal di <=1199px.
   Hook sidebar lama dipertahankan tetapi dinonaktifkan oleh navigation.css.
   -------------------------------------------------------------------------- */
.ui-topbar {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 10px 24px;
  color: #fff;
  background: var(--ui-navy);
  box-shadow: 0 2px 8px rgba(22, 41, 92, 0.12);
  font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
}

.ui-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  color: #fff;
  text-decoration: none;
}

.ui-brand-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--primary);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.ui-brand strong {
  display: block;
  max-width: 180px;
  font-size: 14px;
  font-weight: 600;
}

.ui-brand small {
  display: block;
  font-size: 11px;
  color: #c4cfe4;
}

.ui-primary-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.ui-nav-group {
  position: relative;
}

.ui-topbar .nav-item,
.ui-topbar summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #e0e7f5;
  white-space: nowrap;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  text-decoration: none;
  border: 0;
  background: transparent;
  font-family: inherit;
}

.ui-topbar .nav-item .nav-label,
.ui-topbar summary span {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-shadow: none;
}

.ui-topbar .nav-item .nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

.ui-topbar .nav-item .nav-icon svg,
.ui-nav-chevron svg {
  width: 13px;
  height: 13px;
}

.ui-nav-chevron {
  display: inline-flex;
  margin-left: auto;
  font-size: 10px;
  opacity: 0.8;
}

.ui-topbar summary::-webkit-details-marker {
  display: none;
}

.ui-topbar .nav-item:hover,
.ui-topbar summary:hover,
.ui-topbar .is-active,
.ui-topbar details[open] > summary {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.ui-nav-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 240px;
  padding: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(22, 41, 92, 0.15);
  display: grid;
  gap: 2px;
  z-index: 130;
}

.ui-nav-panel .nav-item {
  color: #2f3b55;
  width: 100%;
}

.ui-nav-panel .nav-item .nav-label {
  color: inherit;
}

.ui-nav-panel .nav-item .nav-icon {
  border-color: #dbe3f0;
  background: #edf6fe;
  color: var(--primary);
}

.ui-nav-panel .nav-item:hover,
.ui-nav-panel .is-active {
  color: var(--primary);
  background: #edf6fe;
}

.ui-account {
  margin-left: auto;
  flex-shrink: 0;
}

.ui-account .ui-nav-panel {
  left: auto;
  right: 0;
}

.ui-account-avatar {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
}

.ui-account-name {
  padding: 8px 10px;
  border-bottom: 1px solid var(--ui-border);
  overflow-wrap: anywhere;
  font-size: 12px;
  color: #2f3b55;
}

.ui-account-name span {
  color: var(--ui-muted);
}

.ui-menu-toggle {
  display: none;
}

.ui-nav-badges {
  display: inline-flex;
  gap: 3px;
}

.ui-nav-badges > span {
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.ui-topbar-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  border: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.5);
}

.ui-topbar-overlay[hidden] {
  display: none;
}

/* Konten di bawah topbar: tanpa margin kiri sidebar (pola SIMAPRO:
   .app-main padding 24px clamp, max-width 1440px). */
body.app-shell .shell-main {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

body.app-shell .shell-main > :first-child {
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

/* Sidebar lama menjadi drawer mobile saja (hidden di desktop). */
@media (min-width: 1200px) {
  body.app-shell .sidebar,
  body.app-shell .mobile-topbar,
  body.app-shell .sidebar-backdrop,
  body.app-shell .ui-mobile-account {
    display: none !important;
  }

  body.app-shell .shell-main {
    padding: 24px clamp(16px, 3vw, 42px) !important;
  }
}

@media (max-width: 1199px) {
  .ui-topbar {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
    min-height: 64px;
  }

  .ui-brand strong {
    max-width: 150px;
  }

  .ui-account {
    display: none;
  }

  .ui-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 18px;
  }

  .ui-primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100dvh - 150px);
    overflow-y: auto;
    padding: 12px 16px;
    background: var(--ui-navy);
    flex-direction: column;
    align-items: stretch;
  }

  .ui-topbar.mobile-menu-open .ui-primary-nav {
    display: flex;
  }

  .ui-nav-panel {
    position: static;
    margin: 4px 0 8px;
    min-width: 0;
    box-shadow: none;
  }

  .ui-primary-nav > .nav-item,
  .ui-primary-nav summary {
    width: 100%;
  }

  .ui-mobile-account {
    display: grid;
    gap: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.19);
    margin-top: 8px;
    padding-top: 8px;
  }

  body.app-shell .shell-main {
    padding: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell-main *,
  .shell-main *::before,
  .shell-main *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
