/* ============================================================
   Portal Elecciones - Design System
   Theme: Light with #4AAAC3 primary
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
    --primary: #4AAAC3;
    --primary-dark: #3A8DA3;
    --primary-light: #7CC5D8;
    --primary-ultra-light: #E8F6FA;
    --primary-gradient: linear-gradient(135deg, #4AAAC3, #3A8DA3);

    --bg: #F0F4F8;
    --surface: #FFFFFF;
    --surface-hover: #F8FAFC;
    --text-primary: #1A2332;
    --text-secondary: #5A6B7F;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;

    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.2s ease;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
.header {
    background: var(--primary);
    color: #fff;
    padding: 0 2rem;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(74, 170, 195, 0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-logo img {
    height: 80px;
    filter: brightness(1);
}

.header-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
    flex: 1;
    text-transform: uppercase;
    padding: 0 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.btn-login {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: var(--font);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-login:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-1px);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: var(--font);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.3);
}

.header-user {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ---- Progress Bars (Mesas & Votantes) ---- */
.progress-section {
    background: #1E3A4F;
    padding: 0;
    display: flex;
    height: 40px;
}

.progress-bar-container {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: relative;
    overflow: hidden;
}

.progress-bar-container:first-child {
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.progress-bar-label {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar-label .icon {
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
}

.progress-bar-track {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--primary);
    opacity: 0.3;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar-value {
    margin-left: auto;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-pct {
    font-size: 1rem;
    color: #fff;
}

.progress-detail {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ---- Main Content ---- */
.main-content {
    padding: 1.5rem 2rem 0 2rem;
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Bulletin Selector & View Switch ---- */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.bulletin-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bulletin-selector label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.bulletin-selector select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%235A6B7F'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: border-color var(--transition);
}

.bulletin-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 170, 195, 0.15);
}

/* Switch Toggle */
.view-switch {
    display: flex;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.view-switch-btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.view-switch-btn.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.view-switch-btn:hover:not(.active) {
    background: var(--primary-ultra-light);
    color: var(--primary-dark);
}

/* ---- Candidates View Sub-Controls & Podium ---- */
.candidates-sub-controls {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 0.5rem 0;
    margin-top: -0.5rem;
}

.sub-view-switch {
    display: flex;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.sub-view-btn {
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.sub-view-btn.active {
    background: var(--primary);
    color: #fff;
}

.sub-view-btn:hover:not(.active) {
    background: var(--primary-ultra-light);
    color: var(--primary-dark);
}

/* Podium View */
.podium-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    height: clamp(350px, calc(100vh - 280px), 800px);
    padding: 0 1rem;
    flex-shrink: 0;
}

.podium-wrapper:empty {
    display: none;
}

.podium-column {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    width: 30%;
    max-width: 250px;
    position: relative;
    height: 100%;
}

/* Rank specific heights to create the podium shape */
.podium-column.rank-1 .podium-bar {
    height: 60%;
}

.podium-column.rank-2 .podium-bar {
    height: 40%;
}

.podium-column.rank-3 .podium-bar {
    height: 25%;
}

.podium-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0.75rem;
    text-align: center;
    width: 100%;
}

.podium-photo {
    width: clamp(86px, 12vh, 120px);
    height: clamp(86px, 12vh, 120px);
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid;
    margin-bottom: 0.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.podium-photo-placeholder {
    width: clamp(86px, 12vh, 120px);
    height: clamp(86px, 12vh, 120px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2rem, 3vh, 3rem);
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-md);
}

.podium-name {
    font-size: clamp(1rem, 1.5vh, 1.15rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.podium-pct {
    font-size: clamp(1.25rem, 2vh, 1.5rem);
    font-weight: 800;
}

.podium-bar {
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 0;
    box-shadow: var(--shadow);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 55px;
}

.podium-rank-number {
    font-size: clamp(2.5rem, 5vh, 4rem);
    font-weight: 800;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1;
}


@media (max-width: 600px) {
    .podium-wrapper {
        height: 250px;
        margin-bottom: 1rem;
        gap: 0.5rem;
    }

    .podium-photo,
    .podium-photo-placeholder {
        width: 60px;
        height: 60px;
        border-width: 2px;
        font-size: 1.5rem;
    }

    .podium-name {
        font-size: 0.8rem;
    }

    .podium-pct {
        font-size: 1rem;
    }

    .podium-rank-number {
        font-size: 1.75rem;
    }

    .podium-bar {
        min-height: 38px;
    }
}

/* ---- Candidate Cards View ---- */
.candidates-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.candidates-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
    padding-bottom: 1.5rem;
    width: 75%;
    margin: 0 auto;
}

.candidate-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.candidate-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.candidate-rank {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
    min-width: 2.5rem;
    text-align: center;
}

.candidate-photo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid;
    flex-shrink: 0;
}

.candidate-photo-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.candidate-info {
    flex: 1;
    min-width: 0;
}

.candidate-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.candidate-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.35rem;
}

.candidate-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.candidate-stats {
    text-align: right;
    flex-shrink: 0;
    min-width: 120px;
}

.candidate-pct {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.candidate-votes {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- YouTube Live Toggle ---- */
.candidate-card-wrapper {
    display: flex;
    flex-direction: column;
}

.candidate-yt-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #FF0000;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    margin-left: 0.75rem;
}

.candidate-yt-btn:hover {
    background: #CC0000;
    transform: scale(1.1);
}

.candidate-yt-btn.active {
    background: var(--text-secondary);
}

.candidate-yt-embed {
    background: #000;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
    width: 100%;
    height: clamp(350px, 65vh, 650px);
    display: flex;
    justify-content: center;
}

.candidate-yt-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ---- Department Map View ---- */
.department-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    flex: 1;
    overflow: hidden;
}

@media (min-width: 1025px) {
    .department-view {
        grid-template-columns: calc(50% - 0.75rem) calc(50% - 0.75rem);
    }
}

.map-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    min-height: 450px;
}

@media (min-width: 1025px) {
    .map-container {
        height: 100%;
        min-height: 100%;
    }
}

#colombia-map {
    width: 100%;
    height: 100%;
    min-height: 450px;
}

