/* Web-CCTV Custom Stylesheet */

/* Running Ticker/Marquee Animation */
@keyframes marquee {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

.animate-marquee {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 30s linear infinite;
}

/* Pause marquee on hover */
#ticker-bar:hover .animate-marquee {
  animation-play-state: paused;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.scrollbar-none::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.scrollbar-none {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Map adjustment */
#map {
  width: 100%;
  height: 100%;
  background: #0b1329;
}

/* Custom transitions and styling overrides */
.nav-item.active {
  background-color: #1e3a8a !important; /* bg-blue-900 */
  color: #ffffff !important;
  border-left: 4px solid #3b82f6; /* border-blue-500 */
}

/* CCTV grid video styling */
.cctv-card-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #000;
}

/* Leaflet Popup Override dark theme */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #0f172a !important; /* bg-slate-900 */
  color: #f1f5f9 !important;      /* text-slate-100 */
  border: 1px solid #1e293b;     /* border-slate-800 */
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  border-radius: 0.75rem !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #94a3b8 !important; /* text-slate-400 */
  padding: 6px !important;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  color: #f1f5f9 !important;
}

/* Touch friendly button adjustments for mobile */
@media (max-width: 768px) {
  /* Prevent zoom on inputs on iOS */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Fail-safe overlay blocking prevention */
#global-loader.opacity-0,
.opacity-0 {
  pointer-events: none !important;
}

/* ================= THEME: LIGHT MODE OVERRIDES ================= */
body.light-mode {
  background-color: #f8fafc !important; /* bg-slate-50 */
  color: #0f172a !important;            /* text-slate-900 */
}

body.light-mode #sidebar,
body.light-mode #ticker-bar,
body.light-mode .bg-slate-900,
body.light-mode .bg-slate-950 {
  background-color: #ffffff !important; /* bg-white cards & sidebar */
  border-color: #e2e8f0 !important;     /* border-slate-200 */
  color: #1e293b !important;
}

body.light-mode #ticker-bar {
  background-color: #2563eb !important; /* Keep blue for ticker but clean text */
  color: #ffffff !important;
}

body.light-mode .text-slate-100,
body.light-mode .text-slate-200,
body.light-mode .text-white {
  color: #0f172a !important;
}

body.light-mode .text-slate-300,
body.light-mode .text-slate-400 {
  color: #475569 !important;            /* text-slate-600 */
}

body.light-mode .border-slate-800,
body.light-mode .border-slate-850 {
  border-color: #e2e8f0 !important;     /* border-slate-200 */
}

body.light-mode input,
body.light-mode select,
body.light-mode textarea {
  background-color: #f1f5f9 !important; /* bg-slate-100 inputs */
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

body.light-mode .nav-item {
  color: #334155 !important;
}

body.light-mode .nav-item:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

body.light-mode .nav-item.active {
  background-color: #2563eb !important; /* active blue brand */
  color: #ffffff !important;
  border-left-color: #3b82f6 !important;
}

body.light-mode #app-footer-text,
body.light-mode .text-slate-500 {
  color: #64748b !important;
}

body.light-mode .bg-slate-950\/40 {
  background-color: #f1f5f9 !important;
}

/* Sidebar Hide/Show transitions */
#sidebar {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsible Sidebar Layout Override */
#app-container.sidebar-collapsed #sidebar {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  transform: translateX(-100%) !important;
  border-right-width: 0 !important;
  overflow: hidden !important;
}

/* Berikan ruang atas ekstra agar tombol hamburger melayang tidak menimpa judul halaman */
#view-container {
  padding-top: 3rem !important;
}

@media (max-width: 768px) {
  #view-container {
    padding-top: 1rem !important; /* Mobile top bar is already present, so no extra padding needed on mobile! */
  }
}

/* ================= FULLSCREEN LIVE PLAYER ================= */
/* Fallback CSS fullscreen (bila Fullscreen API tidak tersedia di WebView lama) */
#player-video-stage.cctv-pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  z-index: 9999 !important;
  background: #000 !important;
  border-radius: 0 !important;
  grid-column: 1 / -1 !important;
  padding: 0 !important;
  margin: 0 !important;
}

#player-video-stage.cctv-pseudo-fullscreen video,
#player-video-stage.cctv-pseudo-fullscreen iframe {
  object-fit: contain !important;
}

/* Saat fullscreen penuh, video harus menutupi seluruh area */
#player-video-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#player-video-stage:fullscreen video,
#player-video-stage:fullscreen iframe {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

