/* ── Custom scrollbar ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Hero panel with gradient + background image */
.hero-panel {
  background:
    linear-gradient(135deg,
      rgba(10, 31, 68, 0.85) 0%,
      rgba(22, 76, 129, 0.80) 50%,
      rgba(26, 95, 168, 0.75) 100%),
    url('./hero_bg.png') center/cover no-repeat;
}

/* Alternative: If you want the image as a watermark overlay */
.hero-panel-watermark {
  background: linear-gradient(135deg,
      #0a1f44 0%,
      #164c81 50%,
      #1a5fa8 100%);
  position: relative;
}

.hero-panel-watermark::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('./hero_bg.png') center/cover no-repeat;
  opacity: 0.15;
  mix-blend-mode: overlay;
}

.logo-login {
  height: 49px;
  width: 225px;
  background-image: url('./logo_login.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left center;
}

.logo-nav {
  height: 49px;
  width: 225px;
  background-image: url('./logo_nav.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left center;
}

/* ── Sidebar layout ── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 17rem;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.open {
  transform: translateX(0);
}

#sidebar-toggle-btn {
  width: 3.6rem;
  height: 2.45rem;
  border-radius: 9999px;
  right: -1.2rem;
  transform: translateX(0);
  transition:
    width 0.24s ease,
    height 0.24s ease,
    border-radius 0.24s ease,
    transform 0.24s ease,
    right 0.24s ease;
  will-change: width, height, border-radius, right;
}

#sidebar-toggle-btn.is-open {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 9999px;
  right: -1.35rem;
}

/* Desktop: push content */
@media (min-width: 1024px) {
  #main-content-area {
    margin-left: 0;
    transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #main-content-area.sidebar-open {
    margin-left: 16rem;
  }

  #sidebar-overlay {
    display: none !important;
  }
}

/* Mobile: overlay */
@media (max-width: 1023px) {
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  #sidebar-overlay.active {
    display: block;
  }
}

/* ── Nav active state ── */
.nav-btn {
  position: relative;
}

.nav-btn.is-active {
  background-color: rgba(255, 255, 255, 0.12) !important;
  color: white !important;
  font-weight: 600;
}

.nav-btn.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #f3861b;
}

/* ── Sidebar styling stays consistent across themes ── */
#sidebar {
  background: linear-gradient(180deg, #0a1f44 0%, #164c81 100%) !important;
  color: #ffffff !important;
}

#sidebar nav p {
  color: rgba(255, 255, 255, 0.58) !important;
}

.nav-btn {
  color: rgba(255, 255, 255, 0.9) !important;
  background-color: transparent !important;
}

.nav-btn:hover,
.nav-btn:focus-visible {
  background-color: rgba(243, 134, 27, 0.25) !important;
  color: #ffffff !important;
}

.nav-btn.is-active {
  background-color: #f3861b !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(243, 134, 27, 0.35) !important;
}

.nav-btn.is-active::before {
  display: none;
  /* orange fill replaces the left bar */
}

.nav-btn .fas,
.nav-btn .far,
.nav-btn .fab,
.nav-btn span {
  color: inherit !important;
}

.hover\:bg-white\/8:hover {
  background-color: rgba(10, 31, 68, 0.38) !important;
}

/* ── Light mode: topbar text forced dark ── */
:root:not(.dark) #topbar-page-title {
  color: #111827 !important;
  font-weight: 700 !important;
}

:root:not(.dark) #topbar-page-subtitle {
  color: #374151 !important;
  font-weight: 600 !important;
}

:root:not(.dark) #topbar-username {
  color: #111827 !important;
  font-weight: 700 !important;
}

:root:not(.dark) #topbar-role {
  color: #374151 !important;
  font-weight: 600 !important;
}

:root:not(.dark) #topbar-clock {
  color: #111827 !important;
  font-weight: 700 !important;
}

:root:not(.dark) #topbar-date {
  color: #374151 !important;
  font-weight: 600 !important;
}

/* ── SO / TSO toggle buttons ── */
.status-btn {
  transition: all 0.15s;
  border-width: 2px;
}

.status-btn.is-so {
  background: #dcfce7 !important;
  color: #15803d !important;
  border-color: #22c55e !important;
}

.status-btn.is-tso {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border-color: #ef4444 !important;
}

.status-btn.is-idle {
  background: #f3f4f6 !important;
  color: #9ca3af !important;
  border-color: #e5e7eb !important;
}

.dark .status-btn.is-idle {
  background: #374151 !important;
  color: #6b7280 !important;
  border-color: #4b5563 !important;
}

/* ── Toast container ── */
#toast-container {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  /* mobile: bottom-center */
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem);
}

@media (min-width: 640px) {
  #toast-container {
    bottom: auto;
    top: 1.25rem;
    right: 1.25rem;
    left: auto;
    transform: none;
    align-items: flex-end;
  }
}

