/* ============================================================
   AIN Network Traffic — bandwidth + interface utilization view
   Prefix: .traf-
   Colour theme: cyan/blue (inbound) + violet (outbound),
   with red/orange flares for errors and overloaded interfaces.
   ============================================================ */

.traf-root {
  /* No `position` — let .scr position us (see styles.css). */
  padding: 18px 22px 32px;
  color: #d4d4d4;
}
.traf-root > * + * { margin-top: 16px; }

/* ── Background ─────────────────────────────────────────── */
.traf-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(6, 182, 212, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(6, 182, 212, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none; z-index: 0;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 0%, transparent 80%);
}
.traf-bg-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 20%,  rgba(6, 182, 212, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 90%,  rgba(167, 139, 250, 0.10), transparent 60%);
  pointer-events: none; z-index: 0;
  animation: traf-glow-shift 16s ease-in-out infinite alternate;
}
@keyframes traf-glow-shift {
  0%   { opacity: 0.7; transform: translate(0, 0) scale(1); }
  100% { opacity: 1;   transform: translate(2%, -1%) scale(1.04); }
}
.traf-root > * { position: relative; z-index: 1; }

/* ── Header ─────────────────────────────────────────────── */
.traf-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  /* background: linear-gradient(135deg, rgba(15, 23, 42, 0.7), rgba(20, 30, 50, 0.5)); */
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  position: relative; overflow: hidden;
}
.traf-header::before {
  content: '';
  position: absolute; top: 0; left: -100%; width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, #06B6D4, #A78BFA, transparent);
  animation: traf-sweep 4s ease-in-out infinite;
}
@keyframes traf-sweep {
  0%, 100% { left: -100%; }
  50%      { left: 100%; }
}
.traf-title {
  font-size: 18px; font-weight: 800; letter-spacing: 4px;
  background: linear-gradient(135deg, #fff, #67e8f9, #C4B5FD);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 26px rgba(6, 182, 212, 0.4);
}
.traf-subtitle {
  font-size: 10px; color: #6b7280;
  letter-spacing: 1.5px; margin-top: 4px;
}
.traf-pill {
  padding: 6px 12px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: 4px;
  font-size: 11px; color: #67e8f9;
  letter-spacing: 1px; font-weight: 600;
}

/* ── KPI Cards ──────────────────────────────────────────── */
.traf-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.traf-kpi-card {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.85), rgba(20, 30, 50, 0.7));
  border: 1px solid rgba(6, 182, 212, 0.18);
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  animation: traf-slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.traf-kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, #06B6D4), transparent);
  opacity: 0.7;
}
.traf-kpi-card::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at top right, var(--accent, #06B6D4), transparent 60%);
  opacity: 0.06; pointer-events: none;
}
.traf-kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 28px var(--accent)33;
}
.traf-kpi-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 20px;
  flex-shrink: 0;
}
.traf-kpi-body { flex: 1; min-width: 0; position: relative; z-index: 2; }
.traf-kpi-value {
  font-size: 28px; font-weight: 800;
  color: #fff; line-height: 1;
  text-shadow: 0 0 20px var(--accent);
  margin-bottom: 4px;
  font-feature-settings: 'tnum';
}
.traf-kpi-label {
  font-size: 9px; color: #6b7280;
  letter-spacing: 1.5px; font-weight: 600;
}
.traf-kpi-row .traf-kpi-card:nth-child(1) { animation-delay: 0.05s; }
.traf-kpi-row .traf-kpi-card:nth-child(2) { animation-delay: 0.10s; }
.traf-kpi-row .traf-kpi-card:nth-child(3) { animation-delay: 0.15s; }
.traf-kpi-row .traf-kpi-card:nth-child(4) { animation-delay: 0.20s; }

/* ── Section shell ──────────────────────────────────────── */
.traf-section {
  /* background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(20, 30, 50, 0.6)); */
  border: 1px solid rgba(6, 182, 212, 0.18);
  border-radius: 8px;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  position: relative; overflow: hidden;
  animation: traf-slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.25s;
}
.traf-section::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.5), transparent);
}
.traf-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(6, 182, 212, 0.1);
  flex-wrap: wrap; gap: 10px;
}
.traf-section-title {
  font-size: 11px; font-weight: 700;
  color: #67e8f9; letter-spacing: 2px;
}
.traf-section-meta {
  font-size: 10px; color: #9ca3af;
  letter-spacing: 0.5px;
}
.traf-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #6b7280;
  padding: 30px;
}

/* ── Bandwidth wave ─────────────────────────────────────── */
.traf-wave-section { animation-delay: 0.3s; }
.traf-wave-host {
  width: 100%; min-height: 220px;
}
.traf-wave-svg {
  width: 100%; height: 220px;
  display: block;
}
.traf-wave-legend {
  display: flex; gap: 14px;
  font-size: 11px; color: #d4d4d4;
}
.traf-wave-legend > span {
  display: inline-flex; align-items: center; gap: 6px;
}
.traf-leg-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