@media (min-width: 1025px) {
    #colombia-map {
        height: 100%;
        min-height: 100%;
    }
}

.map-legend {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-md);
    z-index: 10;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    border: 2px solid var(--border);
    max-width: 90%;
}

.map-legend:empty {
    display: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.exterior-badge {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-md);
    z-index: 10;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all var(--transition);
    max-width: 220px;
}

.exterior-badge:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.exterior-badge.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 170, 195, 0.2);
}

.exterior-badge-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.exterior-badge-leader {
    font-size: 0.85rem;
    font-weight: 600;
}

.exterior-badge-votes {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.department-detail {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 350px;
}

@media (min-width: 1025px) {
    .department-detail {
        height: 100%;
        max-height: 100%;
    }
}

.department-detail-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-ultra-light);
}

.department-detail-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.department-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.department-placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.department-placeholder-text {
    font-size: 1rem;
    font-weight: 500;
}

/* Small candidate list for department view */
.dept-candidate-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.dept-candidate-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    transition: background var(--transition);
}

.dept-candidate-item:hover {
    background: var(--primary-ultra-light);
}

.dept-candidate-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.dept-candidate-photo-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid;
    flex-shrink: 0;
}

.dept-candidate-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.dept-candidate-stats {
    text-align: right;
}

.dept-candidate-pct {
    font-size: 0.95rem;
    font-weight: 700;
}

.dept-candidate-votes {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ---- Summary Bar (Bottom) ---- */
.summary-section {
    background: var(--surface);
    border-top: 2px solid var(--border-light);
    padding: 0.5rem 2rem;
    margin-top: auto;
    width: 100%;
}

.summary-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.summary-item {
    text-align: center;
    padding: 0.25rem;
}

.summary-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.1rem;
}

