/* ── UrabaEs.com · Tema (paleta del logo) ─────────────────────────────────── */
:root {
    --ue-navy:  #0A3D7A;
    --ue-ocean: #0B5FA5;
    --ue-teal:  #17A2A0;
    --ue-green: #3DBB4C;
    --ue-lime:  #B5E24A;
    --ue-wa:    #25D366;
    --ue-grad: linear-gradient(90deg, var(--ue-lime) 0%, var(--ue-green) 30%, var(--ue-teal) 60%, var(--ue-ocean) 85%, var(--ue-navy) 100%);

    --nav-h: 58px;

    --bs-primary: var(--ue-ocean);
    --bs-primary-rgb: 11,95,165;
    --bs-link-color: var(--ue-ocean);
    --bs-link-hover-color: var(--ue-navy);
}

/* Botones de marca (Bootstrap 5.3 usa vars --bs-btn-*) */
.btn-primary {
    --bs-btn-bg: var(--ue-ocean); --bs-btn-border-color: var(--ue-ocean);
    --bs-btn-hover-bg: #094e88; --bs-btn-hover-border-color: #094e88;
    --bs-btn-active-bg: #083f6e; --bs-btn-active-border-color: #083f6e;
    --bs-btn-disabled-bg: var(--ue-ocean); --bs-btn-disabled-border-color: var(--ue-ocean);
}
.btn-outline-primary {
    --bs-btn-color: var(--ue-ocean); --bs-btn-border-color: var(--ue-ocean);
    --bs-btn-hover-bg: var(--ue-ocean); --bs-btn-hover-border-color: var(--ue-ocean);
    --bs-btn-active-bg: var(--ue-ocean); --bs-btn-active-border-color: var(--ue-ocean);
}
.btn-success {
    --bs-btn-bg: var(--ue-wa); --bs-btn-border-color: var(--ue-wa);
    --bs-btn-hover-bg: #1eb658; --bs-btn-hover-border-color: #1eb658;
    --bs-btn-active-bg: #1aa04d;
}
.text-primary { color: var(--ue-ocean) !important; }
.text-success { color: #18a957 !important; }

/* ── Base ───────────────────────────────────────────────────────────────── */
/* Nada de overflow ni height fijo en html/body: el documento hace scroll normal
   y el position:sticky de navbar y mapa funciona. Si algún elemento se desborda
   en horizontal, se controla en ese elemento (no en el body). */

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.ue-navbar {
    min-height: var(--nav-h);
    background: var(--bs-body-bg);
    border-bottom: 3px solid transparent;
    border-image: var(--ue-grad) 1;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    padding-top: .25rem; padding-bottom: .25rem;
}
.ue-logo { height: 34px; width: auto; }
.ue-logo-footer { height: 40px; width: auto; }

/* En móvil, el menú se despliega como overlay (no empuja el layout) */
@media (max-width: 991.98px) {
    .ue-navbar .navbar-collapse {
        position: absolute; top: 100%; left: 0; right: 0;
        background: var(--bs-body-bg);
        padding: .5rem 1rem 1rem;
        box-shadow: 0 8px 16px rgba(0,0,0,.12);
        z-index: 1030;
    }
}

/* ── App shell (mapa fijo + panel scrollable) ───────────────────────────── */
.app-shell {
    position: relative;
}
/* Mapa fijo arriba con position:sticky (robusto en iOS, sin depender de 100dvh).
   Las cards fluyen por debajo del mapa al hacer scroll normal de la página. */
#mapa {
    position: sticky;
    top: var(--nav-h);
    height: 42vh;
    min-height: 220px;
    width: 100%;
    background: #dfe7ee;
    z-index: 2;
}
.panel-scroll {
    position: relative;
    z-index: 1;
    background: var(--bs-body-bg);
}

/* ── Barra de filtros (sticky bajo el mapa) ─────────────────────────────── */
.filtros-bar {
    position: relative; z-index: 1;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    padding: .6rem .75rem;
    box-shadow: 0 4px 10px rgba(0,0,0,.04);
}
.filtros-bar .form-control, .filtros-bar .form-select { font-size: .9rem; }
.filtros-panel { display: flex; gap: .5rem; flex-wrap: wrap; }
.filtros-panel .form-select { flex: 1 1 140px; min-width: 120px; }
.resultado-conteo { font-size: .8rem; color: var(--bs-secondary-color); }

