/* =========================================================================
   FOSi Banten — Warm Cream & Gold / Institutional Minimalism
   Palet: Cream, Ivory, Deep Bronze, Gold, Ink
   ========================================================================= */
:root {
  --foc-bg: #FAF7F2;
  --foc-bg-alt: #F5EFE6;
  --foc-card: #FFFFFF;
  --foc-card-ivory: #FDFBF7;
  --foc-line: #E6DEC8;
  --foc-line-strong: #D6C9B2;
  --foc-primary: #5C3D2E;
  --foc-primary-hover: #4A3022;
  --foc-primary-soft: #F7F1EA;
  --foc-brass: #B48A3E;
  --foc-brass-soft: #F6E9D4;
  --foc-gold-dark: #8A6A32;
  --foc-ink: #2C221E;
  --foc-muted: #82715F;
  --foc-danger: #8F3A35;
  --foc-sans: "Plus Jakarta Sans", sans-serif;
  --foc-serif: "Newsreader", Georgia, serif;
  --foc-mono: "JetBrains Mono", monospace;
}

html { background: var(--foc-bg); scroll-behavior: smooth; }
body {
  font-family: var(--foc-sans);
  background-color: var(--foc-bg);
  color: var(--foc-ink);
  -webkit-tap-highlight-color: transparent;
}
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, .foc-serif, .foc-doc-title, .foc-doc-kop .instansi {
  font-family: var(--foc-serif);
  letter-spacing: -0.01em;
}
h1, h2 { font-weight: 600 !important; }
.tabular-nums { font-variant-numeric: tabular-nums; }
.foc-num,
#heroOpen, #heroInitialFilled, #heroReplacementFilled, #heroPending,
#dashSeatPercent, #dashSeatCount, #dashTotalQuota, #visaCountdown,
#badgeTabPending, #badgeTabSeat, #badgeTabArsip,
#sideBadgePending, #sideBadgeSeat, #sideBadgeArsip,
#mBadgePending, #mBadgeSeat, #mBadgeArsip,
#seatSlotCount, #seatCandidateCount {
  font-family: var(--foc-mono);
  font-variant-numeric: tabular-nums;
}
table td.text-right {
  font-family: var(--foc-mono);
  font-variant-numeric: tabular-nums;
}
table td.text-right button,
table td.text-right a,
table td.text-right .badge-text,
table td.text-right .inline-flex {
  font-family: var(--foc-sans);
}
summary::-webkit-details-marker { display: none; }

/* --- Kartu & permukaan --- */
.foc-card {
  background: var(--foc-card);
  border: 1px solid var(--foc-line);
  border-radius: 6px;
  box-shadow: none;
}
.foc-rule { border-color: var(--foc-line); }

/* --- Tabel padat data: header lengket + kolom pertama lengket --- */
.table-scroll::-webkit-scrollbar { width: 7px; height: 7px; }
.table-scroll::-webkit-scrollbar-track { background: #F5EFE6; }
.table-scroll::-webkit-scrollbar-thumb { background: #D6C9B2; border-radius: 9999px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #A79783; }
.table-scroll, .overflow-x-auto { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }

.foc-table, .responsive-table { border-collapse: collapse; }
.foc-table thead th, .responsive-table thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  font-family: var(--foc-sans);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  padding-top: 0.55rem !important;
  padding-bottom: 0.55rem !important;
}
.foc-table tbody td, .responsive-table tbody td {
  padding-top: 0.6rem !important;
  padding-bottom: 0.6rem !important;
  font-size: 0.72rem;
  vertical-align: top;
}
.foc-table thead th {
  background: #F5EFE6;
}
@media (min-width: 768px) {
  .foc-table thead th:first-child,
  .foc-table tbody td:first-child,
  .responsive-table thead th:first-child,
  .responsive-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 6;
    background: var(--foc-card);
  }
  .foc-table thead th:first-child {
    z-index: 16;
    background: #F5EFE6;
  }
  .responsive-table thead th:first-child {
    z-index: 16;
    background: var(--foc-primary);
  }
  .foc-table tbody tr:hover td:first-child,
  .responsive-table tbody tr:hover td:first-child { background: #FAF7F2; }
}

/* --- Sidebar full-height: expand / collapse --- */
#leftCategoryNav { flex: 0 0 16rem; min-width: 0; transition: flex-basis 0.18s ease; }
#leftCategoryNav.is-collapsed { flex-basis: 5rem !important; width: 5rem !important; }
#leftCategoryNav.is-collapsed .sidebar-label,
#leftCategoryNav.is-collapsed .side-badge { display: none !important; }
#leftCategoryNav.is-collapsed .sidebar-header {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
#leftCategoryNav.is-collapsed .side-cat-btn {
  width: 2.75rem;
  height: 2.75rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
  justify-content: center;
}
#leftCategoryNav.is-collapsed .menu-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 6px;
  background: #FAF7F2;
}
#leftCategoryNav.is-collapsed .side-cat-btn.is-active .menu-icon {
  background: rgba(255, 255, 255, 0.12);
}