/* ── Print: QR only ── */
@media print {
  body > *:not(#qr-print-area) {
    display: none !important;
  }

  #qr-print-area {
    display: flex !important;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: white;
  }
}

/* ── Misc helpers ── */
.view-section {
  display: none;
}

.view-section.is-visible {
  display: block;
}

.view-section.is-flex {
  display: flex;
  flex-direction: column;
}

/* History-detail & database need flex column */
#view-database,
#view-history {
  display: none;
}

#view-database.is-visible,
#view-history.is-visible {
  display: flex;
  flex-direction: column;
}

/* Master edit modal field label helper */
.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: #6b7280;
}

.dark .field-label {
  color: #9ca3af;
}

.field-input {
  width: 100%;
  padding: 0.625rem;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.dark .field-input {
  background-color: #374151;
  border-color: #4b5563;
}

.field-input:focus {
  border-color: #164c81;
}

.dark .field-input:focus {
  border-color: #f3861b;
}

/* ── Light mode contrast boost ── */
:root:not(.dark) body {
  background-color: #e8edf3;
}

:root:not(.dark) .bg-white {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.06);
}

:root:not(.dark) .border-gray-100 {
  border-color: #cbd5e1 !important;
}

:root:not(.dark) .border-gray-200 {
  border-color: #94a3b8 !important;
}

:root:not(.dark) input:not([type="radio"]):not([type="checkbox"]),
:root:not(.dark) select,
:root:not(.dark) textarea {
  border-color: #94a3b8 !important;
  background-color: #ffffff !important;
}

:root:not(.dark) input:focus,
:root:not(.dark) select:focus,
:root:not(.dark) textarea:focus {
  border-color: #164c81 !important;
  box-shadow: 0 0 0 3px rgba(22, 76, 129, 0.12) !important;
}

:root:not(.dark) table thead tr {
  background-color: #f1f5f9;
}

:root:not(.dark) table tbody tr:hover {
  background-color: #f0f4f8 !important;
}

:root:not(.dark) .divide-gray-100 > * + * {
  border-color: #cbd5e1 !important;
}

:root:not(.dark) .hover\:bg-white\/8:hover,
:root:not(.dark) .hover\:bg-gray-50:hover {
  background-color: #f8fafc !important;
}

/* Tab active states */
:root:not(.dark) .hist-tab.is-active,
:root:not(.dark) button.is-active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Card hover borders */
:root:not(.dark) .rounded-xl:hover {
  border-color: #94a3b8;
}

/* Topbar border */
:root:not(.dark) header {
  border-bottom-color: #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Breadcrumb area */
:root:not(.dark) .bg-gray-50 {
  background-color: #f1f5f9 !important;
}

/* Modal backdrop stronger in light */
:root:not(.dark) .bg-gray-900\/40 {
  background-color: rgba(15, 23, 42, 0.55) !important;
}

/* ── Dashboard matrix cell gradient ── */
.matrix-cell-mixed {
  background: linear-gradient(135deg, #dcfce7 50%, #fee2e2 50%);
}

.dark .matrix-cell-mixed {
  background: linear-gradient(
    135deg,
    rgba(21, 128, 61, 0.35) 50%,
    rgba(185, 28, 28, 0.35) 50%
  );
}

/* ── Dashboard tab panel ── */
.dash-tab-btn {
  white-space: nowrap;
  transition: all 0.15s;
}

.dash-tab-btn.is-active {
  background-color: #164c81;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(22, 76, 129, 0.25);
}

.dark .dash-tab-btn.is-active {
  background-color: #1e5fa3;
}

.dash-tab-btn:not(.is-active) {
  color: #6b7280;
}

.dash-tab-btn:not(.is-active):hover {
  background-color: rgba(22, 76, 129, 0.1);
  color: #164c81;
}

.dark .dash-tab-btn:not(.is-active):hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #93c5fd;
}

/* ── Dashboard dot indicators ── */
.dash-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #cbd5e1;
  transition:
    background 0.2s,
    transform 0.2s;
  cursor: pointer;
}

.dash-dot.is-active {
  background: #164c81;
  transform: scale(1.4);
}

.dark .dash-dot.is-active {
  background: #60a5fa;
}

/* ── Matrix table ── */
#dash-matrix-table th,
#dash-matrix-table td {
  min-width: 2.6rem;
  text-align: center;
  font-size: 0.7rem;
  padding: 0.3rem 0.2rem;
}

#dash-matrix-table th {
  font-weight: 700;
}

/* ── Matrix table fluid sizing ── */
#dash-matrix-table th,
#dash-matrix-table td {
  padding: 0.35rem 0.5rem;
  font-size: clamp(9px, 1vw, 12px);
  white-space: nowrap;
}

#dash-matrix-table th {
  font-weight: 600;
}

/* Wilayah column: values left, header center */
#dash-matrix-table td:first-child {
  text-align: left !important;
}

#dash-matrix-table th:first-child {
  text-align: center !important;
}