/* ── Top talkers ────────────────────────────────────────── */
.traf-talkers {
  display: flex; flex-direction: column; gap: 6px;
}
.traf-talker-row {
  display: grid;
  grid-template-columns: 28px 200px 1fr 120px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,0.025);
  border-left: 2px solid #06B6D4;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  animation: traf-slide-right 0.4s ease backwards;
}
.traf-talker-row:hover {
  background: rgba(6, 182, 212, 0.08);
  transform: translateX(2px);
}
.traf-talker-rank {
  text-align: center;
  font-size: 18px; font-weight: 800;
  color: #67e8f9;
  font-family: monospace;
}
.traf-talker-name { min-width: 0; }
.traf-talker-title {
  color: #fff; font-weight: 600; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.traf-talker-type {
  color: #6b7280; font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase;
  margin-top: 2px;
}
.traf-talker-bars {
  display: flex; flex-direction: column; gap: 4px;
}
.traf-talker-bar-row {
  display: grid;
  grid-template-columns: 40px 1fr 90px;
  gap: 8px;
  align-items: center;
  font-size: 10px;
}
.traf-talker-dir {
  color: #9ca3af;
  font-family: monospace;
  font-weight: 600;
}
.traf-talker-bar {
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px; overflow: hidden;
}
.traf-talker-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.traf-talker-fill.traf-rx {
  background: linear-gradient(90deg, #06B6D4, #0891b2);
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.5);
}
.traf-talker-fill.traf-tx {
  background: linear-gradient(90deg, #A78BFA, #8B5CF6);
  box-shadow: 0 0 6px rgba(167, 139, 250, 0.5);
}
.traf-talker-val {
  color: #fff; font-weight: 700;
  font-family: monospace; font-size: 10px;
  text-align: right;
}
.traf-talker-total {
  text-align: center;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.08);
}
.traf-talker-total-num {
  font-size: 14px; font-weight: 800;
  color: #fff;
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}
.traf-talker-total-lbl {
  font-size: 8px; color: #6b7280;
  letter-spacing: 1.5px; margin-top: 2px;
}

/* ── Heatmap ────────────────────────────────────────────── */
.traf-heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 4px;
  min-height: 80px;
}
.traf-heat-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: rgba(0,0,0,0.7);
  transition: transform 0.15s ease;
  animation: traf-fade-in 0.4s ease backwards;
}
.traf-heat-cell:hover {
  transform: scale(1.5);
  z-index: 5; position: relative;
}
.traf-heatmap-legend {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; color: #9ca3af;
}
.traf-heat-leg-tile {
  width: 12px; height: 12px;
  border-radius: 2px;
  margin-left: 6px;
}
.traf-heat-leg-tile:first-child { margin-left: 0; }

/* ── Bottom row ─────────────────────────────────────────── */
.traf-row-bottom {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}

/* Errors */
.traf-errors {
  display: flex; flex-direction: column; gap: 8px;
}
.traf-err-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px 50px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid #EF4444;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.15s;
  animation: traf-slide-right 0.4s ease backwards;
}
.traf-err-row:hover { background: rgba(239, 68, 68, 0.08); }
.traf-err-name {
  color: #fff; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.traf-err-stats {
  display: flex; gap: 10px;
  font-size: 10px; font-family: monospace;
  flex-wrap: wrap;
}
.traf-err-stat { font-weight: 700; }
.traf-err-bar {
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px; overflow: hidden;
}
.traf-err-fill {
  height: 100%;
  background: linear-gradient(90deg, #F59E0B, #EF4444);
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
  transition: width 0.6s ease;
}
.traf-err-total {
  font-family: monospace; font-weight: 700;
  color: #EF4444; font-size: 12px;
  text-align: right;
}

/* Protocol breakdown donut */
.traf-protocol {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}
.traf-proto-flex {
  display: flex; align-items: center; gap: 16px; width: 100%;
}
.traf-proto-svg-wrap { position: relative; flex-shrink: 0; }
.traf-proto-svg { width: 180px; height: 180px; }
.traf-proto-center {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.traf-proto-center-num {
  font-size: 24px; font-weight: 800; color: #fff;
}
.traf-proto-center-lbl {
  font-size: 9px; color: #6b7280;
  letter-spacing: 1.5px; margin-top: 2px;
}
.traf-proto-legend {
  flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}
.traf-proto-leg-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px; align-items: center;
  padding: 6px 10px;
  background: rgba(255,255,255,0.025);
  border-radius: 4px;
  font-size: 12px;
}
.traf-proto-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
}
.traf-proto-leg-label { color: #d4d4d4; font-weight: 600; }
.traf-proto-leg-pct {
  font-family: monospace; font-weight: 800;
  font-size: 13px;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes traf-slide-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes traf-slide-right {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes traf-fade-in {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1280px) {
  .traf-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .traf-row-bottom { grid-template-columns: 1fr; }
  .traf-talker-row { grid-template-columns: 24px 130px 1fr 90px; }
}
@media (max-width: 768px) {
  .traf-kpi-row { grid-template-columns: 1fr; }
  .traf-talker-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .traf-talker-rank { display: none; }
  .traf-header { flex-direction: column; gap: 8px; text-align: center; }
}