/*
 * Analytics — admin decision cockpit styles.
 *
 * Loaded after admin.css / components.css, so it consumes the light-content
 * design tokens (--color-*, --space-*, --radius-*, --shadow-*) already scoped
 * to .main. New, uniquely-prefixed (.an-*) classes only — no existing selector
 * is overridden. English-only, no external assets (Envato ZIP constraint).
 *
 * Colour story: GREEN = real humans (the thing that matters), GREY = bots
 * (filler). The gold brand accent stays for badges / the primary CTA.
 */

.main {
    --an-humans: #12B76A;
    --an-humans-soft: rgba(18, 183, 106, 0.14);
    --an-bots: #98A2B3;
    --an-bots-soft: rgba(152, 162, 179, 0.18);
    --an-blue: #2E90FA;
}

/* Zone rhythm. */
.an-zone { margin-top: var(--space-xl); }
.an-zone--live { margin-top: var(--space-lg); }
.an-zone > * + * { margin-top: var(--space-base); }

/* Live tag in the page head. */
.an-live-tag {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
}
.an-live-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--an-humans);
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.5);
    animation: an-pulse 2.4s ease-out infinite;
}
@media (prefers-reduced-motion: reduce) {
    .an-live-dot { animation: none; }
}
@keyframes an-pulse {
    0% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.45); }
    70% { box-shadow: 0 0 0 7px rgba(18, 183, 106, 0); }
    100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0); }
}

.an-accent { color: var(--an-humans); }
.an-loading {
    padding: var(--space-lg);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

/* ── Zone 1 — Live pulse ──────────────────────────────────────────────────*/
.an-stat-grid { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

.an-banner {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-base) var(--space-lg);
    border: 1px solid var(--color-border);
    border-left-width: 4px;
    border-radius: var(--radius-lg);
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
}
.an-banner__icon {
    flex: 0 0 auto;
    width: 10px; height: 10px; margin-top: 5px;
    border-radius: 50%;
    background: currentColor;
}
.an-banner__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.an-banner__title { font-size: var(--text-base); font-weight: 700; color: var(--color-text); }
.an-banner__body { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.5; }
.an-banner--ok { border-left-color: var(--an-humans); color: var(--an-humans); }
.an-banner--warn { border-left-color: var(--color-warning); color: var(--color-warning); }
.an-banner--info { border-left-color: var(--an-blue); color: var(--an-blue); }

.an-botbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: var(--space-sm);
    padding: var(--space-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--surface-sunken);
}
.an-botbar__item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: var(--space-sm) var(--space-xs);
    background: var(--surface-raised);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.an-botbar__value {
    font-size: var(--text-lg); font-weight: 700; color: var(--color-text);
    font-variant-numeric: tabular-nums;
}
.an-botbar__label {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

/* ── Segmented control (window selector + table sort) ─────────────────────*/
.an-seg {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.an-seg__btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 6px 14px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.an-seg--sm .an-seg__btn { padding: 5px 10px; font-size: var(--text-xs); }
.an-seg__btn:hover { color: var(--color-text); }
.an-seg__btn.is-active {
    background: var(--surface-raised);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}
.an-seg__btn:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 1px; }

.an-card__actions { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.an-manage-btn { text-decoration: none; }

/* ── Zone 2 — Cockpit ─────────────────────────────────────────────────────*/
.an-trend-body { display: flex; flex-direction: column; gap: var(--space-xl); }
.an-subcard__title {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--color-text);
}
.an-subcard__hint {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* Line / area chart. */
.an-chart { margin: 0; }
.an-chart__plot { width: 100%; }
.an-svg { display: block; width: 100%; height: auto; }
.an-svg--bars { height: 120px; }
.an-grid-line { stroke: var(--hairline); stroke-width: 1; }
.an-axis-label { fill: var(--color-text-muted); font-size: 11px; font-family: inherit; }

.an-area { opacity: 0.16; stroke: none; }
.an-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.an-dot { stroke: var(--surface-raised); stroke-width: 1; }
.an-s--humans { fill: var(--an-humans); stroke: var(--an-humans); }
.an-s--bots { fill: var(--an-bots); stroke: var(--an-bots); }

.an-legend { display: flex; gap: var(--space-base); margin-bottom: var(--space-sm); flex-wrap: wrap; }
.an-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.an-legend__swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.an-legend__swatch.an-s--humans { background: var(--an-humans); }
.an-legend__swatch.an-s--bots { background: var(--an-bots); }
.an-legend__label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-secondary); }

/* Bars. */
.an-bar--accent { fill: var(--an-humans); }
.an-bar--blue { fill: var(--an-blue); }

/* Heatmap. */
.an-heatmap-wrap { display: flex; flex-direction: column; gap: var(--space-md); }
.an-heatmap__scroll { overflow-x: auto; padding-bottom: 4px; }
.an-heatmap {
    display: grid;
    grid-template-columns: 34px repeat(24, minmax(15px, 1fr));
    gap: 3px;
    min-width: 520px;
}
.an-heatmap__corner { }
.an-heatmap__hour {
    font-size: 9px; color: var(--color-text-muted); text-align: center;
    align-self: end; padding-bottom: 2px;
}
.an-heatmap__day {
    font-size: 11px; font-weight: 600; color: var(--color-text-secondary);
    display: flex; align-items: center;
}
.an-heatmap__cell {
    aspect-ratio: 1 / 1;
    min-height: 15px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--an-humans) calc(var(--an-heat, 0) * 100%), var(--surface-sunken));
    border: 1px solid var(--hairline);
    cursor: default;
}
.an-heatmap__cell--empty { background: var(--surface-sunken); opacity: 0.55; }
.an-heatmap__cell:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 1px; }