/* Escritorio: split horizontal 50% mapa / 50% lista (lado a lado) */
@media (min-width: 992px) {
    .app-shell {
        display: flex;
        flex-direction: row;
        height: calc(100vh - var(--nav-h));
    }
    #mapa {
        position: static;
        top: 0;
        flex: 0 0 50%;
        width: 50%;
        height: 100%;
        min-height: 0;
    }
    .panel-scroll {
        flex: 0 0 50%;
        width: 50%;
        height: 100%;
        overflow-y: auto;
    }
    .filtros-bar {
        position: sticky;
        top: 0;
        z-index: 6;
    }
    /* En el panel 50% de escritorio: cuadrícula de 3 columnas */
    .app-shell .lista-centros.vista-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── Lista de centros ───────────────────────────────────────────────────── */
.lista-centros { display: grid; gap: .6rem; padding: .6rem; }
.lista-centros.vista-lista { grid-template-columns: 1fr; }
.lista-centros.vista-grid  { grid-template-columns: repeat(2, 1fr); }

/* Botones del toggle lista/grid */
.vista-toggle .btn.active { background: var(--ue-ocean); border-color: var(--ue-ocean); color: #fff; }

.centro-card {
    display: flex;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s, transform .1s;
    text-decoration: none; color: inherit;
}
/* Vista LISTA (horizontal) */
.vista-lista .centro-card { flex-direction: row; gap: .75rem; padding: .6rem; }
.vista-lista .centro-thumb { flex: 0 0 84px; width: 84px; height: 84px; }
/* Vista GRID (vertical) */
.vista-grid .centro-card { flex-direction: column; gap: .5rem; padding: .5rem; }
.vista-grid .centro-thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.centro-card:hover, .centro-card.activa {
    border-color: var(--ue-ocean);
    box-shadow: 0 6px 18px rgba(11,95,165,.15);
}
.centro-card.activa { transform: translateY(-1px); }
.centro-thumb {
    object-fit: cover; border-radius: .5rem; background: #eef2f6;
}
.centro-body { min-width: 0; flex: 1; }
.centro-nombre { font-weight: 600; font-size: .98rem; line-height: 1.2; margin: 0 0 .15rem; }
.centro-org { font-size: .8rem; color: var(--bs-secondary-color); }
.centro-muni { font-size: .82rem; }
.centro-tags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.tag-tipo {
    font-size: .68rem; padding: .1rem .45rem; border-radius: 1rem;
    color: #fff; white-space: nowrap;
}
.centro-meta { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; font-size: .72rem; }

.estado-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 1rem;
}
.estado-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.sin-resultados { text-align: center; padding: 2rem 1rem; color: var(--bs-secondary-color); }

/* Bloque de contacto dentro del panel */
.contacto-block {
    margin: .5rem .75rem 1rem;
    padding: 1.1rem;
    border-radius: .9rem;
    color: #fff;
    background: linear-gradient(120deg, var(--ue-ocean), var(--ue-teal));
}
.contacto-block .btn-light { color: var(--ue-ocean); font-weight: 600; }

/* ── Anuncios (home) ─────────────────────────────────────────────────────── */
.anuncios-home { margin: .25rem .75rem 1.25rem; }
.anuncios-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 768px) { .anuncios-grid { grid-template-columns: repeat(4, 1fr); } }
.anuncio-thumb {
    border: 1px solid var(--bs-border-color); background: var(--bs-body-bg);
    border-radius: .6rem; padding: 0; overflow: hidden; cursor: pointer; text-align: left;
    display: flex; flex-direction: column;
    transition: box-shadow .15s, border-color .15s;
}
.anuncio-thumb:hover { border-color: var(--ue-ocean); box-shadow: 0 6px 16px rgba(11,95,165,.15); }
.anuncio-thumb-img {
    display: block; width: 100%; aspect-ratio: 1 / 1;
    background-size: cover; background-position: center; background-color: #eef2f6; position: relative;
}
.anuncio-pin {
    position: absolute; top: 6px; left: 6px; background: #E0A800; color: #fff;
    width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .7rem;
}
.anuncio-thumb-title {
    padding: .4rem .5rem; font-size: .78rem; font-weight: 600; line-height: 1.2;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.anuncio-vertodos {
    border: 1px dashed var(--bs-border-color); border-radius: .6rem;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
    text-decoration: none; color: var(--ue-ocean); font-weight: 600; font-size: .82rem;
    background: var(--bs-tertiary-bg);
}
.anuncio-vertodos:hover { color: var(--ue-navy); background: var(--bs-secondary-bg); }

/* Texto del popup de anuncio (contenido del editor) */
.anuncio-texto { line-height: 1.55; }
.anuncio-texto :last-child { margin-bottom: 0; }
.anuncio-texto ul, .anuncio-texto ol { padding-left: 1.2rem; }

/* Editor WYSIWYG (Quill) */
.editor-wysiwyg { min-height: 150px; background: var(--bs-body-bg); }
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--bs-border-color); }
.ql-container.ql-snow { border-bottom-left-radius: .375rem; border-bottom-right-radius: .375rem; font-size: 1rem; }
.ql-toolbar.ql-snow { border-top-left-radius: .375rem; border-top-right-radius: .375rem; }
[data-bs-theme="dark"] .ql-snow .ql-stroke { stroke: var(--bs-body-color); }
[data-bs-theme="dark"] .ql-snow .ql-picker { color: var(--bs-body-color); }
[data-bs-theme="dark"] .ql-editor { color: var(--bs-body-color); }

