/* Calculadora Electoral & Pactómetro CSS */
:root {
    --primary: #0052bd;
    --primary-dark: #003d8f;
    --primary-light: #1a6dd4;
    --accent: #00d4ff;
    --dark: #0a0f1c;
    --dark-light: #111827;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --white: #ffffff;
    --gray-100: #f3f4f6;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Page Setup & Resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.calc-page {
    font-family: 'Exo', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--dark);
    color: var(--gray-300);
    line-height: 1.6;
    overflow-x: hidden;
    padding-top: 100px;
}

.calc-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header & Navigation Bar Integration */
.calc-header {
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 82, 189, 0.1) 0%, rgba(0, 212, 255, 0.05) 100%);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.calc-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.calc-subtitle {
    font-size: 1.1rem;
    color: var(--gray-400);
}

.view-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.view-tab-btn {
    border: 1px solid rgba(0, 212, 255, 0.25);
    background: rgba(0, 212, 255, 0.08);
    color: var(--gray-100);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.92rem;
    cursor: pointer;
}

.view-tab-btn.active {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.6);
    color: #fff;
}

[data-tab].tab-hidden {
    display: none !important;
}

/* Back Link Button */
.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(0, 212, 255, 0.2);
    background: rgba(0, 212, 255, 0.05);
}

.back-link:hover {
    background: rgba(0, 212, 255, 0.1);
    transform: translateX(-3px);
}

/* Layout Grid and Wrappers */
.calc-layout-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.calc-muni-top .calc-card {
    margin-bottom: 0;
}

.muni-details-horizontal {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.calc-top-inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 768px) {
    .calc-top-inputs {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .calc-top-inputs {
        grid-template-columns: 0.95fr 1.25fr 1.15fr;
    }
}

.calc-bottom-outputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .calc-bottom-outputs {
        grid-template-columns: 1.25fr 1fr;
    }
}

.calc-territorial-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .calc-territorial-section {
        grid-template-columns: 1fr 1.2fr;
    }
}

.territorial-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.territorial-btn {
    border: 1px solid rgba(0, 212, 255, 0.25);
    background: rgba(0, 212, 255, 0.08);
    color: var(--gray-100);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.territorial-btn.active {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.6);
    color: #fff;
}

.territorial-summary {
    font-size: 0.9rem;
    color: var(--gray-300);
    margin-bottom: 12px;
}

.zone-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.zone-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.5);
    color: #dcfce7;
    font-size: 0.8rem;
}

.zone-chip button {
    border: 0;
    background: transparent;
    color: #dcfce7;
    cursor: pointer;
    font-size: 0.85rem;
}

.zone-presets-bar {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.territorial-table-wrap {
    max-height: 340px;
    overflow: auto;
    border: 1px solid var(--card-border);
    border-radius: 10px;
}

.territorial-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.territorial-table th,
.territorial-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--card-border);
    text-align: left;
}

.territorial-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.territorial-table tbody tr:hover {
    background: rgba(0, 212, 255, 0.08);
}

.territorial-table tbody tr.selected {
    background: rgba(0, 212, 255, 0.2);
}

.territorial-table th {
    color: var(--gray-100);
    background: rgba(255, 255, 255, 0.03);
}

.census-map {
    width: 100%;
    height: 540px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
}

/* Glassmorphism Cards */
.calc-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-premium);
    margin-bottom: 24px;
}

.calc-card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calc-card-title span.badge {
    font-size: 0.8rem;
    background: var(--primary);
    color: var(--white);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

/* Autocomplete Search Bar */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(10, 15, 28, 0.8);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--white);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(0, 82, 189, 0.2);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(17, 24, 39, 0.98);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    margin-top: 5px;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: none;
}

.search-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    display: flex;
    justify-content: space-between;
}

.search-item:hover {
    background: rgba(0, 82, 189, 0.2);
}

.search-item .muni-info {
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* Municipality Info Badges */
.muni-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .muni-details-horizontal {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.muni-badge {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

.muni-badge-label {
    font-size: 0.75rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.muni-badge-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
}

.muni-badge-val.majority {
    color: var(--accent);
}

/* Inputs & Forms */
.calc-form-group {
    margin-bottom: 20px;
}

.calc-label-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.calc-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-300);
}

.calc-val-display {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
}

.calc-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    outline: none;
    border-radius: 3px;
}

.calc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.calc-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Party List Simulation Styles */
.party-sim-list {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 5px;
}

.party-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    margin-bottom: 12px;
    transition: all 0.3s ease;
    border-left: 5px solid var(--party-color, var(--gray-600));
}

.party-item:hover {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.party-item.excluded {
    opacity: 0.5;
}

.party-name-col {
    flex-grow: 1;
}

.party-name {
    font-weight: 700;
    color: var(--white);
    font-size: 1rem;
}

.party-desc {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.party-vote-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 130px;
}

.party-vote-input {
    width: 100%;
    padding: 8px;
    background: rgba(10, 15, 28, 0.8);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--white);
    font-size: 0.95rem;
    text-align: right;
    font-family: inherit;
    font-weight: 600;
}

