/*
 * Widget Elecciones 2026 - Estilos de Widgets
 * Archivo: widget-2w.css
 * 
 * Este archivo contiene los estilos de los dos widgets principales:
 * 1. Widget de Candidatos Presidenciales
 * 2. Widget de Mapa Electoral
 * 
 * (C) 2026 Prisa Media - http://www.prisa.com
 */

/* ===== CSS VARIABLES ===== */
:root {
    --bg: #f7f7f7;
    --card: #fff;
    --muted: #727272;
    --font-stack: "Poppins", Arial, Helvetica, sans-serif;
    --max-w: 1115px;
}

/* ===== ESTILOS COMUNES ===== */
* {
    box-sizing: border-box;
}

/* ============================================== */
/* WIDGET 1: CANDIDATOS PRESIDENCIALES            */
/* ============================================== */

.widget-pres {
    max-width: var(--max-w);
    background: var(--bg);
    margin: 24px auto;
    padding: 20px;
    border-radius: 10px;
    min-height: 522px;
}
#mapa_interactivo {margin-left:20px
}
/* ----- Header del Widget ----- */
.widg-header {
    text-align: center;
}

.widg-header h1 {
    font-size: 28px;
    letter-spacing: 1px;
    margin: 6px 0 10px;
}

.top-stats {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    font-size: 19px;
    color: var(--muted);
    border-bottom: 1px solid rgba(0,0,0,0.12);
    padding-bottom: 12px;
}

.top-stats .boletin .num {
    color: var(--accent);
    font-weight: 700;
    margin-left: 6px;
}

.top-stats .boletin small {
    display: block;
    font-size: 12px;
    color: #9c9c9e;
    margin-top: 2px;
}

.top-stats .mesas strong {
    color: #000;
    margin-left: 6px;
}

/* ----- Candidatos Grandes (Top 2) ----- */
.candidates-big {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 22px 0;
}

