/* ==========================================================================
   NPG Election Results — Broadcast Dark Theme + Light Theme
   ========================================================================== */

/* --- Dark Theme Variables (default) --- */
:root {
    --npg-bg-dark: #1a1a2e;
    --npg-bg-card: #16213e;
    --npg-bg-row: #0f3460;
    --npg-text: #eaeaea;
    --npg-text-muted: #8a8fa3;
    --npg-accent: #e94560;
    --npg-dem: #2b7de9;
    --npg-rep: #e53935;
    --npg-other: #8e8e8e;
    --npg-winner-glow: #ffd700;
    --npg-border: rgba(255, 255, 255, 0.08);
    --npg-bar-track: rgba(255, 255, 255, 0.06);
    --npg-input-bg: rgba(255, 255, 255, 0.08);
    --npg-input-border: rgba(255, 255, 255, 0.15);
    --npg-input-text: #eaeaea;
    --npg-pill-bg: rgba(255, 255, 255, 0.08);
    --npg-pill-text: #8a8fa3;
    --npg-pill-active-bg: var(--npg-accent);
    --npg-pill-active-text: #fff;
}

/* --- Light Theme Variables --- */
[data-theme="light"] {
    --npg-bg-dark: #f5f5f7;
    --npg-bg-card: #ffffff;
    --npg-bg-row: #f0f0f2;
    --npg-text: #1a1a2e;
    --npg-text-muted: #6b7280;
    --npg-accent: #dc2626;
    --npg-dem: #2563eb;
    --npg-rep: #dc2626;
    --npg-other: #6b7280;
    --npg-winner-glow: #b8860b;
    --npg-border: rgba(0, 0, 0, 0.1);
    --npg-bar-track: rgba(0, 0, 0, 0.06);
    --npg-input-bg: #ffffff;
    --npg-input-border: rgba(0, 0, 0, 0.2);
    --npg-input-text: #1a1a2e;
    --npg-pill-bg: #e5e7eb;
    --npg-pill-text: #4b5563;
    --npg-pill-active-bg: #1a1a2e;
    --npg-pill-active-text: #fff;
}

/* --- Shared Base --- */
.npg-election-full,
.npg-featured,
.npg-ticker-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--npg-text);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

.npg-no-data {
    background: var(--npg-bg-dark);
    color: var(--npg-text-muted);
    padding: 40px;
    text-align: center;
    border-radius: 8px;
    font-size: 16px;
}

.npg-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.npg-updated {
    font-size: 12px;
    color: var(--npg-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.npg-header-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
}

/* Winner checkmark */
.npg-winner-check {
    color: var(--npg-winner-glow);
    font-weight: 700;
    margin-right: 4px;
}

/* --- Party color bars --- */
.npg-bar-dem { background: var(--npg-dem); }
.npg-bar-rep { background: var(--npg-rep); }
.npg-bar-other { background: var(--npg-other); }

/* ==========================================================================
   REFRESH COUNTDOWN BAR
   ========================================================================== */

.npg-refresh-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--npg-bar-track);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    z-index: 10;
}

.npg-refresh-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--npg-accent);
    transition: width 1s linear;
}

.npg-countdown-text {
    font-size: 11px;
    color: var(--npg-text-muted);
    font-variant-numeric: tabular-nums;
}

.npg-countdown-text.npg-flash-updated {
    color: #22c55e;
    font-weight: 700;
}

/* Ticker countdown */
.npg-ticker-countdown {
    font-size: 9px;
    margin-left: 6px;
    opacity: 0.7;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   FRONTEND SEARCH & FILTER (Full Results)
   ========================================================================== */

.npg-front-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.npg-front-search {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--npg-input-border);
    border-radius: 6px;
    background: var(--npg-input-bg);
    color: var(--npg-input-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.npg-front-search:focus {
    border-color: var(--npg-accent);
}

.npg-front-search::placeholder {
    color: var(--npg-text-muted);
}

.npg-front-pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.npg-front-pill {
    padding: 5px 12px;
    font-size: 12px;
    border: none;
    border-radius: 14px;
    background: var(--npg-pill-bg);
    color: var(--npg-pill-text);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.npg-front-pill:hover {
    opacity: 0.8;
}

.npg-front-pill.npg-front-pill-active {
    background: var(--npg-pill-active-bg);
    color: var(--npg-pill-active-text);
}

/* ==========================================================================
   FULL RESULTS
   ========================================================================== */

.npg-election-full {
    background: var(--npg-bg-dark);
    border-radius: 8px;
    padding: 24px;
    max-width: 900px;
}

.npg-election-full .npg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--npg-accent);
    margin-bottom: 20px;
}

.npg-race {
    background: var(--npg-bg-card);
    border-radius: 6px;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--npg-border);
}

