/* ═══════════════════════════════════════════════════════════
   gis-map/frontend/css/topo.css  — v2.9 redesign
   Restyle halaman "Topologi ONU": sidebar profil+OLT, header
   detail, selector profil, search, tabel jalur, breadcrumb
   rantai titik pasif, dan empty/loading state. Murni visual
   (warna, layout, animasi) — seluruh id & onclick handler yang
   dipakai onu-topology.js (selectTopoOlt, selectTopoProfile,
   selectListContextProfile, filterTopo, dst) TIDAK diubah, jadi
   file ini aman ditambahkan tanpa menyentuh logic apa pun.
   Konsisten dgn token & pola dari olt.css (--ln-accent-a/b, dll).
═══════════════════════════════════════════════════════════ */

.topo-page { display: flex; gap: 18px; height: 100%; overflow: hidden; }
.topo-fade { animation: topo-fadein .32s var(--ln-ease, ease); }
@keyframes topo-fadein { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ── Sidebar kiri: switch profil konteks + daftar OLT ── */
.topo-sidebar { width: 262px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; }
/* Pembungkus kotak chip: tingginya ikut isi kotak (yang sudah dibatasi), jangan ikut disusutkan flex. */
#topo-list-profile-switch { flex-shrink: 0; }

.topo-ctx-box {
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
  padding: 9px 10px; margin-bottom: 10px; flex-shrink: 0;
  /* Dibatasi supaya banyaknya profil tidak memakan seluruh sidebar & menjepit daftar OLT.
     Kalau chip melebihi batas, kotak ini yang scroll. */
  max-height: clamp(96px, 28vh, 220px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.topo-ctx-label {
  font-size: 9.5px; color: var(--text3); margin-bottom: 6px; font-weight: 600; letter-spacing: .02em;
  position: sticky; top: -9px; padding: 0 0 4px; margin-top: -2px; background: var(--surface); z-index: 1;
}
.topo-ctx-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.topo-ctx-chip {
  font-size: 9.5px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; transition: all .15s ease;
}
.topo-ctx-chip:hover  { background: rgba(255,255,255,.05); border-color: var(--border2); }
.topo-ctx-chip.active {
  border-color: rgba(59,130,246,.55); background: rgba(59,130,246,.16); color: #93c5fd;
  font-weight: 600; box-shadow: 0 0 0 1px rgba(59,130,246,.12);
}

/* Kotak pencarian OLT (di atas daftar OLT) */
.topo-olt-search {
  flex-shrink: 0; display: flex; align-items: center; gap: 7px;
  margin-bottom: 8px; padding: 6px 9px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.topo-olt-search:focus-within { border-color: rgba(59,130,246,.55); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.topo-olt-search > i { font-size: 13px; color: var(--text3); flex-shrink: 0; }
.topo-olt-search input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 11px; font-family: inherit;
}
.topo-olt-search input::placeholder { color: var(--text3); }
.topo-olt-search-clear {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 18px; height: 18px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.08); color: var(--text2); font-size: 11px; padding: 0;
}
.topo-olt-search-clear:hover { background: rgba(255,255,255,.16); color: var(--text); }

.topo-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding: 2px 5px 4px 0; }
.topo-empty { padding: 26px 10px; text-align: center; font-size: 11px; color: var(--text3); line-height: 1.7; }
.topo-empty i { font-size: 28px; display: block; margin-bottom: 8px; opacity: .35; }

.topo-card {
  position: relative; padding: 9px 10px 9px 14px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0));
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
  overflow: hidden;
  /* PENTING: .topo-list adalah flex column. Tanpa ini kartu (yang overflow:hidden) boleh
     disusutkan browser sampai muat di sisa ruang, sehingga baris ringkasan ONU terpotong. */
  flex-shrink: 0;
}
.topo-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background .16s ease;
}
.topo-card:hover    { background: rgba(255,255,255,0.045); transform: translateX(2px); border-color: var(--border2); }
.topo-card.selected { border-color: rgba(59,130,246,.55); background: rgba(59,130,246,0.085); box-shadow: 0 4px 16px rgba(59,130,246,.16); }
.topo-card.selected::before { background: linear-gradient(180deg, var(--ln-accent-a, #3b82f6), var(--ln-accent-b, #22d3ee)); }

.topo-card-top  { display: flex; align-items: center; gap: 7px; }
.topo-card-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; position: relative; }
.topo-card-dot.up   { background: var(--green); }
.topo-card-dot.up::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid rgba(34,197,94,.45); animation: topo-ring 2.2s ease-out infinite;
}
.topo-card-dot.down { background: var(--red); animation: topo-blink 1.3s ease-in-out infinite; }
@keyframes topo-ring  { 0% { transform: scale(.5); opacity: .9; } 100% { transform: scale(2); opacity: 0; } }
@keyframes topo-blink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.topo-card-name { font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topo-card-loc  { font-size: 10px; color: var(--text3); padding-left: 14px; margin-top: 2px; }
.topo-card-meta { font-size: 10px; color: var(--text3); padding-left: 14px; margin-top: 4px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.topo-badge {
  display: inline-flex; align-items: center; gap: 3px; font-size: 9px; padding: 0 6px; height: 15px;
  border-radius: 8px; font-weight: 600; white-space: nowrap;
}
.topo-badge.hit    { background: rgba(74,222,128,.12); color: #4ade80; }
.topo-badge.zero   { background: rgba(255,255,255,.05); color: var(--text3); }
.topo-badge.fail   { background: rgba(239,68,68,.12); color: #f87171; }
.topo-badge.pending{ color: var(--text3); }

/* ── Detail: header card ── */
.topo-detail-scroll { flex: 1; overflow-y: auto; padding-right: 4px; }
.topo-head {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; margin-bottom: 14px;
  border-radius: 14px; border: 1px solid var(--border2); position: relative; overflow: hidden;
  background: linear-gradient(120deg, rgba(96,165,250,.10), rgba(34,211,238,.03) 55%, transparent);
  flex-wrap: wrap;
}
.topo-head::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 88% 15%, rgba(96,165,250,.14), transparent 60%);
}
.topo-head-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0; position: relative; z-index: 1;
  background: linear-gradient(135deg, #60a5fa, var(--ln-accent-b, #22d3ee));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(96,165,250,.35), inset 0 1px 0 rgba(255,255,255,.2);
}
.topo-head-icon i { font-size: 22px; color: #fff; }
.topo-head-body { flex: 1; min-width: 220px; z-index: 1; }
.topo-head-name { font-size: 15px; font-weight: 700; color: var(--text); }
.topo-head-sub  { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Profil selector + search ── */
.topo-profile-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.topo-profile-label { font-size: 11px; color: var(--text3); font-weight: 600; flex-shrink: 0; }

.topo-profile-pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; padding: 4px 11px; border-radius: 20px;
  border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer;
  transition: all .15s ease;
}
.topo-profile-pill:hover  { background: rgba(255,255,255,.05); border-color: var(--border2); }
.topo-profile-pill.active {
  border-color: rgba(99,102,241,.55); background: rgba(99,102,241,.16); color: #a5b4fc;
  font-weight: 600; box-shadow: 0 0 0 1px rgba(99,102,241,.12);
}
.topo-profile-pill .cnt {
  font-size: 9px; background: rgba(255,255,255,.08); padding: 0 6px; border-radius: 8px; margin-left: 1px;
}
.topo-profile-pill.active .cnt { background: rgba(255,255,255,.14); }
.topo-profile-pill .cnt.hit  { background: rgba(74,222,128,.18); color: #4ade80; }
.topo-profile-pill .cnt.fail { background: rgba(239,68,68,.18); color: #f87171; }

.topo-hint-row { font-size: 9px; color: var(--text3); margin: -3px 0 10px 2px; }

.topo-search-wrap { position: relative; margin-left: auto; }
.topo-search-wrap i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--text3); pointer-events: none;
}
.topo-search-input {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px;
  padding: 6px 10px 6px 29px; font-size: 11.5px; color: var(--text); outline: none;
  width: 250px; transition: border-color .15s ease, box-shadow .15s ease, width .2s ease;
}
.topo-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.16); width: 280px; }

/* ── Banner sumber data profil ── */
.topo-info-banner {
  display: flex; align-items: flex-start; gap: 9px; font-size: 11px; line-height: 1.55; color: #93c5fd;
  background: var(--blue-bg); border: 1px solid var(--blue-bd); border-radius: 10px; padding: 9px 12px; margin-bottom: 12px;
}
.topo-info-banner i { font-size: 14px; margin-top: 1px; flex-shrink: 0; }
.topo-info-banner b { color: #bfdbfe; }

/* ── Tabel jalur ONU ── */
.topo-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; overflow: auto; }
.topo-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
.topo-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface2, #1a2235);
  box-shadow: 0 1px 0 var(--border); padding: 8px 10px; text-align: left; font-size: 10px;
  font-weight: 700; letter-spacing: .03em; white-space: nowrap; color: var(--text3);
}
.topo-table tbody tr { border-top: 1px solid var(--border); transition: background-color .12s ease; vertical-align: top; }
.topo-table tbody tr:hover { background: rgba(255,255,255,.028); }
.topo-table tbody tr.row-online  { box-shadow: inset 3px 0 0 rgba(34,197,94,.55); }
.topo-table tbody tr.row-los     { box-shadow: inset 3px 0 0 rgba(245,158,11,.55); }
.topo-table tbody tr.row-offline { box-shadow: inset 3px 0 0 rgba(239,68,68,.55); }
.topo-table td { padding: 7px 10px; }
.topo-table td.mono { font-family: var(--mono); white-space: nowrap; }

.topo-status-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .02em; }
.topo-status-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.topo-status-badge.online .dot { animation: topo-dot-pulse 1.8s infinite; }
@keyframes topo-dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.55); }
  70%  { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

.topo-table-foot { font-size: 10px; color: var(--text3); margin-top: 6px; padding-left: 4px; }

/* ── Breadcrumb rantai titik pasif → OLT ── */
.topo-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 2px; }
.topo-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px; white-space: nowrap;
  color: var(--text); background: var(--surface3, rgba(255,255,255,.04)); border: 1px solid var(--border2);
  padding: 2px 8px; border-radius: 10px; transition: transform .12s ease, border-color .12s ease;
}
.topo-chip:hover { border-color: var(--border3); transform: translateY(-1px); }
.topo-chip .ty { opacity: .6; margin-left: 1px; }
.topo-chip.olt {
  color: #c4b5fd; background: rgba(167,139,250,.1); border-color: rgba(167,139,250,.3); font-weight: 600;
}
.topo-chip.olt i { font-size: 9px; }
.topo-chain-arrow { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.topo-chip-unmapped {
  font-size: 10px; color: var(--amber); background: var(--amber-bg); border: 1px solid var(--amber-bd);
  padding: 2px 9px; border-radius: 10px;
}

/* ── Empty / diagnostik state ── */
.topo-empty-cell { text-align: center; padding: 26px 16px; color: var(--text3); font-size: 12px; line-height: 1.7; }
.topo-diag-box {
  margin: 14px auto 0; font-size: 11px; color: #4ade80; background: rgba(74,222,128,.06);
  border: 1px solid rgba(74,222,128,.2); border-radius: 10px; padding: 10px 12px; display: block;
  max-width: 460px; text-align: center;
}
.topo-diag-box .lbl { display: flex; align-items: center; justify-content: center; gap: 5px; margin-bottom: 7px; font-weight: 600; }
.topo-diag-chip {
  margin: 2px 3px; font-size: 10px; padding: 3px 11px; border-radius: 12px; border: 1px solid rgba(74,222,128,.35);
  background: rgba(74,222,128,.08); color: #4ade80; cursor: pointer; transition: all .15s ease;
}
.topo-diag-chip:hover { background: rgba(74,222,128,.18); transform: translateY(-1px); }
.topo-diag-note { margin-top: 8px; color: var(--text3); font-size: 10.5px; }

.topo-empty-state { display: flex; align-items: center; justify-content: center; height: 280px; color: var(--text3); font-size: 13px; }
.topo-empty-state i { font-size: 38px; display: block; margin-bottom: 10px; opacity: .3; }

/* ── Skeleton loading (sidebar & rows) ── */
.topo-skel { border-radius: 8px; background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 37%, rgba(255,255,255,.04) 63%); background-size: 400% 100%; animation: topo-shimmer 1.4s ease infinite; }
@keyframes topo-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.topo-skel-card { height: 58px; border-radius: 11px; margin-bottom: 2px; }
.topo-skel-row  { height: 14px; margin: 8px 10px; }

/* ── Responsive ── */
@media (max-width: 880px) {
  .topo-page { flex-direction: column; overflow-y: auto; overflow-x: hidden; }
  .topo-sidebar { width: 100%; max-height: 260px; }
  .topo-search-wrap { margin-left: 0; width: 100%; }
  .topo-search-input { width: 100%; }
  .topo-search-input:focus { width: 100%; }
}