@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* =========================================
   VARIABLES Y CONFIGURACIÓN BASE
   ========================================= */
:root {
    --color-primary: #1e4a90;      /* PP Azul Principal */
    --color-primary-dark: #003366; /* Azul Oscuro */
    --color-accent: #0066ff;       /* Azul Brillante (Hover) */
    --color-highlight: #f7d417;    /* Amarillo PP (Detalles) */
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-bg: #f4f6f9;
    --color-text: #333333;
    --color-text-light: #666666;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 10px 25px rgba(30, 74, 144, 0.15);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

html, body {
    height: 100%;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

ul {
    list-style: none;
}

/* =========================================
   ESTRUCTURA GENERAL
   ========================================= */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
    flex: 1;
}

/* =========================================
   HEADER / HERO SECTION
   ========================================= */
.head {
    width: 100%;
    height: 350px;
    background-image: url("img/junta.jpg");
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

.head::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(30, 74, 144, 0.85) 0%, rgba(0, 51, 102, 0.6) 100%);
    z-index: 1;
}

.head img {
    max-width: 90%;
    width: 500px;
    height: auto;
    z-index: 2;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

/* =========================================
   FILTROS DE BÚSQUEDA
   ========================================= */
.filtro {
    background: #fff;
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
    transform: translateY(-20px); /* Efecto flotante sobre el header */
    border: 1px solid rgba(0,0,0,0.05);
}

.filtro form {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 15px;
    align-items: center;
}

.filtro input[type="text"], 
.filtro select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fff;
    font-size: 0.95rem;
    color: var(--color-text);
    outline: none;
    transition: border-color 0.3s ease;
}

.filtro input[type="text"]:focus, 
.filtro select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 74, 144, 0.1);
}

.filtro button {
    padding: 12px 25px;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    height: 100%;
}

.filtro button:hover {
    background-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(30, 74, 144, 0.3);
}

/* =========================================
   TARJETAS DE INICIATIVAS (LISTADO)
   ========================================= */
.iniciativas {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.iniciativa {
    background: #fff;
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.03);
    border-left: 15px solid transparent;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: grid;
    grid-template-columns: 1fr auto; /* Contenido | Estado */
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.iniciativa:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

/* Colores de borde lateral según estado */
.iniciativa.aprobada { border-left-color: var(--color-success); }
.iniciativa.rechazada { border-left-color: var(--color-danger); }

/* Contenido Principal de la Tarjeta */
.iniciativa-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.iniciativa-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 5px;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.fecha {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f0f2f5;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.area-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

.titulo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.4;
    display: block;
}

.titulo:hover {
    color: var(--color-accent);
    text-decoration: none;
}

/* Estado (Lateral derecho) */
.iniciativa-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-width: 120px;
}

.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: capitalize;
}

.estado-badge.aprobada {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
}

.estado-badge.rechazada {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--color-danger);
}

/* =========================================
   PAGINACIÓN
   ========================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 50px;
}

.pagination a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 15px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    color: var(--color-primary);
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.pagination a:hover {
    border-color: var(--color-primary);
    background-color: #f0f4fa;
}

.pagination a.active {
    background-color: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    pointer-events: none;
}

/* =========================================
   NAVBAR (Manteniendo funcionalidad original)
   ========================================= */
.navbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-primary);
    padding: 10px 30px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
    max-width: 90%;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 5px;
}

.nav-links a {
    color: #fff;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.95rem;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--color-highlight);
    background-color: rgba(255,255,255,0.1);
}

.nav-links a.button {
    background-color: #fff;
    color: var(--color-primary);
    margin-left: 10px;
}

.nav-links a.button:hover {
    background-color: var(--color-accent);
    color: #fff;
}

.hamburger-menu {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: #fff;
    margin-left: auto;
}

/* Submenú Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-primary);
    padding: 15px;
    border-radius: 15px;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    margin-top: 15px;
    flex-direction: column;
    gap: 5px;
}
.dropdown.active .dropdown-menu { display: flex; }
.dropdown-menu a { width: 100%; text-align: center; }

/* =========================================
   FOOTER
   ========================================= */
