/* =========================================================
   StreamPortal 2.0 - Public Viewer Analytics Bar
   Per-event only. Uses only CSS variables from main.css.
   No inline styles, no external dependencies.
   ========================================================= */

.analytics-bar {
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-top: none;
  margin-bottom: 12px;
  overflow: hidden;
}

.analytics-bar.analytics-empty {
  display: none;
}

/* ---- Header -------------------------------------------- */

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.analytics-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.analytics-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.analytics-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--neon-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
  flex-shrink: 0;
  animation: analyticsLivePulse 2s ease-in-out infinite;
}

@keyframes analyticsLivePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.analytics-header-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.analytics-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.analytics-header-viewers {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.analytics-header-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--neon-cyan);
  line-height: 1;
}

.analytics-header-count-label {
  font-size: 10px;
  color: var(--text-muted);
}

.analytics-top-country {
  font-size: 13px;
  color: var(--text-secondary);
}

.analytics-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius);
  transition: color 0.15s ease, background 0.15s ease;
  font-family: inherit;
  flex-shrink: 0;
}

.analytics-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ---- Collapsible body ---------------------------------- */

.analytics-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.analytics-bar.expanded .analytics-body {
  max-height: 500px;
}

/* ---- Badge row ----------------------------------------- */

.analytics-badges {
  display: flex;
  gap: 6px;
  padding: 10px 14px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.analytics-badges::-webkit-scrollbar {
  display: none;
}

.analytics-badge {
  flex-shrink: 0;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s ease;
}

.analytics-badge:hover {
  border-color: rgba(59, 130, 246, 0.3);
}

.analytics-badge-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-badge-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.analytics-badge.badge-viewers .analytics-badge-value { color: var(--neon-cyan); }
.analytics-badge.badge-peak    .analytics-badge-value { color: var(--neon-blue); }
.analytics-badge.badge-bw      .analytics-badge-value { color: var(--neon-green); }
.analytics-badge.badge-country .analytics-badge-value { color: var(--neon-orange); font-size: 14px; }
.analytics-badge.badge-reach   .analytics-badge-value { color: var(--neon-purple); }

/* ---- Geo panel ----------------------------------------- */

.analytics-geo {
  padding: 0 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.analytics-geo-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 0 5px;
}

.analytics-geo-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-geo-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-geo-flag {
  font-size: 15px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  line-height: 1;
}

.analytics-geo-name {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-geo-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

.analytics-geo-bar-track {
  width: 64px;
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  flex-shrink: 0;
  overflow: hidden;
}

.analytics-geo-bar-fill {
  height: 100%;
  background: var(--neon-cyan);
  border-radius: 2px;
  transition: width 0.5s ease;
  min-width: 2px;
}

/* ---- Lane chips ---------------------------------------- */

.analytics-lanes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.analytics-lane-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  font-size: 12px;
  transition: border-color 0.15s ease;
}

.analytics-lane-chip.chip-active {
  border-color: rgba(16, 185, 129, 0.3);
}

.analytics-lane-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-lane-chip-dot.dot-active {
  background: var(--neon-green);
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.8);
}

.analytics-lane-chip-dot.dot-idle {
  background: var(--text-muted);
}

.analytics-lane-chip-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.analytics-lane-chip-count {
  color: var(--neon-cyan);
  font-weight: 700;
}

/* ---- Embed mode ---------------------------------------- */

.public-page.embed-mode .analytics-bar {
  display: none !important;
}

/* ---- Responsive ---------------------------------------- */

@media (max-width: 768px) {
  .analytics-header-viewers { display: none; }
  .analytics-top-country    { display: none; }
  .analytics-geo-bar-track  { display: none; }
}

@media (max-width: 600px) {
  .analytics-badges {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 8px 10px 6px;
    gap: 5px;
    overflow-x: unset;
    scroll-snap-type: unset;
  }

  .analytics-badge {
    min-width: unset;
    width: 100%;
    padding: 7px 10px;
    scroll-snap-align: unset;
  }

  .analytics-badge-value { font-size: 15px; }

  .analytics-badge.badge-country {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .analytics-badge.badge-country .analytics-badge-value { font-size: 13px; }

  .analytics-lanes {
    padding: 5px 10px 8px;
    gap: 4px;
  }

  .analytics-lane-chip {
    padding: 3px 8px;
    font-size: 11px;
  }

  .analytics-geo {
    padding: 0 10px 8px;
  }
}
