/* ========================================
   Resultados Electorales 2025 - Stylesheet
   ======================================== */

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

/* CSS Variables - Light Mode */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --background: #fafafa;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --header-bg: #28364c;
}

/* CSS Variables - Dark Mode */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --primary-light: #2563eb;
    --background: #0f1419;
    --card-bg: #1a1f2e;
    --border: #2d3748;
    --text-primary: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --header-bg: #000000;
}

body {
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding-bottom: 90px;
}

.app-container {
    min-height: 100vh;
    padding: 2rem 0;
}

/* ========================================
   Header
   ======================================== */
.app-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.app-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-logo {
    width: 190px;
    height: auto;
}

.app-subtitle {
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    line-height: 1.4;
}

/* Theme Switcher */
.theme-switcher {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    padding: 0;
}

.theme-switcher:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.theme-icon {
    width: 20px;
    height: 20px;
    color: #ffffff;
    transition: all 0.3s ease;
    position: absolute;
}

.theme-icon.sun {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-icon.moon {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .theme-icon.sun {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .theme-icon.moon {
    opacity: 1;
    transform: rotate(0deg);
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Map and Timeline Row - No gap */
.row.mb-4 {
    gap: 0;
    margin-left: 0;
    margin-right: 0;
}

.row.mb-4 > [class*="col-"] {
    padding-left: 0;
    padding-right: 0;
}

/* Map card specific - reduced padding */
.map-card {
    padding: 1rem !important;
}

.map-card .card-title {
    margin-bottom: 0.75rem;
}

.map-card .map-container {
    margin: 0 -0.5rem -0.5rem -0.5rem;
}

/* Statistics Cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 1.25rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
    border: none;
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--background);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ========================================
   Corporation Selector - Fixed Bottom
   ======================================== */
.corporation-selector-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 1rem 0;
    background: rgba(255, 255, 255, 0.29);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(7.7px);
    -webkit-backdrop-filter: blur(7.7px);
    border-top: 1px solid rgba(255, 255, 255, 0.31);
}

[data-theme="dark"] .corporation-selector-fixed {
    background: rgba(37, 37, 37, 0.29);
    border-top: 1px solid rgba(37, 37, 37, 0.31);
}

.corporation-selector-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.corporation-buttons {
    display: flex;
    gap: 0.5rem;
}

.corporation-btn-compact {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    min-width: 100px;
}

.department-filter-inline {
    flex: 1;
    min-width: 200px;
}

.department-select-compact {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.department-select-compact:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.party-filter-inline {
    flex: 1;
    min-width: 200px;
}

.party-select-compact {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.party-select-compact:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.clear-selection-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    white-space: nowrap;
}

.group-by-party-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    white-space: nowrap;
}


/* ========================================
   Search Box
   ======================================== */
.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box::before {
    content: "🔍";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
}

/* ========================================
   Candidate Table
   ======================================== */
.candidate-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.candidate-table thead {
    background: var(--background);
}

.candidate-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.candidate-table th:hover {
    color: var(--primary);
}

.candidate-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s ease;
}

.candidate-table tbody tr:hover {
    background: var(--background);
}

.candidate-table td {
    padding: 1rem;
    font-size: 0.95rem;
}

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

.candidate-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.candidate-votes {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1rem;
}

.candidate-percentage {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.candidate-age-young {
    color: #3b82f6;
    font-weight: 600;
}

.trend-indicator {
    display: inline-block;
    font-size: 1.2rem;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

/* Checkbox */
.candidate-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Grouped Table Rows */
.group-header-row {
    background: var(--background);
    cursor: pointer;
    font-weight: 600;
    border-left: 4px solid var(--primary);
}

.group-header-row:hover {
    background: var(--border);
}

.expand-icon {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: inline-block;
    transition: transform 0.2s ease;
}

.child-row {
    background: var(--card-bg);
}

.child-row:hover {
    background: var(--background);
}

/* ========================================
   Pagination
   ======================================== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

.pagination-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.9rem;
}

/* ========================================
   Chart Container
   ======================================== */
.chart-container {
    position: relative;
    height: 400px;
    margin-top: 1rem;
}

/* Chart Color Mode Buttons */
.chart-color-mode-buttons {
    display: flex;
    gap: 0.5rem;
}

.chart-mode-btn {
    padding: 0.5rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chart-mode-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.chart-mode-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.chart-mode-btn.active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.chart-mode-btn:active {
    transform: scale(0.98);
}

/* ========================================
   Loading Spinner
   ======================================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

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

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

/* ========================================
   Badge
   ======================================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

/* ========================================
   Sort Indicator
   ======================================== */
.sort-indicator {
    margin-left: 0.25rem;
    font-size: 0.75rem;
    opacity: 0.6;
}

/* ========================================
   No Results Message
   ======================================== */
.no-results {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* ========================================
   Political Party Badges
   ======================================== */
.party-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.party-colombia-humana {
    background: #3b82f6;  /* Azul sólido */
}

.party-polo-democratico {
    background: #ffc107;  /* Amarillo */
    color: #1f2937;
    text-shadow: none;
}

.party-progresistas {
    background: #8b5cf6;  /* Púrpura */
}

.party-union-patriotica {
    background: #10b981;  /* Verde sólido */
}

.party-partido-comunista {
    background: #ef4444;  /* Rojo */
}

.party-minga-politica {
    background: #92400e;  /* Café */
}

.party-otra-agrupacion {
    background: #6b7280;  /* Gris */
}

.party-persona-individual {
    background: #9ca3af;  /* Gris claro */
}

.party-default {
    background: #e5e7eb;
    color: #6b7280;
    text-shadow: none;
}

/* ========================================
   Mapa de Colombia
   ======================================== */
.map-toggle-btn {
    padding: 0.5rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: none;
}

.map-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.map-toggle-btn:active {
    transform: scale(0.98);
}

.map-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.map-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.map-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.map-svg-wrapper {
    width: 100%;
    height: 0;
    padding-bottom: 113%; /* Aspect ratio: 693.68 / 612.82 = 1.13 */
    position: relative;
    margin: 0 auto;
    transition: opacity 0.3s ease;
}

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-align: center;
}

.map-loading p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.map-svg-wrapper svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.map-path {
    stroke: #ffffff;
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-path:hover {
    stroke-width: 3;
    stroke: #1f2937;
    filter: brightness(1.1);
    transform-origin: center;
}

.map-path:active {
    filter: brightness(0.9);
}

/* ========================================
   Tooltip del Mapa
   ======================================== */
.map-tooltip {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    z-index: 10000;
    min-width: 350px;
    max-width: 450px;
    max-height: 500px;
    overflow-y: auto;
}

.map-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.map-tooltip-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.map-tooltip-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

.map-tooltip-candidate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.map-tooltip-candidate:last-child {
    border-bottom: none;
}

.map-tooltip-candidate-rank {
    font-weight: 700;
    color: var(--primary);
    margin-right: 0.75rem;
    min-width: 25px;
}

.map-tooltip-candidate-info {
    flex: 1;
    margin-right: 0.5rem;
}

.map-tooltip-candidate-name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.map-tooltip-candidate-votes {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.map-tooltip-party {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 140px;
    }

    .app-container {
        padding: 1rem 0;
    }

    .container {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }

    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .app-logo {
        width: 190px;
    }

    .app-subtitle {
        display: none;
    }

    .card-title {
        font-size: 1.1rem;
    }

    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .search-box {
        margin-bottom: 1rem;
    }

    .search-box input {
        font-size: 0.9rem;
        padding: 0.65rem 1rem 0.65rem 2.5rem;
    }

    .search-box::before {
        font-size: 1rem;
        left: 0.85rem;
    }

    .candidate-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .pagination-container {
        flex-direction: column;
        gap: 0.75rem;
        padding-top: 1rem;
        margin-top: 1rem;
    }

    .pagination-info {
        font-size: 0.85rem;
        width: 100%;
        text-align: center;
    }

    .pagination-controls {
        width: 100%;
        justify-content: center;
    }

    .pagination-controls span {
        font-size: 0.85rem;
        padding: 0 0.5rem !important;
    }

    .pagination-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .empty-state {
        padding: 2rem 0.5rem;
    }

    .empty-state h3 {
        font-size: 1rem;
    }

    .empty-state p {
        font-size: 0.9rem;
    }

    .clear-selection-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    .app-header {
        padding: 0.75rem 0;
        margin-bottom: 1rem;
    }

    .app-header-content {
        gap: 0.5rem;
    }

    .corporation-selector-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .clear-selection-btn {
        width: 100%;
    }

    .group-by-party-btn {
        width: 100%;
    }

    .corporation-buttons {
        width: 100%;
        justify-content: space-between;
    }

    .corporation-btn-compact {
        flex: 1;
        min-width: auto;
        padding: 0.625rem 0.75rem;
        font-size: 0.85rem;
    }

    .department-filter-inline {
        width: 100%;
        min-width: auto;
    }

    .party-filter-inline {
        width: 100%;
        min-width: auto;
    }

    .corporation-selector-fixed {
        padding: 0.75rem 0;
    }

    .row.mb-4 {
        margin-left: 0;
        margin-right: 0;
    }

    .row.mb-4 > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
    }

    .map-card {
        padding: 1rem !important;
    }

    .map-toggle-btn {
        display: inline-block;
    }

    .map-svg-wrapper {
        padding-bottom: 113%; /* Mantiene aspect ratio en móvil */
    }

    .candidate-table {
        font-size: 0.9rem;
    }

    .candidate-table th {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .candidate-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .candidate-name {
        font-size: 0.95rem;
        line-height: 1.3;
    }

    .candidate-details {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    .candidate-votes {
        font-size: 1rem;
    }

    .candidate-percentage {
        font-size: 0.85rem;
    }

    .candidate-age-young {
        font-size: 0.9rem;
    }

    .party-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .candidate-checkbox {
        width: 16px;
        height: 16px;
    }

    .chart-container {
        height: 300px;
    }

    .chart-color-mode-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .chart-mode-btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 0.5rem 0.5rem;
    }

    .map-tooltip {
        min-width: 260px;
        max-width: 85vw;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .map-tooltip-title {
        font-size: 1rem;
    }

    .map-tooltip-candidate-name {
        font-size: 0.85rem;
    }

    .map-tooltip-candidate-votes {
        font-size: 0.75rem;
    }

    .map-tooltip-party {
        font-size: 0.65rem;
    }

    .theme-switcher {
        width: 36px;
        height: 36px;
    }

    .theme-icon {
        width: 18px;
        height: 18px;
    }

    /* Smooth horizontal scroll for table */
    div[style*="overflow-x: auto"] {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        margin: 0 -0.4rem;
        padding: 0 0.4rem;
    }

    .no-results {
        padding: 1.5rem 1rem;
        font-size: 0.9rem;
    }
}
