/* =========================================
   Analyse Élections 2021 — AFG vs PSU
   Premium Dark Theme
   ========================================= */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #222845;
    --bg-glass: rgba(26, 31, 53, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(255, 255, 255, 0.1);

    --text-primary: #f0f2f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --afg-primary: #facc15;
    --afg-light: #fde047;
    --afg-dark: #ca8a04;
    --afg-bg: rgba(250, 204, 21, 0.12);
    --afg-gradient: linear-gradient(135deg, #facc15, #eab308);

    --psu-primary: #06b6d4;
    --psu-light: #22d3ee;
    --psu-dark: #0891b2;
    --psu-bg: rgba(6, 182, 212, 0.12);
    --psu-gradient: linear-gradient(135deg, #06b6d4, #0284c7);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #8b5cf6;
    --neutral: #6b7280;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-afg: 0 0 20px rgba(249, 115, 22, 0.2);
    --shadow-glow-psu: 0 0 20px rgba(6, 182, 212, 0.2);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== NAVBAR ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.15rem;
}

.logo-icon {
    font-size: 1.4rem;
}

.logo-text .highlight {
    background: linear-gradient(135deg, var(--afg-primary), var(--psu-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 4px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.nav-icon {
    font-size: 1rem;
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn span {
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 32px 0 64px;
    min-height: calc(100vh - 64px - 120px);
}

/* ===== PAGE HEADERS ===== */
.page-header {
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.page-header .subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.gradient-text {
    background: linear-gradient(135deg, var(--afg-primary), var(--psu-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== STAT CARDS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--text-muted), transparent);
    opacity: 0.3;
}

.stat-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card.afg-card::before {
    background: var(--afg-gradient);
    opacity: 1;
}

.stat-card.psu-card::before {
    background: var(--psu-gradient);
    opacity: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.stat-card .stat-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card.afg-card .stat-value {
    color: var(--afg-primary);
}

.stat-card.psu-card .stat-value {
    color: var(--psu-primary);
}

/* ===== CHART SECTIONS ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.chart-card:hover {
    border-color: var(--border-accent);
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-card .chart-icon {
    font-size: 1.2rem;
}

.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas {
    max-height: 400px;
}

.chart-card-full {
    grid-column: 1 / -1;
}

/* ===== FILTER TABS ===== */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 8px 18px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.filter-tab.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.filter-tab .count {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== DATA TABLE ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 32px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

table thead {
    background: rgba(255, 255, 255, 0.02);
}

table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

table tbody tr:last-child td {
    border-bottom: none;
}

.circ-name {
    font-weight: 600;
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.votes-afg {
    color: var(--afg-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.votes-psu {
    color: var(--psu-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.votes-cell {
    font-variant-numeric: tabular-nums;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-afg {
    background: var(--afg-bg);
    color: var(--afg-light);
    border: 1px solid rgba(249, 115, 22, 0.2);
}

.badge-psu {
    background: var(--psu-bg);
    color: var(--psu-light);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-equal {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* ===== TOOLTIPS ===== */
.tooltip-wrap {
    cursor: help;
    display: inline-flex;
    margin-left: 4px;
    font-size: 0.9em;
    opacity: 0.7;
    transition: var(--transition);
    position: relative;
}

.tooltip-wrap:hover {
    opacity: 1;
}

.tooltip-wrap::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    right: 0;
    transform: translateY(-8px);
    background: var(--bg-card-hover);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 400;
    width: 250px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-accent);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 100;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

.tooltip-wrap:hover::before {
    opacity: 1;
    transform: translateY(-4px);
}

.badge-sieges {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ===== POSITION INDICATOR ===== */
.position {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
}

.position-1 {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #1a1a1a;
}

.position-2 {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: #fff;
}

.position-3 {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: #fff;
}

.position-other {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.position-absent {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== COMPARISON BAR ===== */
.comparison-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    min-width: 100px;
}

.comparison-bar .afg-bar {
    background: var(--afg-gradient);
    transition: width 0.6s ease;
}

.comparison-bar .psu-bar {
    background: var(--psu-gradient);
    transition: width 0.6s ease;
}

/* ===== DETAIL CARDS ===== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.detail-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-1px);
}

/* ===== HERO SECTION ===== */
.hero {
    text-align: center;
    padding: 40px 0 20px;
    margin-bottom: 32px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 16px;
}

.hero .subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 24px;
}

.hero-badges {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    font-weight: 600;
}

.hero-badge.afg {
    background: var(--afg-bg);
    color: var(--afg-light);
    border: 1px solid rgba(249, 115, 22, 0.25);
}

.hero-badge.psu {
    background: var(--psu-bg);
    color: var(--psu-light);
    border: 1px solid rgba(6, 182, 212, 0.25);
}

/* ===== LINK CARDS ===== */
.link-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.link-card {
    display: block;
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.link-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.link-card .card-emoji {
    font-size: 2.4rem;
    margin-bottom: 16px;
    display: block;
}

.link-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.link-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.link-card .card-arrow {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--transition);
}

.link-card:hover .card-arrow {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateX(4px);
}

/* ===== LEGEND ===== */
.legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.afg {
    background: var(--afg-primary);
}

.legend-dot.psu {
    background: var(--psu-primary);
}

/* ===== LAST ELECTED ROW HIGHLIGHT ===== */
.last-elected-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.last-elected-divider {
    width: 2px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
}

/* ===== SECTION TITLE ===== */
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 32px 0;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
}

.footer-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.6;
}

.footer-text a {
    color: var(--psu-primary);
    text-decoration: none;
}

.footer-text a:hover {
    text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
        flex-direction: column;
    }

    .nav-links.open {
        display: flex;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-text {
        text-align: center;
    }

    table {
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .filter-tabs {
        gap: 6px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-in:nth-child(1) {
    animation-delay: 0.05s;
}

.animate-in:nth-child(2) {
    animation-delay: 0.1s;
}

.animate-in:nth-child(3) {
    animation-delay: 0.15s;
}

.animate-in:nth-child(4) {
    animation-delay: 0.2s;
}

.animate-in:nth-child(5) {
    animation-delay: 0.25s;
}

.animate-in:nth-child(6) {
    animation-delay: 0.3s;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== TOOLTIP ===== */
.tooltip-wrap {
    position: relative;
    cursor: help;
}

.tooltip-wrap:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    z-index: 10;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}
/* Nav Divider */
.nav-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 10px;
}
@media (max-width: 768px) {
    .nav-divider {
        display: none;
    }
}