#player-video-stage:fullscreen #player-splash {
  position: absolute !important;
  inset: 0 !important;
}

/* ================= ANDROID-STYLE MOBILE BOTTOM NAV =================
   Navigasi utama dibuat seperti aplikasi Android: fixed di bawah, mudah
   disentuh, aman dari gesture bar, dan tidak menutupi isi halaman. */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  #mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    z-index: 80;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 64px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    align-items: stretch;
    justify-content: space-around;
    gap: 3px;
    background: rgba(15, 23, 42, 0.96);
    border-top: 1px solid rgba(71, 85, 105, 0.42);
    box-shadow: 0 -10px 28px rgba(2, 6, 23, 0.5);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  /* Tailwind .hidden tetap harus menang untuk menu admin/privat */
  #mobile-bottom-nav .mobile-bottom-item.hidden {
    display: none !important;
  }

  #mobile-bottom-nav .mobile-bottom-item {
    display: flex;
    flex: 1 1 0%;
    min-width: 0;
    min-height: 50px;
    padding: 2px 3px 1px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #94a3b8;
    background: transparent;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
  }

  #mobile-bottom-nav .mobile-bottom-item:active {
    transform: scale(0.94);
    background: rgba(30, 41, 59, 0.82);
  }

  #mobile-bottom-nav .mobile-bottom-icon {
    display: flex;
    width: 34px;
    height: 25px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 17px;
    line-height: 1;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
  }

  #mobile-bottom-nav .mobile-bottom-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    line-height: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  #mobile-bottom-nav .mobile-bottom-item.active {
    color: #60a5fa;
  }

  #mobile-bottom-nav .mobile-bottom-item.active .mobile-bottom-icon {
    color: #ffffff;
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.38);
    transform: translateY(-1px);
  }

  #mobile-bottom-nav .mobile-bottom-item.active .mobile-bottom-label {
    color: #93c5fd;
  }

  /* Halaman admin/settings dianggap berada di dalam menu Lainnya. */
  #mobile-bottom-nav #mobile-bottom-more.active .mobile-bottom-icon {
    color: #ffffff;
    background: #334155;
    box-shadow: 0 4px 12px rgba(51, 65, 85, 0.4);
  }

  /* Beri ruang aman agar kartu/tabel terakhir tidak tertutup bottom nav. */
  #view-container {
    padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px)) !important;
    scroll-padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  }

  /* Footer desktop digantikan oleh bottom navigation pada layar kecil. */
  #app-container > main > footer {
    display: none !important;
  }

  /* Drawer harus berada di atas bottom navigation ketika Menu dibuka. */
  #sidebar {
    z-index: 100 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #sidebar-backdrop {
    z-index: 90 !important;
  }

  /* Toast tidak boleh tertutup oleh navigasi bawah. */
  #toast {
    bottom: calc(4.8rem + env(safe-area-inset-bottom, 0px)) !important;
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
  }

  /* Area header lebih ringkas dan terasa seperti app bar Android. */
  #app-container > header {
    min-height: 56px;
    height: 56px;
  }
}

@media (max-width: 380px) {
  #mobile-bottom-nav {
    padding-left: 4px;
    padding-right: 4px;
    gap: 1px;
  }

  #mobile-bottom-nav .mobile-bottom-label {
    font-size: 9px;
  }
}

/* Bottom navigation pada tema terang */
body.light-mode #mobile-bottom-nav {
  background: rgba(255, 255, 255, 0.96);
  border-top-color: rgba(203, 213, 225, 0.9);
  box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.12);
}

body.light-mode #mobile-bottom-nav .mobile-bottom-item {
  color: #64748b;
}

body.light-mode #mobile-bottom-nav .mobile-bottom-item:active {
  background: #f1f5f9;
}

body.light-mode #mobile-bottom-nav .mobile-bottom-item.active {
  color: #2563eb;
}

body.light-mode #mobile-bottom-nav .mobile-bottom-item.active .mobile-bottom-label {
  color: #2563eb;
}

body.light-mode #mobile-bottom-nav #mobile-bottom-more.active .mobile-bottom-icon {
  color: #ffffff;
  background: #475569;
}

