/* ═══════════════════════════════════════════════════════════════════════════
   Stats Page Styles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
    --stats-win-color: #22c55e;
    --stats-win-bg: rgba(34, 197, 94, 0.1);
    --stats-loss-color: #ef4444;
    --stats-loss-bg: rgba(239, 68, 68, 0.1);
    --stats-draw-color: #94a3b8;
    --stats-draw-bg: rgba(148, 163, 184, 0.1);

    --stats-card-bg: #ffffff;
    --stats-card-border: #e2e8f0;
    --stats-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --stats-card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --stats-card-radius: 12px;

    --stats-section-gap: 2rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STATS CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: var(--stats-section-gap);
    padding: 1.5rem 0;
}

.stats-container h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.stats-container h2::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, var(--stats-card-border) 0%, transparent 100%);
    margin-left: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WIN/LOSS/DRAW DONUT CHARTS
   ═══════════════════════════════════════════════════════════════════════════ */
.stats-section {
    background: var(--stats-card-bg);
    border-radius: var(--stats-card-radius);
    padding: 1.5rem;
    border: 1px solid var(--stats-card-border);
    box-shadow: var(--stats-card-shadow);
}

.donut-charts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: flex-start;
}

.donut-chart-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-width: 160px;
}

.donut-chart-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.donut-svg {
    width: 140px;
    height: 168px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}

.donut-svg circle {
    transition: stroke-dasharray 0.4s ease, stroke-dashoffset 0.4s ease;
}

.donut-bg-circle {
    stroke: #e2e8f0;
}

.donut-win-circle {
    stroke: var(--stats-win-color);
}

.donut-loss-circle {
    stroke: var(--stats-loss-color);
}

.donut-draw-circle {
    stroke: var(--stats-draw-color);
}

.donut-center-total {
    font-size: 16px;
    font-weight: 700;
    fill: var(--text-primary);
}

.donut-center-label {
    font-size: 10px;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.donut-time-control {
    font-size: 13px;
    font-weight: 600;
    fill: var(--text-secondary);
    text-transform: capitalize;
}

/* Donut Legend */
.donut-legend {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.donut-legend-win {
    color: var(--stats-win-color);
}

.donut-legend-loss {
    color: var(--stats-loss-color);
}

.donut-legend-draw {
    color: var(--stats-draw-color);
}

.donut-legend span span {
    font-weight: 500;
    opacity: 0.8;
}

/* Chart Legend */
.stats-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--stats-card-border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stats-legend-dot.win {
    background: var(--stats-win-color);
}

.stats-legend-dot.loss {
    background: var(--stats-loss-color);
}

.stats-legend-dot.draw {
    background: var(--stats-draw-color);
}

/* ═══════════════════════════════════════════════════════════════════════════
   STATS BY YEAR TABLE
   ═══════════════════════════════════════════════════════════════════════════ */
.stats-table-wrapper {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

.stats-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.stats-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.stats-table thead th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 0.875rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--stats-card-border);
    white-space: nowrap;
}

.stats-table thead th:first-child {
    border-top-left-radius: 8px;
}

.stats-table thead th:last-child {
    border-top-right-radius: 8px;
}

.stats-table tbody tr {
    transition: background-color 0.15s ease;
}

.stats-table tbody tr:hover {
    background-color: #f8fafc;
}

.stats-table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.stats-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* Year Column */
.stats-year {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Record Display */
.stats-record {
    display: inline-flex;
    gap: 0.25rem;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.stats-record-win {
    color: var(--stats-win-color);
    font-weight: 600;
}

.stats-record-loss {
    color: var(--stats-loss-color);
    font-weight: 600;
}

.stats-record-draw {
    color: var(--text-muted);
    font-weight: 600;
}

.stats-record-separator {
    color: var(--text-light);
}

/* Moves Column */
.stats-moves {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   STREAKS SECTION
   ═══════════════════════════════════════════════════════════════════════════ */
.streaks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.streak-card {
    display: flex;
    align-items: stretch;
    background: var(--stats-card-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--stats-card-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.streak-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.streak-icon-area {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    font-size: 1.5rem;
}

.streak-card.winning .streak-icon-area {
    background: linear-gradient(135deg, var(--stats-win-bg) 0%, rgba(34, 197, 94, 0.05) 100%);
    color: var(--stats-win-color);
}

.streak-card.losing .streak-icon-area {
    background: linear-gradient(135deg, var(--stats-loss-bg) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: var(--stats-loss-color);
}

.streak-content-area {
    flex: 1;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.streak-type {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.streak-values {
    display: flex;
    gap: 2rem;
}

.streak-stat {
    display: flex;
    flex-direction: column;
}

.streak-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.125rem;
}

.streak-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.streak-card.winning .streak-value {
    color: var(--stats-win-color);
}

.streak-card.losing .streak-value {
    color: var(--stats-loss-color);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIMESTAMP & FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */
.stats-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--stats-card-border);
}

.stats-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stats-back-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.stats-back-link:hover {
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .stats-container {
        gap: 1.5rem;
        padding: 1rem 0;
    }

    .stats-section {
        padding: 1.25rem;
        border-radius: 10px;
    }

    .donut-charts-grid {
        gap: 1rem;
        justify-content: center;
    }

    .donut-chart-card {
        padding: 1rem;
        min-width: 140px;
    }

    .donut-svg {
        width: 120px;
        height: 148px;
    }

    .donut-center-total {
        font-size: 14px;
    }

    .donut-legend {
        gap: 0.5rem;
        font-size: 0.75rem;
    }

    .stats-legend {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .stats-table {
        font-size: 0.85rem;
    }

    .stats-table thead th,
    .stats-table tbody td {
        padding: 0.75rem 0.625rem;
    }

    .streaks-grid {
        grid-template-columns: 1fr;
    }

    .streak-values {
        gap: 1.5rem;
    }

    .streak-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .stats-container h2 {
        font-size: 1.1rem;
    }

    .stats-container h2::after {
        display: none;
    }

    .donut-charts-grid {
        flex-direction: column;
        align-items: stretch;
    }

    .donut-chart-card {
        flex-direction: row;
        gap: 1rem;
        padding: 1rem;
        min-width: unset;
    }

    .donut-svg {
        width: 100px;
        height: 128px;
    }

    .donut-center-total {
        font-size: 12px;
    }

    .donut-center-label {
        font-size: 8px;
    }

    .donut-time-control {
        font-size: 11px;
    }

    .donut-legend {
        flex-direction: column;
        gap: 0.25rem;
        margin-top: 0;
        font-size: 0.8rem;
    }

    .streak-icon-area {
        width: 50px;
        font-size: 1.25rem;
    }

    .streak-content-area {
        padding: 0.875rem 1rem;
    }

    .stats-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-section {
    animation: fadeInUp 0.3s ease forwards;
}

.stats-section:nth-child(1) { animation-delay: 0s; }
.stats-section:nth-child(2) { animation-delay: 0.1s; }
.stats-section:nth-child(3) { animation-delay: 0.2s; }