.npg-race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--npg-border);
}

[data-theme="light"] .npg-race-header {
    background: rgba(0, 0, 0, 0.02);
}

.npg-race-name {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.npg-precincts {
    font-size: 12px;
    color: var(--npg-text-muted);
    white-space: nowrap;
}

/* Candidates table */
.npg-candidates-table {
    width: 100%;
    border-collapse: collapse;
}

.npg-candidates-table thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--npg-text-muted);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--npg-border);
    font-weight: 600;
}

.npg-candidate-row td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--npg-border);
    font-size: 14px;
}

.npg-candidate-row:last-child td {
    border-bottom: none;
}

.npg-candidate-row.npg-winner {
    background: rgba(255, 215, 0, 0.06);
}

[data-theme="light"] .npg-candidate-row.npg-winner {
    background: rgba(184, 134, 11, 0.08);
}

.npg-candidate-row.npg-winner td:first-child {
    border-left: 3px solid var(--npg-winner-glow);
}

.npg-col-name { font-weight: 600; white-space: nowrap; }
.npg-col-party { text-align: center; width: 50px; color: var(--npg-text-muted); }
.npg-col-votes { text-align: right; width: 110px; font-variant-numeric: tabular-nums; }
.npg-col-pct { text-align: right; width: 60px; font-weight: 700; font-variant-numeric: tabular-nums; }
.npg-col-bar { width: 120px; padding-right: 16px; }

.npg-incumbent {
    font-size: 11px;
    color: var(--npg-text-muted);
    margin-left: 4px;
    font-weight: 400;
}

/* Vote percentage bar */
.npg-bar-bg {
    height: 8px;
    background: var(--npg-bar-track);
    border-radius: 4px;
    overflow: hidden;
}

.npg-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* ==========================================================================
   FEATURED RACES CAROUSEL (Multi-slide)
   ========================================================================== */

.npg-featured {
    background: var(--npg-bg-dark);
    border-radius: 8px;
    padding: 20px;
}

.npg-featured-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--npg-accent);
    margin-bottom: 16px;
}

.npg-featured-carousel {
    position: relative;
    overflow: hidden;
}

.npg-featured-track {
    display: flex;
    transition: transform 0.4s ease;
}

.npg-featured-slide {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    padding: 0 6px;
    box-sizing: border-box;
}

.npg-slide-inner {
    background: var(--npg-bg-card);
    border-radius: 6px;
    padding: 14px;
    border: 1px solid var(--npg-border);
    height: 100%;
    box-sizing: border-box;
}