/* ==========================================================================
   v2.9: TEMA — WARNA AKSEN YANG BISA DIPILIH
   --------------------------------------------------------------------------
   Seluruh kelas biru Tailwind yang dipakai aplikasi dialihkan ke variabel CSS,
   jadi mengganti satu atribut data-accent pada <body> langsung mengubah warna
   merek di seluruh dashboard tanpa menyentuh HTML/JS.
   ========================================================================== */
:root,
body[data-accent="blue"] {
  --accent-300: #93c5fd;
  --accent-400: #60a5fa;
  --accent-500: #3b82f6;
  --accent-600: #2563eb;
  --accent-700: #1d4ed8;
  --accent-900: #1e3a8a;
}
body[data-accent="emerald"] {
  --accent-300: #6ee7b7; --accent-400: #34d399; --accent-500: #10b981;
  --accent-600: #059669; --accent-700: #047857; --accent-900: #064e3b;
}
body[data-accent="violet"] {
  --accent-300: #c4b5fd; --accent-400: #a78bfa; --accent-500: #8b5cf6;
  --accent-600: #7c3aed; --accent-700: #6d28d9; --accent-900: #4c1d95;
}
body[data-accent="rose"] {
  --accent-300: #fda4af; --accent-400: #fb7185; --accent-500: #f43f5e;
  --accent-600: #e11d48; --accent-700: #be123c; --accent-900: #881337;
}
body[data-accent="amber"] {
  --accent-300: #fcd34d; --accent-400: #fbbf24; --accent-500: #f59e0b;
  --accent-600: #d97706; --accent-700: #b45309; --accent-900: #78350f;
}
body[data-accent="cyan"] {
  --accent-300: #67e8f9; --accent-400: #22d3ee; --accent-500: #06b6d4;
  --accent-600: #0891b2; --accent-700: #0e7490; --accent-900: #164e63;
}

/* Pengalihan kelas utilitas biru -> variabel aksen */
.bg-blue-300   { background-color: var(--accent-300) !important; }
.bg-blue-400   { background-color: var(--accent-400) !important; }
.bg-blue-500   { background-color: var(--accent-500) !important; }
.bg-blue-600   { background-color: var(--accent-600) !important; }
.bg-blue-700   { background-color: var(--accent-700) !important; }
.text-blue-300 { color: var(--accent-300) !important; }
.text-blue-400 { color: var(--accent-400) !important; }
.text-blue-500 { color: var(--accent-500) !important; }
.text-blue-600 { color: var(--accent-600) !important; }
.border-blue-500 { border-color: var(--accent-500) !important; }
.border-blue-700 { border-color: var(--accent-700) !important; }
.border-blue-900 { border-color: var(--accent-900) !important; }
.from-blue-700 { --tw-gradient-from: var(--accent-700) !important; }
.to-blue-500   { --tw-gradient-to: var(--accent-500) !important; }
/* focus:ring-blue-500 menyetel --tw-ring-color lewat kelas ring-* */
.ring-blue-500 { --tw-ring-color: var(--accent-500) !important; }

/* Elemen yang warnanya di-hardcode di aturan light-mode ikut memakai aksen */
body.light-mode #ticker-bar,
body.light-mode .nav-item.active {
  background-color: var(--accent-600) !important;
}
body.light-mode .nav-item.active {
  border-left-color: var(--accent-500) !important;
}

/* ==========================================================================
   v2.9: PERBAIKAN TEMA TERANG
   Versi lama hanya menimpa sebagian kelas, sehingga modal, tabel, badge, dan
   tombol masih gelap di mode terang. Bagian di bawah melengkapinya.
   ========================================================================== */
