/* =====================================================================
   PORTAL PÚBLICO · Hoja de estilos
   Tema: Azul Francia · Glassmorphism ligero · Mobile First
   ===================================================================== */

/* ---------- 1. Variables de diseño (design tokens) ---------- */
:root {
    /* Paleta principal */
    --azul-francia:   #0353A4;
    --azul-vivo:      #2A77D4;
    --azul-claro:     #E8F1FC;
    --azul-profundo:  #022B5E;

    --blanco:         #FFFFFF;
    --gris-claro:     #F4F6FA;
    --gris-borde:     #E3E8F0;
    --gris-texto:     #5B6472;
    --negro-texto:    #111827;

    --verde:          #16A34A;
    --rojo:           #DC2626;

    /* Glassmorphism */
    --glass-bg:       rgba(255, 255, 255, 0.72);
    --glass-border:   rgba(255, 255, 255, 0.6);
    --glass-blur:     blur(18px) saturate(160%);

    /* Sombras suaves */
    --sombra-sm: 0 2px 8px rgba(3, 83, 164, 0.08);
    --sombra-md: 0 8px 24px rgba(3, 83, 164, 0.12);
    --sombra-lg: 0 16px 48px rgba(2, 43, 94, 0.18);

    /* Radios */
    --radio-sm: 12px;
    --radio-md: 18px;
    --radio-lg: 26px;

    /* Transiciones */
    --t-rapida: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --t-media:  0.32s cubic-bezier(0.4, 0, 0.2, 1);

    /* Tipografía */
    --fuente-display: 'Sora', system-ui, sans-serif;
    --fuente-cuerpo:  'Manrope', system-ui, sans-serif;

    --panel-ancho: 400px;
}

/* ---------- 2. Reset básico ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--fuente-cuerpo);
    color: var(--negro-texto);
    -webkit-font-smoothing: antialiased;
    background: var(--gris-claro);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }

/* ---------- 3. Estructura general ---------- */
.app {
    position: relative;
    display: flex;
    height: 100dvh;
    width: 100vw;
}

/* ---------- 4. Mapa ---------- */
.mapa-wrap {
    position: relative;
    flex: 1;
    height: 100%;
}
#mapa { position: absolute; inset: 0; }

/* Controles flotantes del mapa */
.map-overlay {
    position: absolute;
    right: 16px;
    bottom: 32px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.map-btn {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: var(--azul-francia);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    box-shadow: var(--sombra-md);
    transition: transform var(--t-rapida), background var(--t-rapida);
}
.map-btn:hover { transform: scale(1.08); background: var(--blanco); }
.map-btn:active { transform: scale(0.96); }

/* ---------- 5. Panel lateral (glassmorphism) ---------- */
.panel {
    position: relative;
    z-index: 10;
    width: var(--panel-ancho);
    max-width: 90vw;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--sombra-lg);
    transition: transform var(--t-media);
}

.panel__header {
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--gris-borde);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand__logo {
    width: 46px; height: 46px;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
}
.brand__dot {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--azul-vivo);
    box-shadow: 0 0 0 5px rgba(42, 119, 212, 0.18);
    flex-shrink: 0;
}
.brand__title {
    font-family: var(--fuente-display);
    font-size: 1.32rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--azul-profundo);
    line-height: 1.1;
}
.brand__subtitle { font-size: 0.82rem; color: var(--gris-texto); margin-top: 2px; }

/* Buscador */
.panel__search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio-sm);
    color: var(--gris-texto);
    transition: border-color var(--t-rapida), box-shadow var(--t-rapida);
}
.panel__search:focus-within {
    border-color: var(--azul-vivo);
    box-shadow: 0 0 0 3px rgba(42, 119, 212, 0.15);
}
.panel__search input {
    flex: 1; border: none; outline: none; background: none;
    font-size: 0.92rem; color: var(--negro-texto);
}

/* Lista scrollable */
.panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--azul-vivo) transparent;
}
.panel__list::-webkit-scrollbar { width: 7px; }
.panel__list::-webkit-scrollbar-thumb {
    background: rgba(42, 119, 212, 0.4); border-radius: 4px;
}

.panel__footer {
    padding: 12px 22px;
    font-size: 0.8rem;
    color: var(--gris-texto);
    border-top: 1px solid var(--gris-borde);
    text-align: center;
}
.panel__footer span { font-weight: 700; color: var(--azul-francia); }

/* ---------- 6. Tarjeta de sucursal ---------- */
.card {
    flex-shrink: 0;            /* no se encoge: evita que se recorten los botones */
    background: var(--blanco);
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio-md);
    overflow: hidden;
    box-shadow: var(--sombra-sm);
    transition: transform var(--t-rapida), box-shadow var(--t-rapida), border-color var(--t-rapida);
    animation: aparecer var(--t-media) both;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--sombra-md);
    border-color: rgba(42, 119, 212, 0.35);
}

.card__foto {
    position: relative;
    height: 132px;
    background: linear-gradient(135deg, var(--azul-claro), #d6e6fb);
    overflow: hidden;
    cursor: pointer;
}
.card__foto img { width: 100%; height: 100%; object-fit: cover; }
.card__foto .sin-foto {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    color: var(--azul-vivo);
    font-family: var(--fuente-display);
    font-weight: 700; font-size: 2.4rem;
    opacity: 0.5;
}

.card__estado {
    position: absolute;
    top: 10px; left: 10px;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    font-size: 0.7rem; font-weight: 700;
    border-radius: 999px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    color: var(--verde);
}
.card__estado::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: var(--verde);
}