.summary-pct {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.summary-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---- Footer ---- */
.footer {
    background: var(--primary);
    text-align: center;
    padding: 0.6rem 2rem;
    font-size: 0.8rem;
    width: 100%;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition);
}

.footer a:hover {
    color: #fff;
}

/* ---- Admin Panel Styles ---- */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

.admin-sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.admin-nav-item:hover {
    background: var(--primary-ultra-light);
    color: var(--primary-dark);
}

.admin-nav-item.active {
    background: var(--primary-ultra-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.admin-nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.admin-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Admin Cards Dashboard */
.admin-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.admin-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.admin-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    border-color: var(--primary-light);
}

.admin-card-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.admin-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.admin-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Forms */
.form-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 800px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    transition: border-color var(--transition);
    background: var(--bg);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 170, 195, 0.15);
}

.form-group input[type="color"] {
    height: 42px;
    padding: 4px;
    cursor: pointer;
}

.form-group input[type="file"] {
    padding: 0.5rem;
}

.btn {
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th {
    background: var(--bg);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--surface-hover);
}

.data-table .color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-block;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.data-table .candidate-thumb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* Alerts / Messages */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-info {
    background: var(--primary-ultra-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary-light);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 1rem;
    font-weight: 500;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Maplibre Tooltip Override */
.maplibregl-popup-content {
    background: var(--surface) !important;
    border-radius: var(--radius) !important;
    padding: 0.75rem 1rem !important;
    box-shadow: var(--shadow-md) !important;
    font-family: var(--font) !important;
    font-size: 0.85rem !important;
    color: var(--text-primary) !important;
    max-width: 250px !important;
}

.maplibregl-popup-tip {
    border-top-color: var(--surface) !important;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .department-view {
        grid-template-columns: 1fr;
    }

    .map-container {
        min-height: 400px;
    }

    .header-title {
        font-size: 0.8rem;
    }

    .admin-sidebar {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 1rem;
    }

    .header-title {
        font-size: 0.7rem;
        display: none;
    }

    .main-content {
        padding: 1rem;
    }

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

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .view-switch {
        justify-content: center;
    }

    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 0;
        display: flex;
        overflow-x: auto;
    }

    .admin-nav-item {
        padding: 0.5rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }

    .admin-nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary);
    }
}

@media (max-width: 480px) {
    .progress-section {
        flex-direction: column;
        height: auto;
    }

    .progress-bar-container {
        padding: 0.5rem 1rem;
    }

    .progress-bar-container:first-child {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    .candidate-card {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .candidate-photo,
    .candidate-photo-placeholder {
        width: 40px;
        height: 40px;
    }

    .candidate-rank {
        font-size: 1.1rem;
        min-width: 1.5rem;
    }

    .candidate-pct {
        font-size: 1.2rem;
    }

    .summary-pct {
        font-size: 1.3rem;
    }
}

@media (min-width: 1025px) {
    body.dashboard-mode {
        height: 100vh;
        overflow: hidden;
    }

    body.dashboard-mode .main-content {
        max-width: 100% !important;
        padding: 1rem 3rem !important;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }

    body.dashboard-mode .controls-bar {
        margin-bottom: 1rem;
    }

    body.dashboard-mode .department-view {
        flex: 1;
        height: 0;
        grid-template-columns: calc(50% - 0.75rem) calc(50% - 0.75rem) !important;
        gap: 1.5rem;
        min-height: 0 !important;
    }

    body.dashboard-mode .map-container {
        height: 100% !important;
        min-height: 0 !important;
    }

    body.dashboard-mode #colombia-map {
        height: 100% !important;
        min-height: 0 !important;
    }

    body.dashboard-mode .department-detail {
        height: 100% !important;
        max-height: 100% !important;
        overflow-y: auto !important;
    }
}