/* ========================================
   FONDOS
   ======================================== */
.ci-bg-navy  { background: var(--navy-blue); }

/* ========================================
   BOTONES DEPARTAMENTOS
   ======================================== */
.ci-dptos-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.ci-btn-dpto {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    padding: 10px 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
    text-align: center;
}
.ci-btn-dpto:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239,184,21,0.35);
}

/* ========================================
   MODAL GOBIERNOS LOCALES
   ======================================== */
.ci-modal-gl {
    position: fixed;
    inset: 0;
    background: rgba(15,17,40,0.82);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.ci-modal-gl-content {
    background: #fff;
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0,0,0,0.35);
    animation: ciModalIn 0.3s ease;
}
@keyframes ciModalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Header modal */
.ci-modal-gl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f1f5;
}
.ci-modal-gl-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--navy-blue);
    margin: 0;
}
.ci-modal-gl-header h2 .nom-departamento {
    color: var(--gold);
}
.ci-modal-gl-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--red);
    background: #fff;
    color: var(--red);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.ci-modal-gl-close:hover {
    background: var(--red);
    color: #fff;
    transform: scale(1.1);
}

/* Grid distritos */
.ci-modal-gl-distritos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}
.ci-btn-distrito {
    background: #fff;
    color: var(--navy-blue);
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.ci-btn-distrito:hover {
    border-color: var(--navy-blue);
    background: var(--navy-blue);
    color: #fff;
}
.ci-btn-distrito.activo {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
    box-shadow: 0 4px 12px rgba(181,46,35,0.3);
}

/* Imagen y botón dentro del modal */
.c-imagen-boton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 8px;
}
.imagen-gobiernos-locales {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(57,63,111,0.12);
    transition: opacity 0.35s ease;
    background: #f5f6f8;
}
.fade-out { opacity: 0; }

.btn-conoce-mas-gobierno {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: var(--navy-blue);
    border: 1.5px solid var(--red);
    border-radius: 10px;
    padding: 12px 28px;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.25s ease;
}
.btn-conoce-mas-gobierno i { color: var(--red); transition: color 0.25s; }
.btn-conoce-mas-gobierno:hover {
    background: var(--red);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(181,46,35,0.25);
}
.btn-conoce-mas-gobierno:hover i { color: #fff; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .ci-dptos-grid { grid-template-columns: repeat(3, 1fr); }
    .ci-modal-gl-content { padding: 20px; }
    #modalGaleriaImg { height: 280px !important; }
}
@media (max-width: 576px) {
    .ci-dptos-grid { grid-template-columns: repeat(2, 1fr); }
    .ci-btn-distrito { font-size: 0.76rem; padding: 7px 12px; }
    .ci-modal-gl-header h2 { font-size: 1.1rem; }
}
/* Wrapper para imagen más grande */
.imagen-wrapper-grande {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    min-height: 450px;
}

.imagen-wrapper-grande img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

/* Responsive */
@media (max-width: 991px) {
    .imagen-wrapper-grande {
        min-height: 350px;
    }
    
    .imagen-wrapper-grande img {
        max-height: 500px;
    }
}

@media (max-width: 768px) {
    .imagen-wrapper-grande {
        min-height: 300px;
        padding: 15px;
    }
    
    .imagen-wrapper-grande img {
        max-height: 400px;
    }
}

/* ========================================
   RESPONSIVE MÓVIL — INSTITUCIONES
   Añadir al final de convenios_instituciones.css
   ======================================== */

/* ---------- INTRO: título + imagen + 4 párrafos ---------- */
@media (max-width: 991px) {

    /* La imagen de la sección Intro pasa a ancho completo */
    .intro-imagen-col {
        text-align: center;
    }
    .intro-imagen-col img {
        height: 200px !important;
        width: 100% !important;
        object-fit: cover;
        object-position: center;
        border-radius: 1rem;
    }
}