body.light-mode .bg-slate-800,
body.light-mode .bg-slate-800\/40,
body.light-mode .bg-slate-800\/60 {
  background-color: #f1f5f9 !important;
}
body.light-mode .bg-slate-900\/80,
body.light-mode .bg-slate-950\/90,
body.light-mode .bg-slate-950\/80 {
  background-color: rgba(248, 250, 252, 0.92) !important;
}
body.light-mode .divide-slate-800\/60 > * + *,
body.light-mode .divide-slate-800 > * + * {
  border-color: #e2e8f0 !important;
}
body.light-mode .text-slate-600,
body.light-mode .text-slate-700 {
  color: #334155 !important;
}
/* Badge & chip berwarna tetap terbaca di atas latar terang */
body.light-mode .bg-emerald-500\/10 { background-color: rgba(16, 185, 129, 0.14) !important; }
body.light-mode .bg-rose-500\/10    { background-color: rgba(244, 63, 94, 0.14) !important; }
body.light-mode .bg-red-500\/10     { background-color: rgba(239, 68, 68, 0.14) !important; }
body.light-mode .bg-amber-500\/10   { background-color: rgba(245, 158, 11, 0.16) !important; }
body.light-mode .bg-fuchsia-500\/15 { background-color: rgba(217, 70, 239, 0.14) !important; }
body.light-mode .bg-violet-500\/10  { background-color: rgba(139, 92, 246, 0.14) !important; }
body.light-mode .bg-sky-500\/10     { background-color: rgba(14, 165, 233, 0.14) !important; }
body.light-mode .bg-cyan-500\/10    { background-color: rgba(6, 182, 212, 0.14) !important; }
/* Tombol tetap kontras */
body.light-mode button.bg-slate-700,
body.light-mode button.bg-slate-800 {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}
body.light-mode button.bg-slate-700:hover,
body.light-mode button.bg-slate-800:hover {
  background-color: #cbd5e1 !important;
}
/* Kotak kode / monospace */
body.light-mode code,
body.light-mode .font-mono {
  color: #1e293b;
}
body.light-mode code {
  background-color: #e2e8f0 !important;
}
/* Scrollbar agar serasi */
body.light-mode ::-webkit-scrollbar-thumb { background-color: #cbd5e1; }
body.light-mode ::-webkit-scrollbar-track { background-color: #f1f5f9; }

/* =====================================================================
   v2.9.15 — KOP INSTANSI & STATUS BAR GAYA INSTANSI PEMERINTAHAN
   ---------------------------------------------------------------------
   Dipakai di atas Dasbor. Mengikuti variabel tema yang sudah ada
   (--accent-*) sehingga mode terang/gelap ikut menyesuaikan.
   ===================================================================== */

.gov-header {
  background-color: #0b1220;
}

/* Baris kop: garis emas tipis di atas, seperti kop surat instansi */
.gov-header > div:first-child {
  border-top: 3px solid #d4a017;
}

/* Setiap sel indikator */
.gov-stat {
  background-color: #0f172a;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gov-stat-label {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gov-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .gov-stat { padding: 10px 14px; }
  .gov-stat-value { font-size: 18px; }
}

/* Meter tipis untuk CPU & penyimpanan */
.gov-meter {
  height: 3px;
  background-color: #1e293b;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
}

.gov-meter-fill {
  height: 100%;
  transition: width 0.4s ease, background-color 0.4s ease;
}

/* v2.9.19: baris kecil penunjuk disk mana yang diukur (HDD rekaman / SD sistem) */
.gov-stat-sub {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.gov-stat-sub.gov-stat-warn {
  color: #f87171;
  font-weight: 700;
}

/* Teks berjalan resmi */
.gov-ticker {
  display: flex;
  align-items: center;
  background-color: #0b1220;
  overflow: hidden;
  height: 26px;
}

.gov-ticker-tag {
  flex-shrink: 0;
  background-color: #d4a017;
  color: #0b1220;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  height: 100%;
  display: flex;
  align-items: center;
}

.gov-ticker-track {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.gov-ticker-text {
  display: inline-block;
  padding-left: 100%;
  font-size: 11px;
  color: #cbd5e1;
  animation: gov-ticker-scroll 38s linear infinite;
}

@keyframes gov-ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .gov-ticker-text { animation: none; padding-left: 8px; }
}

/* ---- Mode terang: kop jadi formal terang ---- */
body.light-mode .gov-header { background-color: #f8fafc; }
body.light-mode .gov-header > div:first-child {
  background: linear-gradient(to right, #ffffff, #f1f5f9);
  border-bottom-color: #e2e8f0;
}
body.light-mode .gov-stat { background-color: #ffffff; }
body.light-mode .gov-stat-label { color: #64748b; }
body.light-mode .gov-stat-value { color: #0f172a; }
body.light-mode .gov-meter { background-color: #e2e8f0; }
body.light-mode .gov-stat-sub { color: #64748b; }
body.light-mode .gov-stat-sub.gov-stat-warn { color: #b91c1c; }
body.light-mode .gov-ticker { background-color: #f1f5f9; border-top-color: #e2e8f0; }
body.light-mode .gov-ticker-text { color: #334155; }

/* =====================================================================
   v3.0 — ROUTER CONTROL UI
   Tampilan baru: lebih bersih, padat, konsisten, dan mudah dipindai pada
   monitor ruang kontrol maupun layar ponsel. Tidak memakai resource CDN.
   ===================================================================== */
:root {
  --ui-bg: #070b14;
  --ui-surface: #0d1422;
  --ui-surface-2: #111b2d;
  --ui-border: rgba(148, 163, 184, .14);
  --ui-border-strong: rgba(148, 163, 184, .24);
  --ui-shadow: 0 18px 50px rgba(0, 0, 0, .24);
  --ui-radius: 16px;
}

body {
  background:
    radial-gradient(circle at 78% -10%, color-mix(in srgb, var(--accent-600) 18%, transparent), transparent 32rem),
    var(--ui-bg) !important;
}

#ticker-bar {
  background: color-mix(in srgb, var(--accent-600) 88%, #07101e) !important;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

#sidebar {
  width: 17rem;
  background: rgba(9, 15, 26, .94) !important;
  border-color: var(--ui-border) !important;
  box-shadow: 16px 0 50px rgba(0,0,0,.16);
  backdrop-filter: blur(20px);
}

#sidebar > div:first-child { min-height: 72px; }
#nav-menu { padding: 14px 12px; gap: 3px; }
#nav-menu .nav-item {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #94a3b8;
}
#nav-menu .nav-item i { color: #64748b; transition: color .2s ease; }
#nav-menu .nav-item:hover {
  background: rgba(148,163,184,.07) !important;
  border-color: var(--ui-border);
}
#nav-menu .nav-item.active {
  color: #fff !important;
  background: linear-gradient(110deg, color-mix(in srgb, var(--accent-600) 85%, #111827), color-mix(in srgb, var(--accent-900) 72%, #111827)) !important;
  border: 1px solid color-mix(in srgb, var(--accent-400) 32%, transparent) !important;
  border-left-width: 1px !important;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent-600) 22%, transparent);
}
#nav-menu .nav-item.active i { color: #fff; }

#app-container main { background: transparent !important; }
#view-container { padding-top: 4.25rem !important; }
.view-section > div.bg-slate-900,
.network-panel,
#storage-status-panel {
  border-color: var(--ui-border) !important;
  box-shadow: 0 10px 32px rgba(0,0,0,.13) !important;
}

/* Kartu live CCTV lebih sinematik dan status lebih mudah dibaca. */
#live-cameras-grid > [data-reorder-id] {
  border-color: var(--ui-border) !important;
  border-radius: var(--ui-radius) !important;
  background: linear-gradient(155deg, rgba(17,27,45,.97), rgba(10,16,28,.97)) !important;
  box-shadow: var(--ui-shadow) !important;
  transform: translateY(0);
}
#live-cameras-grid > [data-reorder-id]:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent-400) 45%, transparent) !important;
  box-shadow: 0 20px 55px rgba(0,0,0,.34) !important;
}
#live-cameras-grid > [data-reorder-id] .aspect-video { background: #020408; }
#live-cameras-grid > [data-reorder-id] .aspect-video::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 58%, rgba(2,6,23,.36));
}

/* Panel network seperti halaman administrasi router. */
.router-console {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent-500) 24%, var(--ui-border));
  border-radius: 20px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-900) 22%, transparent), transparent 44%),
    linear-gradient(145deg, #101a2b, #090f1b);
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.router-console-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
}
.router-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--accent-400);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
}
.router-console h3 { color: #f8fafc; font-size: 20px; font-weight: 800; line-height: 1.2; }
.router-console-head p { margin-top: 4px; color: #7f8da3; font-size: 11px; }
.router-health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(148,163,184,.16);
  border-radius: 999px;
  background: rgba(2,6,23,.42);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
}
.router-health-dot { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 12px #f59e0b; }
.router-health.is-online { color: #6ee7b7; border-color: rgba(16,185,129,.28); }
.router-health.is-online .router-health-dot { background: #10b981; box-shadow: 0 0 14px #10b981; }
.router-health.is-offline { color: #fda4af; border-color: rgba(244,63,94,.28); }
.router-health.is-offline .router-health-dot { background: #f43f5e; box-shadow: 0 0 14px #f43f5e; }

.router-topology {
  display: grid;
  grid-template-columns: minmax(0,1fr) 22px minmax(0,1.2fr) 22px minmax(0,1fr) 22px minmax(0,1fr);
  align-items: center;
  padding: 12px 22px 22px;
}
.router-node {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--ui-border);
  border-radius: 13px;
  background: rgba(2,6,23,.42);
}
.router-node-main { border-color: color-mix(in srgb, var(--accent-500) 42%, transparent); background: color-mix(in srgb, var(--accent-900) 20%, rgba(2,6,23,.6)); }
.router-node-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--accent-300);
  background: color-mix(in srgb, var(--accent-600) 18%, transparent);
}
.router-node b, .router-node small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.router-node b { color: #e5edf8; font-size: 11px; }
.router-node small { margin-top: 3px; color: #74839a; font-size: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.router-link { color: color-mix(in srgb, var(--accent-400) 55%, #475569); text-align: center; font-size: 10px; }
.router-quick-nav {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--ui-border);
  background: rgba(2,6,23,.28);
  scrollbar-width: none;
}
.router-quick-nav::-webkit-scrollbar { display: none; }
.router-quick-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 8px;
  color: #8795aa;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}
.router-quick-nav a:hover { color: #fff; background: rgba(148,163,184,.09); }
.network-panel { scroll-margin-top: 18px; }
.network-panel > h3:first-child { letter-spacing: -.01em; }

/* Form dan tabel: target sentuh lebih baik serta fokus konsisten. */
input, select, textarea { border-color: var(--ui-border-strong) !important; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-500) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-500) 14%, transparent) !important;
}
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-400); outline-offset: 2px; }
thead { letter-spacing: .045em; }