/* --- Top bar: user dropdown --- */
#userMenuDropdown { transform-origin: top right; }
#userMenuDropdown:not(.hidden) { animation: foc-menu-in 0.14s ease-out; }
@keyframes foc-menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Notifikasi aksi --- */
@keyframes foc-progress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}
@keyframes foc-countdown {
  from { width: 100%; }
  to { width: 0%; }
}
.action-progress { animation: foc-progress 1.2s ease-in-out infinite; }
.notify-countdown {
  animation-name: foc-countdown;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes foc-toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.foc-toast {
  animation: foc-toast-in 0.18s ease-out;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.cell-flex { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.mobile-safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* --- Tab internal --- */
.foc-tab { border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; }
.foc-tab-active { border-bottom-color: var(--foc-primary); color: var(--foc-primary); background: var(--foc-primary-soft); }
.foc-subtab {
  border: 1px solid transparent;
  color: var(--foc-muted);
  background: transparent;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.foc-subtab:hover { background: var(--foc-primary-soft); color: var(--foc-primary); }
.foc-subtab-active,
.foc-subtab-active:hover {
  background: var(--foc-primary);
  border-color: var(--foc-primary);
  color: #FFFFFF;
}

/* --- Split view Pasangkan Kursi --- */
.seat-row-selected { background: var(--foc-primary-soft) !important; box-shadow: inset 3px 0 0 var(--foc-primary); }
.role-hidden { display: none !important; }
.filter-scroll { scrollbar-width: none; -ms-overflow-style: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.kverif-pill { white-space: nowrap; }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Slide-over drawer (detail, pratinjau, audit) --- */
#actionModal {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}
#actionModal.hidden { display: none; }
#actionDrawerBackdrop { animation: foc-fade-in 0.18s ease-out; }
#actionDrawerPanel {
  animation: foc-drawer-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes foc-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes foc-drawer-in {
  from { transform: translateX(24px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}
#actionDrawerPanel #modalBody {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}
#actionDrawerPanel #modalBody > * + * { margin-top: 0.85rem; }

/* --- Dokumen resmi siap cetak --- */
.foc-doc {
  background: #fff;
  color: var(--foc-ink);
  border: 1px solid var(--foc-line);
  border-radius: 6px;
  padding: 1.5rem;
  font-family: var(--foc-sans);
  font-size: 0.72rem;
  line-height: 1.6;
}
.foc-doc-kop {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid var(--foc-primary);
}
.foc-doc-kop img { width: 48px; height: 48px; object-fit: contain; flex: 0 0 auto; }
.foc-doc-kop .kemenag {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--foc-primary);
}
.foc-doc-kop .instansi { font-size: 0.98rem; font-weight: 600; line-height: 1.25; }
.foc-doc-kop .alamat { font-size: 0.62rem; color: var(--foc-muted); }
.foc-doc-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 1rem 0 0.15rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.foc-doc-sub { text-align: center; font-size: 0.68rem; color: var(--foc-muted); }
.foc-doc table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.foc-doc th, .foc-doc td {
  border: 1px solid var(--foc-line);
  padding: 0.3rem 0.45rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.68rem;
}
.foc-doc th { background: #F5EFE6; font-weight: 800; }
.foc-doc .mono { font-family: var(--foc-mono); font-variant-numeric: tabular-nums; }
.foc-doc .doc-sign { display: flex; justify-content: space-between; gap: 2rem; margin-top: 1.6rem; }
.foc-doc .doc-sign .sign { text-align: center; min-width: 12rem; }
.foc-doc .doc-sign .space { height: 3.2rem; }
.foc-doc .doc-note { margin-top: 1rem; font-size: 0.62rem; color: var(--foc-muted); }

/* --- Mode cetak: sembunyikan UI aplikasi, tampilkan dokumen --- */
@media print {
  body { background: #fff !important; }
  #mainAppScreen, #loginScreen, #authLoadingScreen, #toastContainer, header, nav, aside, footer,
  .no-print { display: none !important; }
  #actionModal { position: static !important; display: block !important; background: #fff !important; }
  #actionDrawerBackdrop { display: none !important; }
  #actionDrawerPanel {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    border: 0 !important;
    box-shadow: none !important;
    animation: none !important;
  }
  #actionDrawerPanel > div:first-child { display: none !important; }
  #modalBody { overflow: visible !important; padding: 0 !important; }
  .foc-doc { border: 0; padding: 0; }
  .foc-doc table { page-break-inside: auto; }
  .foc-doc tr { page-break-inside: avoid; }
  .foc-doc thead { display: table-header-group; }
}

/* ================= MOBILE & TABLET ================= */
@media (max-width: 767px) {
  #mainAppScreen main {
    padding-bottom: calc(8.5rem + env(safe-area-inset-bottom));
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
  #toastContainer {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(7.5rem + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    padding: 0;
  }
  #actionModal {
    align-items: flex-end !important;
    justify-content: center !important;
  }
  #actionDrawerPanel {
    position: relative !important;
    right: auto !important;
    top: auto !important;
    max-width: none !important;
    width: 100% !important;
    height: auto !important;
    max-height: 92vh;
    border-left: 0 !important;
    border-top: 1px solid var(--foc-line);
    border-radius: 6px 6px 0 0 !important;
    animation: foc-sheet-in 0.22s ease-out;
  }
  @keyframes foc-sheet-in {
    from { transform: translateY(24px); opacity: 0.7; }
    to { transform: translateY(0); opacity: 1; }
  }
  #actionDrawerPanel #modalBody { max-height: calc(92vh - 4.25rem); }

  /* Tabel menjadi kartu agar tidak perlu scroll horizontal. */
  .responsive-table { display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td { display: block; width: 100%; }
  .responsive-table tbody { padding: 0.35rem 0.5rem 0.6rem; }
  .responsive-table tbody tr {
    border: 1px solid var(--foc-line);
    border-radius: 6px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.55rem;
    background: #fff;
  }
  .responsive-table tbody tr:hover { background: #fff; }
  .responsive-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.2rem 0 !important;
    border: 0 !important;
    text-align: right;
    font-size: 0.7rem;
  }
  .responsive-table td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    text-align: left;
    font-size: 9px;
    line-height: 1.4;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--foc-muted);
  }
  .responsive-table td.cell-no { display: none !important; }
  .responsive-table td[data-label="Aksi"] {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.65rem !important;
    margin-top: 0.35rem;
    border-top: 1px dashed var(--foc-line) !important;
  }
  .responsive-table td[data-label="Aksi"]::before { display: none; }
  .responsive-table .cell-actions > div { width: 100%; }
  .responsive-table .cell-actions button { flex: 1 1 0; padding-top: 0.6rem; padding-bottom: 0.6rem; }
  .responsive-table .cell-flex { justify-content: flex-end; }

  .table-scroll { max-height: none !important; }
  .mobile-only { display: block !important; }
  .desktop-only { display: none !important; }
  .foc-doc { padding: 1rem; }
  .foc-doc .doc-sign { flex-direction: column; gap: 1.25rem; }
}