.an-heatmap-scale { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.an-heatmap-scale__label { font-size: var(--text-xs); color: var(--color-text-muted); }
.an-heatmap-scale__swatches { display: inline-flex; gap: 3px; }
.an-heatmap-scale__swatch {
    width: 18px; height: 14px; border-radius: 3px;
    border: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--an-humans) calc(var(--an-heat, 0) * 100%), var(--surface-sunken));
}
.an-heatmap-scale__peak {
    font-size: var(--text-xs); color: var(--color-text-muted);
    margin-left: auto; font-weight: 600;
}

/* Table composition list. */
.an-tlist { display: flex; flex-direction: column; gap: var(--space-sm); }
.an-trow {
    display: grid;
    grid-template-columns: minmax(190px, 1.4fr) minmax(140px, 2fr) minmax(150px, auto);
    align-items: center;
    gap: var(--space-base);
    padding: var(--space-sm) var(--space-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
}
.an-trow--bots { background: var(--surface-sunken); }
.an-trow__meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.an-trow__id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: var(--text-xs); color: var(--color-text-muted);
    max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.an-fill {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: var(--an-bots-soft);
    overflow: hidden;
}
.an-fill--bots { background: var(--an-bots-soft); }
.an-fill__humans { position: absolute; inset: 0 auto 0 0; background: var(--an-humans); border-radius: 999px; }
.an-trow__counts { display: flex; gap: var(--space-base); justify-content: flex-end; }
.an-trow__c { font-size: var(--text-sm); color: var(--color-text-secondary); white-space: nowrap; }
.an-trow__c strong { font-variant-numeric: tabular-nums; }
.an-trow__c--h strong { color: var(--an-humans); }
.an-trow__c--b strong { color: var(--color-text-secondary); }

/* ── Zone 3 — Real players ────────────────────────────────────────────────*/
.an-zone-head__title { margin: 0; font-size: var(--text-xl); font-weight: 700; color: var(--color-text); }
.an-zone-head__sub { margin: 4px 0 0; font-size: var(--text-sm); color: var(--color-text-secondary); }

.an-players-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-base);
    align-items: start;
}
.an-players-col {
    display: flex;
    flex-direction: column;
    gap: var(--space-base);
    min-width: 0;
}
.an-inline-total { margin: 0 0 var(--space-base); font-size: var(--text-sm); color: var(--color-text-secondary); }
.an-inline-total strong { font-size: var(--text-lg); color: var(--color-text); }

.an-mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--space-sm); }
.an-mini-stat {
    display: flex; flex-direction: column; gap: 2px;
    padding: var(--space-sm) var(--space-md);
    background: var(--surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.an-mini-stat__v { font-size: var(--text-xl); font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.an-mini-stat__l { font-size: 11px; font-weight: 600; color: var(--color-text-muted); }

.an-mini-stats + .an-subcard__hint { margin-top: var(--space-base); }

/* Cap the leaderboard height so it can never dominate the bento; the header
   stays pinned while the body scrolls. */
.an-table-wrap { overflow: auto; max-height: 384px; }
/* The shared .data-table forces a 640px min-width for wide admin tables; the
   compact Top-players table only has five short columns, so let it fit its
   card instead of clipping behind a horizontal scrollbar. */
.an-table { min-width: 0; }
.an-table thead th, .an-table tbody td { padding: 10px 12px; }
.an-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-raised);
    z-index: 1;
}
.an-table .an-num { text-align: right; font-variant-numeric: tabular-nums; }
.an-table tbody td.muted { white-space: nowrap; }

/* Leaderboard rank medallion — restrained: muted chip for ranks 4+, and
   gold / silver / bronze tints for the top three (text-backed, not colour
   alone). */
.an-leaderboard .an-rank-col { width: 44px; text-align: center; }
.an-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-secondary);
    background: var(--surface-sunken);
}
.an-rank--1 { background: color-mix(in srgb, #F5C842 32%, #fff); color: #7a5c00; box-shadow: inset 0 0 0 1px color-mix(in srgb, #F5C842 60%, #fff); }
.an-rank--2 { background: color-mix(in srgb, #98A2B3 26%, #fff); color: #475467; box-shadow: inset 0 0 0 1px color-mix(in srgb, #98A2B3 50%, #fff); }
.an-rank--3 { background: color-mix(in srgb, #C17C3A 26%, #fff); color: #824a16; box-shadow: inset 0 0 0 1px color-mix(in srgb, #C17C3A 48%, #fff); }
.an-lb-name { font-weight: 600; color: var(--color-text); }

.an-streakers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-xs); }
.an-streakers__item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--hairline);
}
.an-streakers__item:last-child { border-bottom: 0; }
.an-streakers__name { font-size: var(--text-sm); color: var(--color-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Narrow ───────────────────────────────────────────────────────────────*/
/* The bento columns are wide, so collapse to a single column earlier. */
@media (max-width: 900px) {
    .an-players-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .an-trow {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    .an-trow__counts { justify-content: flex-start; }
    .an-trow__id { max-width: 100%; }
}