@media (max-width: 768px) {

    /* ── Hero ── */
    .hero-titulo {
        font-size: clamp(0.9rem, 4vw, 1.2rem) !important;
        padding: 0 12px;
    }
    .hero-subtitulo {
        font-size: clamp(0.72rem, 2.8vw, 0.9rem) !important;
    }

    /* ── Sección Intro ── */
    .intro-section .container {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* Columnas apiladas: primero imagen, luego texto */
    .intro-section .row.g-5 {
        flex-direction: column;
        gap: 0 !important;
    }

    /* Imagen centrada y proporcionada */
    .intro-section .col-lg-5 {
        order: 1;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100%;
        padding-bottom: 20px;
    }
    .intro-section .col-lg-5 img {
        height: 200px !important;
        width: 100% !important;
        object-fit: cover;
        object-position: center top;
        border-radius: 14px;
        box-shadow: 0 8px 28px rgba(57,63,111,0.18);
    }

    /* Texto debajo de la imagen */
    .intro-section .col-lg-7 {
        order: 2;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100%;
        padding-top: 4px;
    }

    /* Título de la sección */
    .intro-section h2 {
        font-size: 1.25rem !important;
        margin-top: 0;
    }

    /* Párrafos legibles */
    .intro-section p,
    .intro-section .row.mt-4 p {
        font-size: 0.88rem !important;
        line-height: 1.65;
        text-align: left !important;
    }

    /* Párrafos 3 y 4 (fila completa) */
    .intro-section .row.mt-4 {
        margin-top: 12px !important;
    }

    /* ── Gobiernos Locales ── */
    .ci-bg-navy .col-lg-4 img {
        height: 200px !important;
        border-radius: 12px;
    }
    .ci-bg-navy .col-lg-8 h2 {
        font-size: 1.2rem;
    }
    .ci-bg-navy .col-lg-8 p {
        font-size: 0.83rem;
    }

    /* ── Grid departamentos ── */
    .ci-dptos-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    .ci-btn-dpto {
        font-size: 0.78rem !important;
        padding: 9px 4px !important;
    }

    /* ── Modal Gobiernos Locales ── */
    .ci-modal-gl-content {
        padding: 18px 16px !important;
        border-radius: 16px !important;
    }
    .ci-modal-gl-header h2 {
        font-size: 1rem !important;
    }
    .imagen-gobiernos-locales {
        max-height: 200px !important;
    }
    .btn-conoce-mas-gobierno {
        font-size: 0.82rem !important;
        padding: 10px 18px !important;
        width: 100%;
        justify-content: center;
    }

    /* ── Instituciones Aliadas ── */
    .imagen-wrapper-grande {
        min-height: 220px !important;
        padding: 10px !important;
    }
    .imagen-wrapper-grande img {
        max-height: 300px !important;
        border-radius: 12px;
    }

    /* ── Galería ── */
    .galeria-section .col-md-4 img,
    .galeria-section .col-6 img {
        height: 150px !important;
    }
}

/* ---------- Teléfonos pequeños: 480px y menos ---------- */
@media (max-width: 480px) {

    /* Hero más compacto */
    .hero-titulo {
        font-size: clamp(0.82rem, 4.5vw, 1rem) !important;
    }

    /* Intro */
    .intro-section .container {
        padding-left: 14px;
        padding-right: 14px;
    }
    .intro-section .col-lg-5 img {
        height: 170px !important;
        border-radius: 10px;
    }
    .intro-section p,
    .intro-section .row.mt-4 p {
        font-size: 0.83rem !important;
    }

    /* Departamentos: 2 columnas apretadas */
    .ci-dptos-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px;
    }
    .ci-btn-dpto {
        font-size: 0.72rem !important;
        padding: 8px 2px !important;
        border-radius: 8px !important;
    }

    /* Modal distritos */
    .ci-btn-distrito {
        font-size: 0.73rem !important;
        padding: 6px 10px !important;
    }

    /* Galería: 2 columnas */
    .galeria-section .col-md-4,
    .galeria-section .col-6 {
        width: 50% !important;
    }
    .galeria-section .col-md-4 img,
    .galeria-section .col-6 img {
        height: 120px !important;
    }
}

/* ---------- Mínimo absoluto: 320px ---------- */
@media (max-width: 360px) {

    .intro-section h2 {
        font-size: 1.1rem !important;
    }
    .intro-section p,
    .intro-section .row.mt-4 p {
        font-size: 0.8rem !important;
    }
    .intro-section .col-lg-5 img {
        height: 150px !important;
    }

    .ci-btn-dpto {
        font-size: 0.68rem !important;
        padding: 7px 2px !important;
    }

    .ci-modal-gl-content {
        padding: 14px 12px !important;
    }
    .ci-modal-gl-header h2 {
        font-size: 0.92rem !important;
    }

    .imagen-wrapper-grande {
        min-height: 160px !important;
    }
    .imagen-wrapper-grande img {
        max-height: 240px !important;
    }
}