/* ── Analytics Dashboard ─────────────────────────────── */
/* Scoped to #screen-analytics and its exclusive classes. */

/* Top-align so long content scrolls naturally instead of
   being pushed off the top of the viewport by flex centering. */
#screen-analytics {
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
}

.analytics-container {
  width: 100%;
  max-width: 1040px;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
}

.analytics-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 8px;
}

.analytics-header .screen-title {
  flex: 1;
}

.analytics-refresh {
  padding: 6px 12px;
  cursor: pointer;
}

.analytics-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 28px;
}

.analytics-canvas {
  width: 100% !important;
  max-height: 260px;
}

/* ── Summary tiles ───────────────────────────────────── */
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.analytics-tile {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-tile-label {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.analytics-tile-value {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--accent);
}

/* ── Two-column rows on wide screens ─────────────────── */
.analytics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .analytics-row {
    grid-template-columns: 1fr;
  }
}

/* ── Tabs (top games) ────────────────────────────────── */
.analytics-tabs {
  display: flex;
  gap: 4px;
}

.analytics-tab {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.analytics-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.analytics-tab.active {
  background: rgba(0, 229, 160, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Heatmap (7 rows dow × 24 cols hour) ─────────────── */
.analytics-heatmap {
  display: grid;
  grid-template-columns: 40px repeat(24, 1fr);
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
}

.analytics-heatmap-hour-header,
.analytics-heatmap-dow-label {
  text-align: center;
  padding: 2px 0;
}

.analytics-heatmap-dow-label {
  text-align: right;
  padding-right: 6px;
  align-self: center;
}

.analytics-heatmap-cell {
  aspect-ratio: 1;
  min-height: 14px;
  border-radius: 2px;
  background: var(--surface2);
  transition: transform 0.1s;
  cursor: default;
}

.analytics-heatmap-cell:hover {
  transform: scale(1.15);
  outline: 1px solid var(--accent);
}

/* ── Netplay summary ─────────────────────────────────── */
.analytics-netplay {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.analytics-netplay-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.analytics-netplay-row:last-child {
  border-bottom: none;
}

.analytics-netplay-label {
  color: var(--text-dim);
  font-size: 10px;
}

.analytics-netplay-value {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--accent);
}

.analytics-netplay-adoption {
  display: flex;
  gap: 4px;
  width: 100%;
  height: 12px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface2);
}

.analytics-netplay-adoption-seg {
  height: 100%;
  transition: flex-basis 0.3s;
}

/* Admin-panel link card (reuses admin styles) */
.admin-link-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-link-btn {
  align-self: flex-start;
  font-size: 10px;
  padding: 10px 20px;
  text-decoration: none;
  display: inline-block;
}

/* Loading state */
.analytics-loading {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  padding: 12px 0;
  text-align: center;
}

/* ── Geography (choropleth) ──────────────────────────── */
.analytics-geo-wrap {
  position: relative;
  width: 100%;
}

.analytics-geo-map {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.analytics-geo-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.analytics-geo-region {
  fill: var(--surface2);
  stroke: #2a2a2a;
  stroke-width: 0.4;
  transition: fill 0.15s, stroke 0.15s;
  cursor: default;
}

.analytics-geo-region:hover {
  stroke: var(--accent);
  stroke-width: 1.2;
}

.analytics-geo-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text);
  white-space: nowrap;
  z-index: 10;
  transform: translate(-50%, -110%);
}

.analytics-geo-tooltip-name {
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 9px;
  margin-bottom: 2px;
}

.analytics-geo-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  padding: 4px 0;
}

.analytics-geo-legend-bar {
  flex: 1;
  max-width: 240px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--surface2), rgba(0, 229, 160, 0.9));
}

/* ── Page views — top pages list ─────────────────────── */
.analytics-pageviews-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.analytics-pageviews-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--surface2);
}

.analytics-pageviews-name {
  flex: 1;
  min-width: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-pageviews-count {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--accent);
  white-space: nowrap;
}

.analytics-pageviews-users {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
}