.party-vote-input:focus {
    outline: none;
    border-color: var(--accent);
}

.delete-party-btn {
    background: none;
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s ease;
    padding: 4px;
    display: flex;
    align-items: center;
}

.delete-party-btn:hover {
    color: #ef4444;
}

/* Add Party Section */
.add-party-card {
    border: 1px dashed rgba(255,255,255,0.15);
    background: transparent;
}

.add-party-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.color-picker-wrapper {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.color-preset {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s ease;
}

.color-preset:hover {
    transform: scale(1.15);
}

.color-preset.active {
    border-color: var(--white);
}

.add-party-btn {
    background: var(--gradient);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
}

.add-party-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 82, 189, 0.3);
}

/* Pactómetro CSS */
.pact-bar-container {
    margin: 24px 0;
}

.pact-bar-wrapper {
    height: 36px;
    width: 100%;
    background: rgba(255,255,255,0.05);
    border-radius: 18px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--card-border);
}

.pact-bar {
    display: flex;
    height: 100%;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.pact-bar-segment {
    height: 100%;
    background-color: var(--seg-color);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 0.8rem;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid rgba(0,0,0,0.15);
}

.pact-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
    z-index: 5;
}

.pact-marker::before {
    content: 'Mayoría';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--dark);
    font-weight: 800;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    margin-bottom: 2px;
}

.pact-status-box {
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 15px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
}

.pact-status-box.success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.pact-status-box.fail {
    color: var(--gray-300);
}

.pact-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.pact-checkbox-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pact-checkbox-card:hover {
    background: rgba(255,255,255,0.05);
}

.pact-checkbox-card input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-light);
}

.pact-checkbox-card.active {
    border-color: var(--primary-light);
    background: rgba(0, 82, 189, 0.1);
}

/* Results Comparer Elements */
.results-flex {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

@media (min-width: 768px) {
    .results-flex {
        flex-direction: row;
    }
    .results-flex > div {
        flex: 1;
    }
}

.seats-graphic-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    min-height: 200px;
}

/* Semicircle seats diagram style */
.seats-semicircle {
    position: relative;
    width: 480px;
    height: 240px;
    overflow: hidden;
    margin-bottom: 15px;
}

.semicircle-bg {
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    border: 36px solid rgba(255, 255, 255, 0.03);
    box-sizing: border-box;
}

.semicircle-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--dot-color, var(--gray-600));
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px var(--dot-color);
    transition: all 0.3s ease;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.results-table th, 
.results-table td {
    padding: 12px 8px;
    text-align: right;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.95rem;
}

.results-table th {
    color: var(--gray-400);
    font-weight: 600;
}

.results-table th:first-child,
.results-table td:first-child {
    text-align: left;
    font-weight: 700;
    color: var(--white);
}

.results-table td:first-child span.color-bar {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--p-color);
    margin-right: 8px;
    vertical-align: middle;
}

.results-table td.seat-val {
    font-weight: 700;
    color: var(--white);
}

.diff-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.diff-badge.plus {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.diff-badge.minus {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.diff-badge.zero {
    background: rgba(255,255,255,0.05);
    color: var(--gray-400);
}

/* D'Hondt Detail Drawer styling */
.dhondt-collapse-trigger {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 14px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
    margin-top: 20px;
}

.dhondt-collapse-trigger:hover {
    background: rgba(255,255,255,0.04);
}

.dhondt-collapse-content {
    display: none;
    overflow-x: auto;
    padding-top: 15px;
}

.dhondt-collapse-content.active {
    display: block;
}

.dhondt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 10px;
}

.dhondt-table th,
.dhondt-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.05);
}

.dhondt-table th {
    background: rgba(0, 82, 189, 0.1);
    color: var(--accent);
}

.dhondt-table td.party-name-td {
    text-align: left;
    font-weight: 700;
    color: var(--white);
}

.dhondt-table td.assigned-seat {
    background: rgba(0, 212, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.3);
    color: var(--accent);
    font-weight: 700;
    position: relative;
}

.dhondt-table td.assigned-seat .seat-number-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
    background: var(--accent);
    color: var(--dark);
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 800;
}

/* Footer integration */
.calc-footer {
    text-align: center;
    margin-top: 50px;
    padding: 30px;
    color: var(--gray-600);
    border-top: 1px solid var(--card-border);
}

/* Custom Scrollbar for Party List */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Next seat margin analyzer styles */
.next-seat-highlight {
    background: rgba(245, 158, 11, 0.08);
    border-left: 4px solid #f59e0b;
    padding: 14px 18px;
    border-radius: 4px 10px 10px 4px;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

.next-seat-highlight strong {
    color: #fff;
}

.next-seat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--gray-300);
}

.next-seat-table th, .next-seat-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.next-seat-table th {
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.next-seat-table td.party-cell {
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.next-seat-table td.party-cell span.color-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.next-seat-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}