/* ── Marcadores Leaflet ─────────────────────────────────────────────────── */
.ue-marker {
    width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
    display: flex; align-items: center; justify-content: center;
}
.ue-marker i { transform: rotate(45deg); color: #fff; font-size: .8rem; }
.ue-marker.activa { outline: 3px solid rgba(11,95,165,.4); }
.leaflet-popup-content { margin: .6rem .8rem; }
.leaflet-popup-content .pop-nombre { font-weight: 600; }
/* Leaflet reescribe el color de los <a>; forzamos el texto blanco del botón */
.leaflet-popup-content a.btn-primary,
.leaflet-popup-content a.btn-primary:hover,
.leaflet-popup-content a.btn-primary:focus {
    color: #fff;
    text-decoration: none;
}

/* ── Botón flotante WhatsApp ────────────────────────────────────────────── */
.ue-fab {
    position: fixed; right: 16px; bottom: 16px; z-index: 1040;
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--ue-wa); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; box-shadow: 0 6px 18px rgba(0,0,0,.28);
    text-decoration: none; transition: transform .12s;
}
.ue-fab:hover { color: #fff; transform: scale(1.06); }

/* ── Flash flotante (no altera el layout de alto fijo) ──────────────────── */
.ue-flash {
    position: fixed; top: calc(var(--nav-h) + 8px); left: 50%; transform: translateX(-50%);
    z-index: 1050; max-width: 92%; width: 460px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.ue-footer {
    background: var(--bs-tertiary-bg);
    border-top: 3px solid transparent; border-image: var(--ue-grad) 1;
}

/* ── Páginas de contenido (detalle, acerca, aliados) ────────────────────── */
.page-wrap { max-width: 960px; }
.detalle-hero {
    border-radius: 1rem; overflow: hidden;
    background: #eef2f6; aspect-ratio: 16 / 8;
}
.detalle-hero img { width: 100%; height: 100%; object-fit: cover; }
.galeria-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .5rem; cursor: pointer; }
.mini-mapa { height: 200px; border-radius: .75rem; }

/* Perfil más compacto en móvil */
@media (max-width: 575.98px) {
    .detalle-hero { aspect-ratio: 16 / 7; }
    .mini-mapa { height: 160px; }
    .ue-footer { margin-top: 1.5rem !important; padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .ue-footer .ue-logo-footer { height: 32px; }
    .ue-footer hr { margin-top: .75rem; margin-bottom: .75rem; }
}

/* ── Admin ──────────────────────────────────────────────────────────────── */
.admin-shell { min-height: calc(100dvh - var(--nav-h)); }
.admin-sidebar .nav-link { color: var(--bs-body-color); border-radius: .5rem; }
.admin-sidebar .nav-link.activo { background: var(--ue-ocean); color: #fff; }
.admin-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: .4rem; }
#adminMapa { height: 300px; border-radius: .5rem; }

/* Dark theme: ajustes puntuales */
[data-bs-theme="dark"] .ue-navbar { box-shadow: 0 2px 10px rgba(0,0,0,.4); }
[data-bs-theme="dark"] #mapa { background: #1a1d21; }
[data-bs-theme="dark"] .centro-thumb { background: #2a2f34; }
