/* ============================================================
   AIN Performance Analytics — sister tab to Operations Center
   Prefix: .perf-
   Built around big gauges, leaderboard cards, and tighter
   data-density lists.
   ============================================================ */

.perf-root {
  /* No `position` — let the parent .scr layer position us. */
  padding: 18px 22px 32px;
  color: #d4d4d4;
}
.perf-root > * + * { margin-top: 16px; }

/* ── Background ─────────────────────────────────────────── */
.perf-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(139, 92, 246, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 92, 246, 0.04) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none; z-index: 0;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 0%, transparent 80%);
}
.perf-bg-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 50% 35% at 25% 15%, rgba(139, 92, 246, 0.10), transparent 60%),
    radial-gradient(ellipse 50% 35% at 75% 85%, rgba(6, 182, 212, 0.07),   transparent 60%);
  pointer-events: none; z-index: 0;
  animation: perf-glow-shift 20s ease-in-out infinite alternate;
}
@keyframes perf-glow-shift {
  0%   { opacity: 0.7; transform: translate(0, 0); }
  100% { opacity: 1;   transform: translate(-2%, 2%); }
}
.perf-root > * { position: relative; z-index: 1; }

/* ── Header ─────────────────────────────────────────────── */
.perf-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(139, 92, 246, 0.25);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}
.perf-header::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, #A78BFA, transparent);
  animation: perf-sweep 5s ease-in-out infinite;
}
@keyframes perf-sweep {
  0%, 100% { left: -100%; }
  50%      { left: 100%; }
}
.perf-title {
  font-size: 18px; font-weight: 800; letter-spacing: 4px;
  background: linear-gradient(135deg, #fff, #C4B5FD);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 26px rgba(139, 92, 246, 0.4);
}
.perf-subtitle {
  font-size: 10px; color: #6b7280;
  letter-spacing: 1.5px; margin-top: 4px;
}
.perf-pill {
  padding: 6px 12px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 4px;
  font-size: 11px; color: #C4B5FD;
  letter-spacing: 1px; font-weight: 600;
}

/* ── Sections (shared shell) ────────────────────────────── */
.perf-section {
  /* background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(20, 30, 50, 0.6)); */
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  position: relative; overflow: hidden;
  animation: perf-slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.perf-section::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.5), transparent);
}
.perf-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}
.perf-section-title {
  font-size: 11px; font-weight: 700;
  color: #C4B5FD; letter-spacing: 2px;
}
.perf-section-meta {
  font-size: 10px; color: #9ca3af;
}
.perf-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #6b7280;
  padding: 20px;
}
.perf-loading { color: #6b7280; font-size: 14px; text-align: center; padding: 20px; }

/* ── Row 1: Gauges + side stack ─────────────────────────── */
.perf-row-gauges {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 220px;
  gap: 14px;
}
.perf-gauge-card {
  /* background: linear-gradient(145deg, rgba(15, 23, 42, 0.85), rgba(20, 30, 50, 0.7)); */
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 8px;
  padding: 14px 14px 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: perf-slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.perf-gauge-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #A78BFA, transparent);
  opacity: 0.7;
}
.perf-gauge-label {
  font-size: 10px; font-weight: 700;
  color: #C4B5FD; letter-spacing: 2px;
  margin-bottom: 6px;
}
.perf-gauge-host {
  display: flex; align-items: center; justify-content: center;
  min-height: 140px;
  padding: 8px 0;
}
.perf-gauge-svg {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
}

.perf-side-stack {
  display: flex; flex-direction: column; gap: 14px;
}
.perf-mini-kpi {
  flex: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.85), rgba(20, 30, 50, 0.7));
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-left: 3px solid var(--accent, #06B6D4);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.perf-mini-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--accent, #06B6D4);
  box-shadow: 0 4px 16px var(--accent, #06B6D4)33;
}
.perf-mini-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid var(--accent, #06B6D4);
  border-radius: 5px;
  font-size: 16px;
  flex-shrink: 0;
}
.perf-mini-body { flex: 1; min-width: 0; }
.perf-mini-value {
  font-size: 22px; font-weight: 800;
  color: #fff; line-height: 1;
  text-shadow: 0 0 12px var(--accent, #06B6D4);
}
.perf-mini-label {
  font-size: 9px; color: #6b7280;
  letter-spacing: 1.5px; margin-top: 4px;
}

/* ── Leaderboard ────────────────────────────────────────── */
.perf-leaderboard {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.perf-rank-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px;
  background: linear-gradient(135deg, rgba(0,0,0,0.35), rgba(20, 30, 50, 0.5));
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-left: 3px solid var(--accent, #06B6D4);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  animation: perf-slide-up 0.5s ease backwards;
  position: relative;
  overflow: hidden;
}
.perf-rank-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 6px 20px var(--accent)44;
}
.perf-rank-medal {
  font-size: 22px;
  width: 32px; text-align: center;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px var(--accent));
}
.perf-rank-body { flex: 1; min-width: 0; }
.perf-rank-name {
  color: #fff; font-weight: 700;
  font-size: 12px; margin-bottom: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.perf-rank-type {
  color: #9ca3af; font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: 6px;
}
.perf-rank-bars {
  display: flex; flex-direction: column; gap: 2px;
}
.perf-rank-bar-row {
  display: grid;
  grid-template-columns: 28px 1fr 32px;
  gap: 5px;
  align-items: center;
  font-size: 9px;
}
.perf-rank-bar-label { color: #6b7280; font-weight: 600; }
.perf-rank-bar {
  height: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px; overflow: hidden;
}
.perf-rank-bar-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.6s ease;
}
.perf-rank-bar-val {
  font-family: monospace; font-weight: 700;
  text-align: right;
}
.perf-rank-worst {
  text-align: center;
  flex-shrink: 0;
  padding: 0 6px;
}
.perf-rank-worst-num {
  font-size: 24px; font-weight: 800;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 0 12px var(--accent);
}
.perf-rank-worst-pct { font-size: 12px; opacity: 0.7; }
.perf-rank-worst-label {
  font-size: 8px; color: #6b7280;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

/* ── Top lists 2x2 ──────────────────────────────────────── */
.perf-row-tops {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.perf-list { font-size: 11px; }
.perf-list-row {
  display: grid;
  grid-template-columns: 24px 1fr 1fr 60px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  animation: perf-slide-up 0.4s ease backwards;
}
.perf-list-row:last-child { border-bottom: none; }
.perf-list-rank {
  color: #6b7280; font-weight: 700;
  font-size: 10px; text-align: center;
  font-family: monospace;
}
.perf-list-name {
  color: #d4d4d4; font-weight: 500;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.perf-list-bar {
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px; overflow: hidden;
}
.perf-list-fill {
  height: 100%;
  background: linear-gradient(90deg, #22C55E, #16a34a);
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.perf-list-fill.high { background: linear-gradient(90deg, #F59E0B, #d97706); box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.perf-list-fill.crit { background: linear-gradient(90deg, #EF4444, #b91c1c); box-shadow: 0 0 6px rgba(239,68,68,0.6); }
.perf-list-val {
  color: #fff; font-weight: 700;
  font-size: 10px;
  text-align: right; font-family: monospace;
}

/* ── Donuts row ─────────────────────────────────────────── */
.perf-row-donuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.perf-donut-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}
.perf-donut-flex {
  display: flex; align-items: center; gap: 16px; width: 100%;
}
.perf-donut-svg-wrap { position: relative; flex-shrink: 0; }
.perf-donut-svg { width: 180px; height: 180px; }
.perf-donut-center {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.perf-donut-total {
  font-size: 28px; font-weight: 800; color: #fff;
  text-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}
.perf-donut-total-label {
  font-size: 10px; color: #6b7280;
  letter-spacing: 1.5px; margin-top: 2px;
}
.perf-donut-legend {
  flex: 1;
  display: flex; flex-direction: column; gap: 6px;
}
.perf-donut-leg-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  gap: 8px; align-items: center;
  padding: 4px 8px;
  background: rgba(255,255,255,0.02);
  border-radius: 3px;
  font-size: 11px;
}
.perf-donut-dot { width: 10px; height: 10px; border-radius: 50%; }
.perf-donut-leg-label { color: #d4d4d4; font-weight: 500; }
.perf-donut-leg-val { color: #fff; font-weight: 700; }
.perf-donut-leg-pct {
  color: #C4B5FD; font-family: monospace;
  min-width: 42px; text-align: right;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes perf-slide-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger for top-rows (so they don't all appear at once) */
.perf-row-tops .perf-section:nth-child(1) { animation-delay: 0.1s; }
.perf-row-tops .perf-section:nth-child(2) { animation-delay: 0.15s; }
.perf-row-tops .perf-section:nth-child(3) { animation-delay: 0.2s; }
.perf-row-tops .perf-section:nth-child(4) { animation-delay: 0.25s; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1280px) {
  .perf-row-gauges { grid-template-columns: 1fr 1fr 1fr; }
  .perf-side-stack { grid-column: 1 / -1; flex-direction: row; }
  .perf-leaderboard { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .perf-row-gauges, .perf-row-tops, .perf-row-donuts, .perf-leaderboard {
    grid-template-columns: 1fr;
  }
  .perf-side-stack { flex-direction: column; }
  .perf-header { flex-direction: column; gap: 8px; text-align: center; }
}