/* ═══════════════════════════════════════════════════════════════
   DevFix — Histórico de análises (v2 · lista curta, pódio visual)
═══════════════════════════════════════════════════════════════ */

.history-page {
    position: relative;
    min-height: 72vh;
    display: flex;
    justify-content: center;
    padding: 48px 24px 88px;
    overflow: hidden;
}

.history-page--v2 {
    background:
        radial-gradient(ellipse 90% 50% at 50% -15%, rgba(168, 216, 200, 0.12), transparent 55%),
        var(--bg-surface);
}

.history-hero-bg {
    pointer-events: none;
    position: absolute;
    inset: 0;
    opacity: 0.45;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 85% 60% at 50% 0%, black 0%, transparent 72%);
}

[data-theme="light"] .history-hero-bg {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    opacity: 0.35;
}

.history-container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    width: 100%;
    box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────────────── */
.history-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.history-header-copy {
    min-width: 0;
}

.history-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.history-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-pill, 999px);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--bg-raised);
}

.history-badge--pulse {
    color: var(--accent);
    border-color: rgba(168, 216, 200, 0.35);
    background: var(--accent-soft);
}

.history-badge--pulse::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success, #34d399);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
    animation: histPulse 2s ease-out infinite;
}

@keyframes histPulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
    70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.history-header h1 {
    font-family: var(--font-display, inherit);
    font-size: clamp(1.65rem, 3.2vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.history-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.98rem;
    line-height: 1.55;
    max-width: 40rem;
}

.btn-clear {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--r-md, 10px);
    border: 1px solid var(--border);
    background: var(--bg-raised);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s var(--ease, ease), color 0.2s, background 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.btn-clear-icon {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.85;
}

.btn-clear:hover {
    border-color: rgba(248, 113, 113, 0.45);
    color: var(--error, #f87171);
    background: var(--error-soft, rgba(248, 113, 113, 0.1));
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.2);
}

/* ── Lista (coluna única, legível) ─────────────────────────── */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.hist-card {
    position: relative;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px 18px;
    padding: 16px 18px 16px 16px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--r-lg, 16px);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s var(--ease, ease), border-color 0.2s, box-shadow 0.25s;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.25));
}

.hist-card:hover {
    border-color: rgba(168, 216, 200, 0.35);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.35));
}

.hist-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    background: var(--bg-raised);
    border: 1px solid var(--border);
}

.hist-card--gold {
    border-color: rgba(212, 160, 23, 0.42);
    background: linear-gradient(105deg, rgba(212, 160, 23, 0.09), var(--bg-body));
    box-shadow: 0 0 0 1px rgba(255, 247, 214, 0.04), var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.35));
}

.hist-card--gold .hist-rank {
    color: #713f12;
    background: linear-gradient(145deg, #fff7d6, #f0c23d);
    border-color: #d4a017;
}

.hist-card--silver {
    border-color: rgba(148, 163, 184, 0.4);
    background: linear-gradient(105deg, rgba(148, 163, 184, 0.1), var(--bg-body));
}

.hist-card--silver .hist-rank {
    color: #1e293b;
    background: linear-gradient(145deg, #f8fafc, #cbd5e1);
    border-color: #94a3b8;
}

.hist-card--bronze {
    border-color: rgba(194, 65, 12, 0.38);
    background: linear-gradient(105deg, rgba(234, 88, 12, 0.09), var(--bg-body));
}

.hist-card--bronze .hist-rank {
    color: #431407;
    background: linear-gradient(145deg, #ffedd5, #ea580c);
    border-color: #c2410c;
}

.hist-card-main {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.hist-domain {
    font-weight: 800;
    font-size: 1.02rem;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-time {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.hist-card-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    text-align: right;
}

.hist-score {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.hist-score.score-good {
    color: var(--accent);
}

.hist-score.score-avg {
    color: #eab308;
}

.hist-score.score-poor {
    color: var(--error, #f87171);
}

.hist-score-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
}

.hist-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.hist-diff {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--r-sm, 6px);
}

.hist-diff.diff-up {
    color: hsl(145 60% 42%);
    background: hsl(145 60% 40% / 0.14);
}

.hist-diff.diff-down {
    color: hsl(0 70% 58%);
    background: hsl(0 70% 55% / 0.12);
}

/* ── Empty ─────────────────────────────────────────────────── */
.history-empty {
    text-align: center;
    padding: 72px 20px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.35;
}

.history-empty h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.history-empty p {
    color: var(--text-secondary);
    margin-bottom: 26px;
    line-height: 1.55;
}

.btn-inspect {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 26px;
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 800;
    font-size: 0.95rem;
    border-radius: var(--r-md, 12px);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.25s;
    box-shadow: 0 6px 24px rgba(168, 216, 200, 0.22);
}

.btn-inspect:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(168, 216, 200, 0.28);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 720px) {
    .history-page {
        padding: 32px 16px 64px;
    }

    .history-header {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-clear {
        justify-content: center;
    }

    .hist-card {
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-rows: auto auto;
    }

    .hist-rank {
        width: 40px;
        height: 40px;
        grid-row: 1 / -1;
    }

    .hist-card-stats {
        grid-column: 2 / -1;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        gap: 10px;
    }

    .hist-meta {
        align-items: flex-start;
    }
}