.card {
    background: var(--card);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.card.large {
    display: flex;
    gap: 18px;
    align-items: center;
    border-bottom:none!important
}

.avatar {
    width: 120px;
    height: 120px;
    min-width: 120px;
    background: linear-gradient(180deg,#d1d1d1,#f3f3f3);
    border-radius: 50%;
    box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.avatar img.cand {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0.9;
    object-fit: cover;
}

.card-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.card-info h2 {
    font-size: 16px;
    margin: 0 0 8px;
    text-transform: uppercase;
}

/* ----- Barra de Progreso ----- */
.progress-line {
    height: 4px;
    width: 100%;
    background: #dadada;
    margin: 8px 0;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

.progress-line span {
    background: #dadada;
    display: block;
    position: absolute;
    height: 4px;
    left: 0;
    top: 0;
}

/* Colores por candidato */
.progress-line span.part001 { background: #a52e94; }
.progress-line span.part002 { background: #c9e622; }
.progress-line span.part003 { background: #545454; }
.progress-line span.part004 { background: #a80b16; }
.progress-line span.part005 { background: #f4c527; }
.progress-line span.part006 { background: #0f4283; }
.progress-line span.part007 { background: #ee2740; }
.progress-line span.part008 { background: #fe0102; }
.progress-line span.part009 { background: #d07f32; }
.progress-line span.part010 { background: #46a30b; }
.progress-line span.part011 { background: #16bbeb; }
.progress-line span.part012 { background: #ffb600; }
.progress-line span.part013 { background: #ea1c78; }

/* ----- Estadísticas ----- */
.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.percent {
    font-weight: 700;
    font-size: 28px;
}

.votos {
    font-size: 16px;
    color: var(--muted);
}

/* ----- Logo de Partido ----- */
.bar-partido {
    height: 28px;
    width: 120px;
    margin-top: 10px;
    overflow: hidden;
}

.bar-partido img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left center;
}

/* ----- Candidatos Pequeños (Resto) ----- */
.candidates-small {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin: 18px 0;
}

.card.small {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px;
    border-bottom:none!important
}

.avatar.small {
    width: 54px;
    height: 54px;
    min-width: 54px;
    border-radius: 50%;
    box-shadow: none;
    overflow: hidden;
}

.avatar.small img.cand {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info.small {
    height: 92px;
}

.card-info.small h3 {
    font-size: 12px;
    margin: 0;
    text-transform: uppercase;
    font-weight: 700;
    min-height: 2.4em;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-info.small .progress-line {
    height: 3px;
    margin: 3px 0;
}

.card-info.small .progress-line span {
    height: 3px;
}

.card-info.small .votos {
    font-size: 12px;
    white-space: nowrap;
}

.card-info.small .percent {
    font-size: 18px;
}

.card-info.small .meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

.card-info.small .bar-partido.tiny {
    margin-top: 2px;
    overflow: hidden;
}

.card-info.small .bar-partido.tiny img {
    height: 22px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.bar-placeholder.tiny {
    height: 16px;
    width: 60px;
    background: #eee;
    border-radius: 3px;
}

/* ----- Footer del Widget ----- */
.widg-footer {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 2px dashed rgba(0,0,0,0.12);
}

.footer-left {
    display: flex;
    gap: 50px;
    color: var(--muted);
}

.footer-center {
    font-weight: 800;
}

.more {
    background: #5a5a5a url(img/ico-sig.svg) 97% 48% no-repeat !important;
    color: #ffffff;
    border-radius: 22px !important;
    padding: 12px 24px 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    margin: 2px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    font-family: inherit;
    text-align: center;
}

/* ----- Barra de Actualización ----- */
#actu {
    background: #dedede;
    height: 2px;
    width: 100%;
    position: relative;
    margin-bottom: 10px;
}

#pr {
    background: #bf0000;
    width: 0;
    height: 2px;
    position: absolute;
    left: 0;
    z-index: 8;
}

/* ----- Estado Loading ----- */
.loading {
    opacity: 0.5;
}

/* ============================================== */
/* WIDGET 2: MAPA ELECTORAL                       */
/* ============================================== */

/* ----- Layout Mapa + Datos ----- */
.mapa {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
}

.mapa .datos {
    flex: 0 0 auto;
    width: 45%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
}

.mapa .grafico_mapa {
    flex: 1 1 auto;
    min-width: 300px;
    padding-right: 20px;
    box-sizing: border-box;
}

.mapa .grafico_mapa svg {
    width: 70%;
    height: auto;
    display: block;
    max-width: 100%;
    margin: auto;
}

/* ----- Leyenda de Colores ----- */
#leyenda_colores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #f9f9f9;
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #e8e8e8;
    margin-bottom: 12px;
}

.leyenda_item {
    display: flex;
    align-items: center;
    font-size: 13px;
    line-height: 1.2;
    color: #333;
    gap: 8px;
    cursor: pointer;
    border-radius: 4px;
    padding: 4px 6px;
    transition: opacity 0.2s, background 0.2s;
}

.leyenda_item:hover {
    background: #ebebeb;
}

.leyenda_item.activo {
    background: #e6f0ff;
    font-weight: 700;
}

.leyenda_item.inactivo {
    opacity: 0.35;
}

.leyenda_item .circulo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    transition: transform 0.2s;
    border: 3px solid;
    overflow: hidden;
    position: relative;
}

.leyenda_item .circulo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.leyenda_item.activo .circulo {
    transform: scale(1.1);
}

.leyenda_item .nombre-candidato {
    font-size: 13px;
    color: #333;
    line-height: 1.3;
}

/* ----- Instrucción Leyenda ----- */
.leyenda-instruccion {
    font-size: 10px;
    color: #999;
    font-style: italic;
    padding: 2px 4px 6px;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 6px;
    line-height: 1.4;
    width: 100%;
    grid-column: 1 / -1;
}

/* ----- Tabs del Mapa ----- */
.mapa-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-radius: 25px;
    overflow: hidden;
    border: 2px solid #e8e8e8;
    background: #e8e8e8;
}

.mapa-tab {
    flex: 1;
    padding: 12px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    border: none;
    background: transparent !important;
    color: #888888;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: none;
    text-align: center;
    border-radius: 0;
}

.mapa-instrucciones-mobile {
    display: none;
}

.mapa-tab:first-child {
    border-radius: 25px 0 0 25px;
}

.mapa-tab:last-child {
    border-radius: 0 25px 25px 0;
}

.mapa-tab:hover:not(.activo) {
    background: #d0d0d0;
    color: #666666;
}

.mapa-tab.activo {
    background: #5a5a5a !important;
    color: #ffffff;
    border-radius: 22px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    margin: 2px;
}

/* ----- Tabs Mapa Móvil ----- */
.mapa-tabs-mobile {
    display: none;
    gap: 0;
    margin-bottom: 16px;
    border-radius: 25px;
    overflow: hidden;
    border: 2px solid #e8e8e8;
    background: #e8e8e8;
}

/* ----- Instrucciones del Mapa ----- */
.mapa-instrucciones {
    font-size: 10px;
    color: #666;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 10px;
}
.mapa-instrucciones p {
    margin: 0;
    font-size:10px
}

/* ----- Top Candidatos (lista departamental) ----- */
#top_cand {
    background: #f9f9f9;
    border-radius: 6px;
    padding: 8px 10px;
    border: 1px solid #e8e8e8;
    font-size: 12px;
}

/* ============================================== */
/* TOOLTIP DEPARTAMENTO                           */
/* ============================================== */

.tooltip-depto {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 12px;
    font-family: 'Open Sans', sans-serif;
    min-width: 260px;
    max-width: 280px;
}

.tooltip-depto .depto-nombre {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    text-transform: uppercase;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 6px;
}

.tooltip-depto .candidato-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px;
    background: #f9f9f9;
    border-radius: 6px;
    transition: background 0.2s;
    gap: 8px;
}

.tooltip-depto .candidato-item:hover {
    background: #f0f0f0;
}

.tooltip-depto .candidato-item:last-child {
    margin-bottom: 0;
}

.tooltip-depto .candidato-posicion {
    font-size: 16px;
    font-weight: 700;
    color: #999;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.tooltip-depto .candidato-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    border: 2px solid #e0e0e0;
}

.tooltip-depto .candidato-info {
    flex: 1;
    min-width: 0;
}

.tooltip-depto .candidato-nombre {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tooltip-depto .candidato-barra-container {
    width: 100%;
    height: 5px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 3px;
}

.tooltip-depto .candidato-barra {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.tooltip-depto .candidato-stats {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #666;
}

.tooltip-depto .candidato-porcentaje {
    font-weight: 700;
    color: #333;
}

.tooltip-depto .candidato-votos {
    color: #999;
}

/* Botón cerrar (X) para móviles */
.tooltip-depto .tooltip-cerrar {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: background 0.2s, color 0.2s;
}

.tooltip-depto .tooltip-cerrar:hover,
.tooltip-depto .tooltip-cerrar:active {
    background: #e0e0e0;
    color: #333;
}

/* Enlace "VER MÁS" solo visible en móviles */
.tooltip-depto .tooltip-ver-mas {
    display: block;
    text-align: center;
    margin-top: 10px;
    padding: 10px 20px;
    background: #5a5a5a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 22px;
    letter-spacing: 0.5px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    cursor: pointer;
}

.tooltip-depto .tooltip-ver-mas:hover,
.tooltip-depto .tooltip-ver-mas:active {
    background: #4a4a4a;
}

/* Tema personalizado para Tippy */
.tippy-box[data-theme~='depto'] {
    background-color: transparent;
    box-shadow: none;
}

.tippy-box[data-theme~='depto'] .tippy-content {
    padding: 0;
}

/* ============================================== */
/* RESPONSIVE - WIDGET PRESIDENCIALES             */
/* ============================================== */

@media (max-width: 900px) {
    .candidates-small {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 12px;
    }

    .candidates-big {
        grid-template-columns: 1fr;
    }

    .avatar {
        width: 90px;
        height: 90px;
        min-width: 90px;
    }

    .widg-header h1 {
        font-size: 22px;
    }

    .card.small {
        padding: 12px;
        gap: 10px;
    }

    .avatar.small {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }

    .card-info.small h3 {
        font-size: 12px;
        min-height: 2.4em;
    }

    .card-info.small .percent {
        font-size: 18px;
    }

    .card-info.small .votos {
        font-size: 11px;
    }

    .bar-partido.tiny {
        height: 20px;
        width: 80px;
    }
}

@media (max-width: 768px) {
    .candidates-small {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }

    .card.small {
        padding: 10px;
        gap: 8px;
    }

    .avatar.small {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }

    .card-info.small h3 {
        font-size: 10px;
        min-height: 2.2em;
    }
    .mapa .grafico_mapa svg {
        width:90%!important
    }
    .card-info.small .percent {
        font-size: 14px;
    }

    .card-info.small .votos {
        font-size: 9px;
    }

    /* Tarjetas grandes */
    .card-info h2 {
        font-size: 13px;
    }

    .percent {
        font-size: 22px;
    }

    .votos {
        font-size: 13px;
    }

    .bar-partido.tiny {
        display: none;
    }

    .widg-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .footer-left {
        font-size: 12px;
    }

    .footer-center {
        font-size: 13px;
    }
}

@media (max-width: 520px) {
    .wrap {
        padding: 14px;
    }

    .widget-pres {
        min-height: 1005px;
    }

    .top-stats {
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .candidates-small {
        grid-template-columns: repeat(1,1fr);
    }

    .card.large {
        flex-direction: row;
        gap: 12px;
    }

    .avatar {
        width: 80px;
        height: 80px;
        min-width: 80px;
    }

    .avatar.small {
        width: 60px;
        height: 60px;
        min-width: 60px;
    }

    .card-info.small {
        height: 62px;
    }

    .percent {
        font-size: 22px;
    }

    .site-header h1 {
        font-size: 20px;
    }

    .widg-header h1 {
        font-size: 20px;
        letter-spacing: 0.5px;
    }

    .bar-partido {
        display: none;
    }

    .widg-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .widg-footer .footer-right {
        align-self: flex-end;
        margin-top: 12px;
    }
}

@media (max-width: 360px) {
    .card.large {
        flex-direction: column;
        align-items: flex-start;
    }

    .avatar {
        align-self: center;
    }

    .widg-header h1 {
        font-size: 16px;
        letter-spacing: 0.3px;
    }
}

/* ============================================== */
/* RESPONSIVE - WIDGET MAPA                       */
/* ============================================== */

@media (max-width: 1024px) {
    #leyenda_colores {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .leyenda-instruccion {
        width: 100%;
        order: -1;
        margin-bottom: 8px;
        font-size: 11px;
        padding: 6px 8px;
    }

    .leyenda_item {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        padding: 6px 8px;
        margin-bottom: 0;
    }

    .leyenda_item .circulo {
        width: 36px;
        height: 36px;
    }

    .leyenda_item .nombre-candidato {
        font-size: 14px;
        flex: 1;
    }
}

@media (max-width: 900px) {
    .mapa {
        flex-direction: column;
    }

    .mapa .datos {
        width: 100%;
        min-width: 0;
        order: 3;
        display: flex;
        flex-direction: column;
    }

    .mapa .grafico_mapa {
        width: 100%;
        min-width: 0;
        order: 2;
    }

    .mapa .grafico_mapa svg {
        width: 100%;
        height: auto;
        display: block;
        max-width: 100%;
        margin: auto;
    }
    #mapa_interactivo {
        margin-left: 0px
    }
        .mapa .datos .mapa-tabs, .mapa-instrucciones {
            display: none;
        }

    .mapa-instrucciones-mobile {
        display: flex;
        order: 1;
        width: 100%;
    }

    .mapa-tabs-mobile {
        display: flex;
        order: 1;
        width: 100%;
    }

    #leyenda_colores {
        flex-direction: row;
        flex-wrap: wrap;
        order: 1;
    }
}

@media (max-width: 768px) {
    .mapa {
        flex-direction: column;
    }

    .mapa .datos {
        width: 100%;
        min-width: 0;
        order: 2;
    }

    .mapa .grafico_mapa {
        width: 100%;
        min-width: 0;
        order: 1;
        padding-right: 15px;
    }

    #leyenda_colores {
        gap: 2px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .leyenda-instruccion {
        width: 100%;
        order: -1;
        flex-basis: 100%;
        font-size: 12px;
        padding: 8px 10px;
    }

    .leyenda_item {
        width: calc(50% - 2px);
        padding: 6px 8px;
        flex-direction: row;
        justify-content: flex-start;
    }

    .leyenda_item .circulo {
        width: 32px;
        height: 32px;
        border-width: 2px;
    }

    .leyenda_item .nombre-candidato {
        font-size: 12px;
        flex: 1;
    }
}

/* ============================================== */
/* UTILIDADES                                     */
/* ============================================== */

/* Scroll vertical para lista de departamentos en Cámara */
.contenido-scrol {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.contenido-scrol #lst-can-ca {
    max-width: 98%;
}