.footer {
    background: linear-gradient(to right, #002545 0%, #00305b 32%, #124b78 100%);
    color: white;
    padding: 30px 0;
    text-align: center;
    margin-top: auto;
}

.footer-copyright {
    opacity: 0.8;
    font-size: 0.9rem;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 992px) {
    .filtro form {
        grid-template-columns: 1fr 1fr;
    }
    .filtro button {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .head { height: 250px; }
    
    /* Navbar Móvil */
    .navbar { width: 90%; justify-content: space-between; padding: 15px 25px; }
    .hamburger-menu { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background-color: var(--color-primary);
        border-radius: 20px;
        padding: 20px;
        flex-direction: column;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    }
    .nav-links.show { display: flex; }
    .nav-links a.button { margin: 10px 0 0 0; text-align: center; }
    .dropdown-menu { position: relative; top: 0; left: 0; transform: none; box-shadow: none; background: rgba(0,0,0,0.1); width: 100%; margin-top: 10px; }

    /* Filtros Móvil */
    .filtro form {
        display: flex;
        flex-direction: column;
    }
    
    /* Tarjetas Móvil */
    .iniciativa {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 20px;
    }
    
    .iniciativa-status {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
        border-top: 1px solid #eee;
        padding-top: 15px;
    }
    
    .titulo { font-size: 1.1rem; }
}

/* =========================================
   ESTILOS ESPECÍFICOS: DETALLE INICIATIVA
   ========================================= */

/* Botón Volver */
.btn-volver {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 20px;
    background: #fff;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.btn-volver:hover {
    transform: translateX(-5px);
    box-shadow: var(--shadow-md);
    color: var(--color-accent);
}

/* Tarjeta Principal de Detalle */
.detalle-container {
    background: #fff;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.05);
    margin-bottom: 40px;
}

/* Cabecera del Detalle */
.detalle-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 25px;
    margin-bottom: 30px;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 36px; /* Altura fija para todos */
    line-height: 1;
}

.meta-badge.fecha {
    background-color: #f1f3f5;
    color: #495057;
    border: 1px solid #dee2e6;
}

.meta-badge.area {
    background-color: rgba(30, 74, 144, 0.1); /* Azul PP muy suave */
    color: var(--color-primary);
    border: 1px solid rgba(30, 74, 144, 0.2);
}

.meta-badge.estado.aprobada {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.meta-badge.estado.rechazada {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.cta-container {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee; /* Separador visual antes de votos */
}

.detalle-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px; /* Espacio entre badges */
    margin-bottom: 20px;
}

.detalle-titulo {
    font-size: 2.2rem;
    color: var(--color-primary);
    line-height: 1.2;
    margin-bottom: 20px;
    font-weight: 700;
}

/* Cuerpo del Texto */
.detalle-body {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #333;
    margin-bottom: 25px; /* Reducido de 40px a 25px */
    white-space: pre-wrap;
}

/* Botón Descarga PDF */
.btn-descarga {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background-color: var(--color-primary); /* Azul PP */
    color: #fff;
    padding: 18px 25px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem; /* Texto más grande */
    transition: all 0.3s ease;
    width: 100%;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(30, 74, 144, 0.2);
    border: 2px solid transparent;
}

.btn-descarga:hover {
    background-color: #fff;
    color: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(30, 74, 144, 0.15);
}

/* Sección de Votaciones (Grid Moderno) */
.votaciones-section {
    margin-top: 0px;
    padding-top: 10px;
    border-top: none;
}

.votaciones-title {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 25px;
    text-align: center;
    font-weight: 700;
}

.votaciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.voto-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    border: 1px solid rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

.voto-card:hover {
    transform: translateY(-5px);
}

/* Colores semánticos para las columnas de votos */
.voto-card.favor {
    background-color: rgba(40, 167, 69, 0.05);
    border-top: 4px solid var(--color-success);
}

.voto-card.contra {
    background-color: rgba(220, 53, 69, 0.05);
    border-top: 4px solid var(--color-danger);
}

.voto-card.abstencion {
    background-color: rgba(255, 193, 7, 0.1);
    border-top: 4px solid #ffc107;
}

.voto-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.voto-header i {
    font-size: 24px;
}

.voto-card.favor .voto-header i { color: var(--color-success); }
.voto-card.contra .voto-header i { color: var(--color-danger); }
.voto-card.abstencion .voto-header i { color: #ffc107; }

.partidos-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.partido-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    transition: transform 0.2s;
}

.partido-logo:hover {
    transform: scale(1.1);
}

/* Ajustes Responsive para Detalle */
@media (max-width: 768px) {
    .detalle-container { padding: 20px; }
    .detalle-titulo { font-size: 1.5rem; }
    .votaciones-grid { grid-template-columns: 1fr; }
}

/* =========================================
   MODAL DE DIPUTADOS
   ========================================= */

/* Hacemos las tarjetas clicables */
.voto-card {
    cursor: pointer;
    position: relative;
}

/* Indicador visual de "Ver más" en la tarjeta */
.voto-card::after {
    content: "Ver diputados";
    display: block;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--color-primary);
    font-weight: 600;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.3s ease;
}

.voto-card:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* Fondo oscuro del Modal */
.modal-overlay {
    display: none !important; /* Forzamos ocultar por defecto */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999; /* Z-index muy alto para estar encima de todo */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex !important;
    animation: fadeIn 0.3s ease;
}

/* Contenedor del Modal */
.modal-content {
    background: #fff;
    width: 100%;
    max-width: 900px;
    max-height: 85vh; /* Evita que sea más alto que la pantalla */
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Evita que la cabecera se encoja */
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--color-danger);
}