.card__body { padding: 14px 16px 16px; }
.card__nombre {
    font-family: var(--fuente-display);
    font-size: 1.05rem; font-weight: 700;
    color: var(--azul-profundo);
    letter-spacing: -0.01em;
}
.card__ciudad {
    display: inline-block; margin-top: 2px;
    font-size: 0.78rem; font-weight: 600;
    color: var(--azul-vivo);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.card__dato {
    display: flex; align-items: flex-start; gap: 8px;
    margin-top: 9px;
    font-size: 0.85rem; color: var(--gris-texto); line-height: 1.4;
}
.card__dato svg { flex-shrink: 0; margin-top: 2px; color: var(--azul-vivo); }

.card__acciones {
    display: flex;
    flex-direction: column;   /* apilados: nunca se recortan en paneles angostos */
    gap: 9px;
    margin-top: 15px;
}

/* Botones */
.btn {
    width: 100%;
    min-width: 0;             /* evita el desbordamiento clásico de flexbox */
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px 12px;
    font-size: 0.85rem; font-weight: 700;
    border-radius: var(--radio-sm);
    box-sizing: border-box;
    white-space: nowrap;
    transition: transform var(--t-rapida), filter var(--t-rapida), box-shadow var(--t-rapida);
}
.btn:active { transform: scale(0.97); }
.btn--mapa {
    color: var(--blanco);
    background: linear-gradient(135deg, var(--azul-vivo), var(--azul-francia));
    box-shadow: 0 4px 12px rgba(3, 83, 164, 0.3);
}
.btn--mapa:hover { filter: brightness(1.08); box-shadow: 0 6px 16px rgba(3, 83, 164, 0.4); }
.btn--wa {
    color: var(--blanco);
    background: linear-gradient(135deg, #25D366, #128C7E);
    box-shadow: 0 4px 12px rgba(18, 140, 126, 0.3);
}
.btn--wa:hover { filter: brightness(1.06); }

/* ---------- 7. Popup del mapa ---------- */
.mapboxgl-popup-content {
    padding: 0 !important;
    border-radius: var(--radio-md) !important;
    overflow: hidden;
    box-shadow: var(--sombra-lg) !important;
    font-family: var(--fuente-cuerpo);
    min-width: 250px;
}
.popup__foto { height: 120px; background: var(--azul-claro); }
.popup__foto img { width: 100%; height: 100%; object-fit: cover; }
.popup__body { padding: 13px 15px 15px; }
.popup__nombre {
    font-family: var(--fuente-display);
    font-size: 1.05rem; font-weight: 700; color: var(--azul-profundo);
}
.popup__ciudad { font-size: 0.75rem; font-weight: 600; color: var(--azul-vivo); text-transform: uppercase; }
.popup__dir { font-size: 0.84rem; color: var(--gris-texto); margin-top: 6px; }
.popup__btn {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    width: 100%; margin-top: 12px; padding: 10px;
    font-size: 0.85rem; font-weight: 700;
    color: var(--blanco);
    background: linear-gradient(135deg, var(--azul-vivo), var(--azul-francia));
    border-radius: var(--radio-sm);
    text-decoration: none;
    transition: filter var(--t-rapida);
}
.popup__btn:hover { filter: brightness(1.08); }
.mapboxgl-popup-close-button {
    font-size: 1.4rem !important; color: var(--blanco) !important;
    right: 6px !important; top: 4px !important; z-index: 2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Marcador personalizado */
.marcador {
    width: 38px; height: 38px;
    cursor: pointer;
    transition: transform var(--t-rapida);
}
.marcador:hover { transform: scale(1.18) translateY(-2px); }
.marcador--img { cursor: pointer; transition: transform var(--t-rapida); }
.marcador--img img {
    width: 44px; height: auto;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
}
.marcador--img:hover { transform: scale(1.15) translateY(-2px); }

/* ---------- 8. Estados auxiliares ---------- */
.estado-carga, .estado-vacio {
    padding: 40px 20px; text-align: center;
    color: var(--gris-texto); font-size: 0.9rem;
}

/* ---------- 9. Botón toggle (móvil) ---------- */
.toggle-panel {
    display: none;
    position: absolute;
    top: 16px; left: 16px;
    z-index: 20;
    width: 46px; height: 46px;
    place-items: center;
    color: var(--azul-francia);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radio-sm);
    box-shadow: var(--sombra-md);
}

/* ---------- 10. Animaciones ---------- */
@keyframes aparecer {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 11. RESPONSIVE ---------- */

/* Tablets */
@media (max-width: 900px) {
    :root { --panel-ancho: 340px; }
}

/* Celulares: el panel se vuelve un cajón deslizable sobre el mapa */
@media (max-width: 680px) {
    .toggle-panel { display: grid; }

    .panel {
        position: absolute;
        top: 0; left: 0;
        width: 88vw;
        max-width: 380px;
        transform: translateX(-105%);
        border-right: none;
        border-radius: 0 var(--radio-lg) var(--radio-lg) 0;
    }
    .panel.abierto { transform: translateX(0); }

    .map-overlay { bottom: 24px; right: 14px; }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
    .brand__title { font-size: 1.15rem; }
}
