/* ============================================================
   neWave Fiber Lab 3D — layout & components
   Desktop: skena si pjesa më e madhe + panel anësor.
   Mobile (<920px): skena sipër, detaje poshtë.
   ============================================================ */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 10px 20px;
  min-height: 60px;
  background: linear-gradient(180deg, #0e1c31 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid rgba(34, 211, 238, 0.35);
  flex: none;
}

.brand-text { min-width: 0; }

.brand-text h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-3d { color: var(--brand); }

.brand-text p {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}
.badge .ic { width: 15px; height: 15px; }
.badge-sim {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid rgba(251, 191, 36, 0.35);
  flex: none;
}
.badge-text-short { display: none; }

/* ---------- App grid ---------- */

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
  height: calc(100dvh - 60px);
  min-height: 0;
}

body { overflow: hidden; }

/* ---------- Scene ---------- */

.scene-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

.scene-canvas { position: absolute; inset: 0; }
.scene-canvas canvas { outline: none; touch-action: none; }

.scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(8, 16, 30, 0) 55%, rgba(5, 10, 20, 0.55) 100%);
}

.scene-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.lb {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -100%);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--text);
  background: rgba(9, 18, 33, 0.82);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  pointer-events: none;
}
.lb small {
  font-weight: 500;
  color: var(--text-dim);
  font-size: 10px;
  margin-left: 5px;
}
.lb-onu { pointer-events: auto; cursor: pointer; transition: border-color 150ms ease-out, background 150ms ease-out; }
.lb-onu:hover, .lb-onu:focus-visible { border-color: var(--brand); background: rgba(12, 26, 45, 0.95); }
.lb-onu .lb-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.lb-onu[data-state="online"] .lb-dot { background: var(--ok); }
.lb-onu[data-state="offline"] .lb-dot { background: var(--danger); }
.lb-onu.is-selected { border-color: var(--brand); color: var(--brand-ring); background: rgba(13, 30, 51, 0.95); }
.lb-cut { color: #ffd7d7; border-color: rgba(248, 113, 113, 0.65); background: rgba(45, 12, 16, 0.85); }
.lb-incident { color: #ffedc4; border-color: rgba(251, 191, 36, 0.6); background: rgba(44, 32, 6, 0.85); }

/* Overlays on the scene */

.scene-overlay-top {
  position: absolute;
  top: 14px; left: 14px; right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

.metric-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(10, 20, 36, 0.82);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-1);
}
.chip strong { font-weight: 800; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip-ok { color: #b8f5dd; border-color: rgba(52, 211, 153, 0.45); }
.chip-ok .dot { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, 0.8); }
.chip-ok strong { color: #d9fbee; }
.chip-danger { color: #ffd4d4; border-color: rgba(248, 113, 113, 0.45); }
.chip-danger .dot { background: var(--danger); box-shadow: 0 0 8px rgba(248, 113, 113, 0.8); }
.chip-danger strong { color: #ffe9e9; }
.chip-neutral { color: var(--text-dim); }
.chip-neutral strong { color: var(--text); }

.scene-actions { display: flex; gap: 8px; pointer-events: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-m);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 150ms ease-out, border-color 150ms ease-out, transform 80ms ease-out;
}
.btn:active { transform: translateY(1px); }

.btn-ghost {
  color: var(--text);
  background: rgba(10, 20, 36, 0.82);
  border-color: var(--border-strong);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-1);
}
.btn-ghost:hover { border-color: var(--brand); background: rgba(14, 28, 48, 0.92); }
.btn-ghost .ic { width: 16px; height: 16px; color: var(--brand); }

.scene-hint {
  position: absolute;
  right: 16px;
  bottom: 52px;
  font-size: 11.5px;
  color: var(--text-faint);
  pointer-events: none;
  z-index: 4;
  text-align: right;
}

.scene-event {
  position: absolute;
  left: 14px; right: 14px; bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  background: rgba(9, 17, 31, 0.88);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-1);
  pointer-events: none;
  z-index: 5;
  min-height: 44px;
}
.scene-event .ev-icon { width: 17px; height: 17px; flex: none; }
.ev-text {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
}
.ev-time { flex: none; font-size: 12px; color: var(--text-faint); font-weight: 600; }
#event-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scene-event.tone-ok    { border-left-color: var(--ok); }     .scene-event.tone-ok .ev-icon    { color: var(--ok); }
.scene-event.tone-error { border-left-color: var(--danger); } .scene-event.tone-error .ev-icon { color: var(--danger); }
.scene-event.tone-warn  { border-left-color: var(--warn); }   .scene-event.tone-warn .ev-icon  { color: var(--warn); }

/* WebGL fallback */
.webgl-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
}

/* ---------- Side panel ---------- */

.panel {
  overflow-y: auto;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.panel-block {
  padding: 18px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-block h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-pill {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-ring);
  background: var(--brand-soft);
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 1px 8px;
  border-radius: 999px;
}

/* Scenario buttons */

.scenario-list { display: grid; gap: 8px; }

.btn-scenario {
  width: 100%;
  align-items: flex-start;
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text-dim);
  min-height: 48px;
}
.btn-scenario .ic { margin-top: 3px; width: 19px; height: 19px; color: var(--text-faint); transition: color 150ms ease-out; }
.btn-scenario-text { display: grid; gap: 1px; min-width: 0; }
.btn-scenario-text strong { font-size: 14px; font-weight: 700; color: var(--text); }
.btn-scenario-text small { font-size: 12px; line-height: 1.4; }
.btn-scenario:hover { border-color: var(--brand-strong); }

.btn-scenario[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), rgba(14, 165, 233, 0.10));
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.25), var(--shadow-1);
}
.btn-scenario[aria-pressed="true"] .ic { color: var(--brand); }