body.light-mode {
  --ui-bg: #f2f5f9;
  --ui-surface: #ffffff;
  --ui-surface-2: #f8fafc;
  --ui-border: rgba(15,23,42,.10);
  --ui-border-strong: rgba(15,23,42,.18);
  --ui-shadow: 0 18px 45px rgba(15,23,42,.10);
}
body.light-mode #sidebar { background: rgba(255,255,255,.94) !important; }
body.light-mode .router-console {
  background: linear-gradient(145deg, #fff, #f3f7fb);
  box-shadow: var(--ui-shadow);
}
body.light-mode .router-console h3,
body.light-mode .router-node b { color: #0f172a; }
body.light-mode .router-node { background: rgba(255,255,255,.82); }
body.light-mode .router-node-main { background: color-mix(in srgb, var(--accent-500) 8%, #fff); }
body.light-mode .router-quick-nav { background: rgba(241,245,249,.75); }
body.light-mode .router-quick-nav a:hover { color: #0f172a; background: #e2e8f0; }
body.light-mode #live-cameras-grid > [data-reorder-id] { background: #fff !important; }

@media (max-width: 900px) {
  .router-topology { grid-template-columns: 1fr 16px 1fr; gap: 8px 0; }
  .router-topology .router-link:nth-of-type(2) { display: none; }
}
@media (max-width: 767px) {
  #view-container { padding: .875rem .875rem calc(5.6rem + env(safe-area-inset-bottom, 0px)) !important; }
  .router-console-head { padding: 16px 14px 10px; }
  .router-console-head p { display: none; }
  .router-health { padding: 6px 8px; }
  .router-topology { grid-template-columns: 1fr; padding: 8px 14px 16px; gap: 6px; }
  .router-link { transform: rotate(90deg); }
  .router-topology .router-link:nth-of-type(2) { display: block; }
  .router-node { min-height: 54px; }
  #live-cameras-grid { gap: 14px; }
}

/* v3.0.1 — Penanda peta berbentuk kamera CCTV */
.cctv-map-marker-wrap {
  background: transparent !important;
  border: 0 !important;
}
.cctv-map-marker {
  --marker-color: #64748b;
  position: relative;
  width: 42px;
  height: 50px;
  filter: drop-shadow(0 8px 10px rgba(2, 6, 23, .42));
  transition: transform .18s ease, filter .18s ease;
}
.cctv-map-marker:hover {
  transform: translateY(-3px) scale(1.08);
  filter: drop-shadow(0 12px 14px rgba(2, 6, 23, .5));
}
.cctv-map-marker-body {
  position: absolute;
  z-index: 3;
  left: 3px;
  top: 2px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  font-size: 15px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 12px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--marker-color) 82%, #fff), color-mix(in srgb, var(--marker-color) 82%, #020617));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.cctv-map-marker-tip {
  position: absolute;
  z-index: 2;
  left: 15px;
  top: 31px;
  width: 12px;
  height: 12px;
  border-right: 2px solid rgba(255,255,255,.9);
  border-bottom: 2px solid rgba(255,255,255,.9);
  border-radius: 0 0 3px 0;
  background: var(--marker-color);
  transform: rotate(45deg);
}
.cctv-map-marker-led {
  position: absolute;
  z-index: 5;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--marker-color);
  box-shadow: 0 0 9px var(--marker-color);
}
.cctv-map-marker-pulse {
  position: absolute;
  z-index: 1;
  left: 3px;
  top: 2px;
  width: 36px;
  height: 36px;
  border: 2px solid var(--marker-color);
  border-radius: 12px;
  opacity: .36;
}
.cctv-map-marker.is-online .cctv-map-marker-pulse {
  animation: cctv-marker-pulse 1.9s ease-out infinite;
}
@keyframes cctv-marker-pulse {
  0% { transform: scale(.9); opacity: .5; }
  75%, 100% { transform: scale(1.45); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cctv-map-marker.is-online .cctv-map-marker-pulse { animation: none; }
}

/* v3.0.2 — SVG kamera mandiri: bentuk kamera tetap terlihat walau font ikon gagal. */
.cctv-svg-marker {
  --marker-color: #64748b;
  position: relative;
  width: 54px;
  height: 48px;
  transition: transform .18s ease, filter .18s ease;
  filter: drop-shadow(0 8px 7px rgba(2, 6, 23, .48));
}
.cctv-svg-marker:hover {
  transform: translateY(-3px) scale(1.1);
  filter: drop-shadow(0 12px 10px rgba(2, 6, 23, .55));
}
.cctv-svg-marker svg {
  position: relative;
  z-index: 3;
  display: block;
  width: 54px;
  height: 45px;
  overflow: visible;
}
.cctv-svg-housing,
.cctv-svg-lens { fill: var(--marker-color); stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.cctv-svg-glass { fill: #07101e; stroke: #fff; stroke-width: 2; }
.cctv-svg-stand { fill: #e2e8f0; stroke: #fff; stroke-width: 1; stroke-linejoin: round; }
.cctv-svg-marker-led {
  position: absolute;
  z-index: 5;
  top: 7px;
  left: 40px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--marker-color);
  box-shadow: 0 0 10px var(--marker-color);
}
.cctv-svg-marker-pulse {
  position: absolute;
  z-index: 1;
  left: 4px;
  top: 7px;
  width: 40px;
  height: 30px;
  border: 3px solid var(--marker-color);
  border-radius: 8px;
  opacity: .4;
}
.cctv-svg-marker.is-online .cctv-svg-marker-pulse,
.cctv-hq-marker .cctv-svg-marker-pulse { animation: cctv-svg-pulse 1.9s ease-out infinite; }
.cctv-hq-flag {
  position: absolute;
  z-index: 6;
  top: -8px;
  left: -5px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 17px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(2,6,23,.35);
}
@keyframes cctv-svg-pulse {
  0% { transform: scale(.9); opacity: .5; }
  75%, 100% { transform: scale(1.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cctv-svg-marker.is-online .cctv-svg-marker-pulse,
  .cctv-hq-marker .cctv-svg-marker-pulse { animation: none; }
}

/* v3.1 — ZeroTier control panel */
.zerotier-logo {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(145deg, #f59e0b, #d97706);
  box-shadow: 0 7px 18px rgba(245,158,11,.22);
}
.zerotier-stat {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--ui-border);
  border-radius: 11px;
  background: rgba(2,6,23,.36);
}
.zerotier-stat span,
.zerotier-stat strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zerotier-stat span { color: #64748b; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.zerotier-stat strong { margin-top: 4px; color: #cbd5e1; font-size: 11px; }
.zerotier-network-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: rgba(2,6,23,.38);
}
.zerotier-status {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .05em;
}
.zerotier-status.is-ok { color: #6ee7b7; background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.22); }
.zerotier-status.is-wait { color: #fcd34d; background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.22); }
.zerotier-ip {
  display: inline-flex;
  padding: 3px 7px;
  border: 1px solid rgba(14,165,233,.24);
  border-radius: 7px;
  color: #7dd3fc;
  background: rgba(14,165,233,.09);
  font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}
body.light-mode .zerotier-stat,
body.light-mode .zerotier-network-card { background: #fff; }
body.light-mode .zerotier-stat strong { color: #1e293b; }
@media (max-width: 520px) {
  .zerotier-network-card { align-items: flex-start; flex-direction: column; }
}