.npg-slide-race-name {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.npg-slide-precincts {
    font-size: 11px;
    color: var(--npg-text-muted);
    margin-bottom: 10px;
}

.npg-slide-candidates {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.npg-slide-candidate {
    background: var(--npg-bg-row);
    border-radius: 5px;
    padding: 10px;
    border: 1px solid var(--npg-border);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.npg-slide-candidate.npg-slide-winner {
    border-color: var(--npg-winner-glow);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.12);
}

[data-theme="light"] .npg-slide-candidate.npg-slide-winner {
    box-shadow: 0 0 8px rgba(184, 134, 11, 0.15);
}

.npg-slide-cand-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.npg-slide-cand-name {
    font-size: 14px;
    font-weight: 700;
}

.npg-slide-party {
    font-weight: 400;
    color: var(--npg-text-muted);
    margin-left: 4px;
    font-size: 12px;
}

.npg-slide-cand-pct {
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.npg-party-dem .npg-slide-cand-pct { color: var(--npg-dem); }
.npg-party-rep .npg-slide-cand-pct { color: var(--npg-rep); }

.npg-slide-bar-bg {
    height: 5px;
    background: var(--npg-bar-track);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.npg-slide-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.npg-slide-cand-votes {
    font-size: 11px;
    color: var(--npg-text-muted);
    font-variant-numeric: tabular-nums;
}

.npg-slide-called {
    margin-top: 10px;
    padding: 5px 10px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--npg-winner-glow);
    border-radius: 4px;
    color: var(--npg-winner-glow);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

[data-theme="light"] .npg-slide-called {
    background: rgba(184, 134, 11, 0.08);
}

/* Dots navigation */
.npg-featured-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
}

.npg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 0;
    transition: background 0.3s, transform 0.2s;
}

[data-theme="light"] .npg-dot {
    background: rgba(0, 0, 0, 0.15);
}

.npg-dot:hover {
    background: rgba(255, 255, 255, 0.4);
}

[data-theme="light"] .npg-dot:hover {
    background: rgba(0, 0, 0, 0.3);
}

.npg-dot.npg-dot-active {
    background: var(--npg-accent);
    transform: scale(1.3);
}

/* ==========================================================================
   TICKER
   ========================================================================== */

.npg-ticker-wrap {
    background: var(--npg-bg-dark);
    display: flex;
    align-items: center;
    height: 44px;
    overflow: hidden;
    border-radius: 4px;
    border: 1px solid var(--npg-border);
    font-size: 14px;
}

.npg-ticker-label {
    background: var(--npg-accent);
    color: #fff;
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
    z-index: 1;
    gap: 4px;
}

.npg-ticker-overflow {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.npg-ticker-track {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: npgTickerScroll linear infinite;
    will-change: transform;
}

@keyframes npgTickerScroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.npg-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
}

.npg-ticker-race {
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
}

[data-theme="light"] .npg-ticker-race {
    color: var(--npg-text);
}

.npg-ticker-cand {
    font-weight: 600;
}

.npg-ticker-dem { color: var(--npg-dem); }
.npg-ticker-rep { color: var(--npg-rep); }

.npg-ticker-winner {
    color: var(--npg-winner-glow) !important;
    font-weight: 700;
}

.npg-ticker-vs {
    color: var(--npg-text-muted);
    font-size: 11px;
    font-style: italic;
}

.npg-ticker-pct {
    color: var(--npg-text-muted);
    font-size: 11px;
}

.npg-ticker-sep {
    color: var(--npg-accent);
    margin: 0 8px;
}

/* ==========================================================================
   FULL RESULTS LINKS (Ticker & Featured)
   ========================================================================== */

.npg-ticker-full-link {
    text-align: right;
    margin-top: 4px;
}

.npg-ticker-full-link a {
    font-size: 11px;
    color: var(--npg-text-muted);
    text-decoration: none;
    letter-spacing: 0.3px;
    transition: color 0.2s;
}

.npg-ticker-full-link a:hover {
    color: var(--npg-accent);
}

.npg-featured-full-link {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--npg-border);
}

.npg-featured-full-link a {
    font-size: 13px;
    color: var(--npg-text-muted);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: color 0.2s;
}

.npg-featured-full-link a:hover {
    color: var(--npg-accent);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .npg-election-full {
        padding: 16px;
    }

    .npg-race-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .npg-col-bar {
        display: none;
    }

    .npg-col-votes {
        width: 80px;
    }

    .npg-candidates-table thead {
        display: none;
    }

    .npg-candidate-row td {
        padding: 8px;
    }

    .npg-featured {
        padding: 14px;
    }

    .npg-featured-slide {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    .npg-ticker-label {
        font-size: 10px;
        padding: 0 10px;
    }

    .npg-front-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .npg-front-search {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .npg-election-full .npg-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .npg-header-meta {
        align-items: flex-start;
    }

    .npg-featured-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .npg-featured-slide {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .npg-col-party {
        display: none;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */

@media print {
    .npg-refresh-bar,
    .npg-countdown-text,
    .npg-front-filters,
    .npg-featured-dots,
    .npg-ticker-countdown {
        display: none !important;
    }

    .npg-election-full,
    .npg-featured,
    .npg-ticker-wrap {
        background: #fff !important;
        color: #000 !important;
    }

    .npg-race {
        break-inside: avoid;
        background: #fff !important;
        border: 1px solid #ccc !important;
    }
}