/* Detail panel */

.detail-empty { color: var(--text-dim); font-size: 13.5px; }

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.status-icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  flex: none;
}
.status-icon .ic { width: 21px; height: 21px; }
.status-icon.is-online { color: var(--ok); background: var(--ok-bg); border: 1px solid rgba(52, 211, 153, 0.4); }
.status-icon.is-offline { color: var(--danger); background: var(--danger-bg); border: 1px solid rgba(248, 113, 113, 0.4); }
.detail-title { min-width: 0; display: grid; }
.detail-title strong { font-size: 15px; font-weight: 700; }
.detail-sub { font-size: 12.5px; color: var(--text-dim); }

.detail-head .chip { margin-left: auto; font-size: 12px; padding: 5px 10px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.detail-grid > div {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 11px;
  min-width: 0;
}
.detail-grid .span-2 { grid-column: span 2; }
.detail-grid dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.detail-grid dd {
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: var(--radius-s);
  border: 1px dashed var(--border-strong);
  background: rgba(13, 24, 42, 0.5);
}
.detail-note strong { color: var(--text); }

/* ONU list */

.onu-list { display: grid; gap: 6px; }

.onu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  min-height: 48px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
  background: var(--panel-2);
  text-align: left;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.onu-item:hover { border-color: var(--brand-strong); }

.onu-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.onu-item[data-state="online"] .onu-dot { background: var(--ok); box-shadow: 0 0 7px rgba(52, 211, 153, 0.7); }
.onu-item[data-state="offline"] .onu-dot { background: var(--danger); box-shadow: 0 0 7px rgba(248, 113, 113, 0.7); }

.onu-names { display: grid; min-width: 0; flex: 1; }
.onu-names strong { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onu-names small { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.onu-state {
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.onu-item[data-state="online"] .onu-state { color: var(--ok); background: var(--ok-bg); }
.onu-item[data-state="offline"] .onu-state { color: var(--danger); background: var(--danger-bg); }

.onu-item[aria-current="true"] {
  border-color: var(--brand);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.14), rgba(14, 165, 233, 0.07));
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.22);
}

/* Legend */

.legend-list {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.legend-list li { display: flex; align-items: center; gap: 10px; }
.legend-list .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); }
.dot-danger { background: var(--danger); }
.dot-warn { background: var(--warn); }

.fiber-sample {
  width: 26px; height: 6px;
  border-radius: 999px;
  flex: none;
}
.fiber-active { background: linear-gradient(90deg, #0ea5e9, #67e8f9); box-shadow: 0 0 8px rgba(34, 211, 238, 0.7); }
.fiber-dark { background: #2b3d55; }
.fiber-broken { background: repeating-linear-gradient(90deg, #ef4444 0 5px, #7f1d1d 5px 10px); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }

.sim-note {
  font-size: 12.5px;
  color: var(--text-faint);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.sim-note strong { color: var(--text-dim); }

/* ---------- Mobile: skena sipër, detaje poshtë ---------- */

@media (max-width: 920px) {
  body { overflow: auto; }

  .app-header { padding: 10px 14px; gap: 10px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 15px; }
  .badge-sim { font-size: 11.5px; padding: 6px 10px; gap: 6px; }
  .badge-sim .badge-text-long { display: none; }
  .badge-text-short { display: inline; }

  .app-main {
    grid-template-columns: 1fr;
    height: auto;
  }

  .scene-wrap {
    height: 52dvh;
    min-height: 360px;
    border-bottom: 1px solid var(--border);
  }

  .scene-overlay-top { top: 10px; left: 10px; right: 10px; flex-wrap: wrap; }
  .chip { font-size: 12px; padding: 6px 10px; }
  .btn { min-height: 44px; }

  .scene-hint { display: none; }

  .scene-event {
    left: 10px; right: 10px; bottom: 10px;
    padding: 8px 12px;
  }
  .ev-text { flex-direction: column; gap: 0; align-items: flex-start; }
  #event-text { white-space: normal; font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

  .panel { border-left: 0; }

  .panel-block { padding: 16px 14px 18px; }
}

@media (max-width: 480px) {
  .brand-text h1 { font-size: 14px; }
  .brand-text p { display: none; }
}

/* Touch comfort: lista dhe skenarët më të mëdhenj në ekranet me gisht */
@media (pointer: coarse) {
  .btn, .onu-item, .btn-scenario { min-height: 50px; }
  .lb-onu { padding: 5px 11px; font-size: 12px; }
}