/* Grid de Diputados */
.modal-body {
    padding: 30px;
    overflow-y: auto; /* Scroll solo dentro del cuerpo */
    background: #fff;
}

.diputado-foto {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Fallback si no hay foto */
.diputado-foto.no-foto {
    background: #eee;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

.diputado-nombre {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.diputado-partido {
    font-size: 0.75rem;
    color: #666;
    background: #f1f1f1;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

/* Bloque para cada partido */
.partido-bloque {
    margin-bottom: 35px;
}

.partido-bloque:last-child {
    margin-bottom: 0;
}

/* Cabecera de cada sección de partido */
.partido-header-modal {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.partido-logo-modal {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.partido-nombre-modal {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.partido-count-badge {
    background: #e9ecef;
    color: #666;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    margin-left: auto; /* Empuja el contador a la derecha */
}

/* Grid interno de personas (Diseño tipo Lista/Tarjeta Horizontal) */
.diputados-lista {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); /* Más ancho para permitir formato horizontal */
    gap: 15px;
}

/* Item individual de diputado */
.diputado-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background-color: #fff;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.diputado-item:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transform: translateX(5px);
}

.diputado-item img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.diputado-info {
    display: flex;
    flex-direction: column;
}

.diputado-nombre-lista {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

.diputado-cargo {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

/* Animaciones */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Cursor para indicar que es clicable */
.voto-card { cursor: pointer; position: relative; transition: transform 0.2s; }
.voto-card:active { transform: scale(0.98); }

@keyframes fadeOut { 
    from { opacity: 1; } 
    to { opacity: 0; } 
}

@keyframes slideDown { 
    from { transform: translateY(0); opacity: 1; } 
    to { transform: translateY(20px); opacity: 0; } 
}

/* Cuando el modal tiene la clase 'closing', ejecuta la salida */
.modal-overlay.closing {
    animation: fadeOut 0.3s ease forwards;
}

.modal-overlay.closing .modal-content {
    animation: slideDown 0.3s ease forwards;
}

/* Responsive */
@media (max-width: 576px) {
    .diputados-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .diputado-foto { width: 60px; height: 60px; }
}