/* ============================================================
   ComBack - App Cliente (userapp) - CSS de la pagina 'establishment'
   Externalizado desde establishment.html (extra_css). Cache-busted con ?v=asset_version.
   ============================================================ */

/* ---- Cover Banner (T21 + T26) ----
       CSS estricto para que la imagen JAMAS se desborde del contenedor.
       Aplicamos contain:strict para aislar el painting/layout dentro del cover. */
    .cover-section {
        position: relative;
        width: 100%;
        height: 60vh;
        max-height: 520px;
        min-height: 340px;
        overflow: hidden !important;
        background: linear-gradient(135deg, var(--cb-magenta) 0%, var(--cb-magenta-dark) 50%, #5E35B1 100%);
        box-sizing: border-box;
        contain: layout paint;  /* aisla el layout del cover del resto del DOM */
    }
    /* Desvanecido inferior: la portada se disuelve en el fondo de la pagina
       para una transicion suave hacia el contenido (sin corte duro). */
    .cover-section::after {
        content: '';
        position: absolute;
        left: 0; right: 0; bottom: 0;
        height: 55%;
        background: linear-gradient(to bottom,
            rgba(0,0,0,0) 0%,
            var(--bg-primary) 94%);
        z-index: 3;
        pointer-events: none;
    }
    /* Slide wrapper: cubre toda la cover-section sin importar safe-area */
    .cover-slide {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }
    .cover-section img,
    .cover-slide img {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: cover !important;
        object-position: center top;
        z-index: 0;
    }
    .cover-section.no-image {
        height: 300px;
        min-height: 300px;
        background:
            radial-gradient(circle at 18% 22%, rgba(255,255,255,0.16), transparent 45%),
            radial-gradient(circle at 82% 65%, rgba(255,255,255,0.10), transparent 50%),
            linear-gradient(135deg, var(--cb-magenta) 0%, var(--cb-magenta-dark) 50%, #5E35B1 100%);
    }
    @media (min-width: 769px) {
        .cover-section { height: 64vh; max-height: 600px; min-height: 380px; }
        .cover-section.no-image { height: 320px; min-height: 320px; }
    }
    .cover-overlay {
        position: absolute;
        bottom: 0; left: 0; right: 0;
        padding: 30px 20px;
        background: linear-gradient(transparent, rgba(0,0,0,0.7));
        color: #fff;
        z-index: 5;  /* por encima del desvanecido inferior (::after, z-index 3) */
    }
    .cover-overlay h1 {
        font-family: 'Playfair Display', serif;
        font-size: 2rem;
        font-weight: 800;
        margin-bottom: 4px;
    }
    .cover-overlay .tagline { font-size: 0.95rem; opacity: 0.85; }
    .cover-dots {
        position: absolute;
        bottom: 12px; left: 50%;
        transform: translateX(-50%);
        display: flex; gap: 8px; z-index: 10;
    }
    .cover-dot {
        width: 8px; height: 8px;
        border-radius: 50%;
        background: rgba(255,255,255,0.5);
        cursor: pointer;
    }
    .cover-dot.active { background: #fff; }

    /* Back button: flotante FIJO arriba-izquierda, siempre visible
       sin importar el scroll. Asi el usuario siempre puede regresar. */
    .back-btn {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        left: 14px;
        width: 40px; height: 40px;
        border-radius: 50%;
        background: rgba(0,0,0,0.55);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        color: #fff;
        border: none;
        font-size: 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 99997; /* por debajo del top-cta-ingresar (99998) */
        text-decoration: none;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        transition: background 0.2s;
    }
    .back-btn:hover { background: rgba(0,0,0,0.75); color: #fff; }

    /* ---- Hero a pantalla completa (desktop) ----
       El nav superior deja de empujar el contenido y flota TRANSPARENTE sobre
       la portada, para que la imagen arranque desde arriba del todo. Al hacer
       scroll el nav se vuelve solido (clase .nav-solid via JS).
       En desktop el back-btn flotante sobra (el nav ya tiene "Inicio" + logo),
       asi que lo ocultamos para que no se monte sobre el logo. */
    @media (min-width: 769px) {
        .back-btn { display: none; }
        body { padding-top: 0 !important; }
        .bottom-nav {
            background: transparent !important;
            border-bottom: none !important;
            box-shadow: none !important;
            transition: background 0.25s, box-shadow 0.25s, border-color 0.25s;
        }
        .bottom-nav .nav-item { color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,0.55); }
        .bottom-nav .nav-item.active { color: #fff; }
        /* Mientras es transparente (sobre la portada oscura) el logo va blanco */
        .bottom-nav:not(.nav-solid) .nav-brand img { filter: none !important; }
        .bottom-nav.nav-solid {
            background: var(--nav-bg) !important;
            border-bottom: 1px solid var(--nav-border) !important;
            box-shadow: var(--shadow-sm) !important;
        }
        .bottom-nav.nav-solid .nav-item { color: var(--nav-inactive); text-shadow: none; }
        .bottom-nav.nav-solid .nav-item.active { color: var(--cb-orange); }
    }

    /* ---- Merchant Profile Card ----
       Va debajo del cover (margin-top positivo) para que el titulo no se
       solape con la imagen y se lea bien sobre fondo solido.
       En desktop, max-width 720 y centrado. */
    .profile-card {
        background: var(--card-bg);
        margin: 40px 16px 0;
        border-radius: 20px;
        padding: 22px 20px;
        position: relative;
        z-index: 5;
        box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    }
    .profile-top {
        display: flex;
        align-items: center;
        gap: 16px;
    }
    /* Logo del comercio: completamente redondo, llena el circulo sin bordes blancos. */
    .profile-logo {
        width: 80px; height: 80px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--cb-orange) 60%, var(--cb-orange-light) 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        box-sizing: border-box;
    }
    /* Logo CUADRADO: llena el circulo (cover, se ve limpio). */
    .profile-logo img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    /* Representacion dinamica para logos RECTANGULARES (horizontal o vertical):
       rectangulo redondeado + fondo transparente (sin el gradiente que choca
       con los colores del logo) + contain para verlo completo. JS agrega la
       clase .logo-rect segun la proporcion real de la imagen. */
    .profile-logo.logo-rect {
        border-radius: 14px;
        background: transparent;
        width: auto;
        min-width: 64px;
        max-width: 150px;
    }
    .profile-logo.logo-rect img { object-fit: contain; }
    .profile-logo span { color:#fff; font-weight:800; font-size:1.9rem; }

    /* Columna derecha: nombre + boton apilados verticalmente */
    .profile-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .profile-name { font-weight: 800; font-size: 1.2rem; color: var(--text-primary); line-height: 1.2; }
    .profile-type { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; margin-top: 2px; }

    .profile-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .profile-actions a {
        flex: 1;
        padding: 10px;
        border-radius: 14px;
        font-size: 0.82rem;
        font-weight: 700;
        text-decoration: none;
        text-align: center;
        transition: all 0.2s;
    }
    .btn-menu-cta {
        background: var(--cb-orange);
        color: #fff;
    }
    .btn-menu-cta:hover { background: var(--cb-orange-dark); color:#fff; text-decoration:none; }
    .btn-wa {
        background: #25D366;
        color: #fff;
    }
    .btn-wa:hover { background: #1fb855; color:#fff; text-decoration:none; }
    .btn-outline {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
    }

    /* ---- Info Section ---- */
    .info-list {
        padding: 20px 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .info-item {
        background: var(--card-bg);
        border-radius: 16px;
        padding: 16px 18px;
        display: flex;
        align-items: flex-start;
        gap: 14px;
        box-shadow: var(--shadow-sm);
    }
    .info-item i {
        font-size: 1.1rem;
        color: var(--cb-orange);
        margin-top: 2px;
        width: 20px;
        text-align: center;
        flex-shrink: 0;
    }
    .info-item-content h6 { font-weight: 700; font-size: 0.85rem; margin: 0 0 4px; color: var(--text-primary); }
    .info-item-content p { font-size: 0.82rem; color: var(--text-secondary); margin: 0; line-height: 1.5; }

    /* ---- About ---- */
    .about-card {
        background: var(--card-bg);
        margin: 0 16px 16px;
        border-radius: 16px;
        padding: 20px;
        box-shadow: var(--shadow-sm);
    }
    .about-card h3 {
        font-family: 'Playfair Display', serif;
        font-size: 1.3rem;
        margin-bottom: 10px;
        color: var(--text-primary);
    }
    .about-card p { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.7; margin: 0; }

    /* ---- Social ---- */
    .social-row {
        display: flex;
        gap: 10px;
        padding: 0 16px 20px;
        flex-wrap: wrap;
    }
    .social-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 18px;
        background: var(--card-bg);
        border-radius: 14px;
        text-decoration: none;
        color: var(--text-secondary);
        font-size: 0.82rem;
        font-weight: 600;
        box-shadow: var(--shadow-sm);
        transition: transform 0.2s;
    }
    .social-btn:hover { transform: translateY(-2px); text-decoration:none; color: var(--text-primary); }
    .social-btn.fb i { color: #1877F2; }
    .social-btn.ig i { color: #E4405F; }
    .social-btn.wa i { color: #25D366; }

    /* ---- Sidebar Banners (inline on mobile) ---- */
    .promo-section { padding: 0 16px 20px; }
    .promo-section .section-label {
        font-size: 0.8rem; font-weight: 700; color: var(--text-secondary);
        text-transform: uppercase; letter-spacing: 0.5px;
        margin-bottom: 10px;
    }
    .promo-scroll {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .promo-scroll::-webkit-scrollbar { display: none; }
    .promo-card {
        flex: 0 0 75%;
        max-width: 280px;
        background: var(--card-bg);
        border-radius: 14px;
        overflow: hidden;
        box-shadow: var(--shadow-sm);
        text-decoration: none;
        color: inherit;
    }
    .promo-card img { width: 100%; height: 140px; object-fit: cover; }
    .promo-card .promo-info { padding: 10px 14px; }
    .promo-card .promo-info h6 { font-size: 0.85rem; font-weight: 700; margin: 0; color: var(--text-primary); }
    .promo-card .promo-info p { font-size: 0.75rem; color: var(--text-secondary); margin: 4px 0 0; }

    /* ---- Popup Modal ---- */
    .popup-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 2000;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    .popup-overlay.hidden { display: none; }
    .popup-card {
        background: var(--card-bg);
        border-radius: 20px;
        overflow: hidden;
        max-width: 380px;
        width: 100%;
        position: relative;
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
        animation: popupIn 0.3s ease;
    }
    @keyframes popupIn {
        from { opacity:0; transform: scale(0.9) translateY(20px); }
        to { opacity:1; transform: scale(1) translateY(0); }
    }
    .popup-card img { width: 100%; max-height: 300px; object-fit: cover; }
    .popup-card .popup-body { padding: 20px; text-align: center; }
    .popup-card .popup-body h4 { font-family: 'Playfair Display', serif; font-size: 1.2rem; margin-bottom: 6px; color: var(--text-primary); }
    .popup-card .popup-body p { color: var(--text-secondary); font-size: 0.85rem; }
    .popup-close {
        position: absolute;
        top: 10px; right: 10px;
        width: 32px; height: 32px;
        border-radius: 50%;
        background: rgba(0,0,0,0.5);
        color: #fff;
        border: none;
        font-size: 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Desktop */
    @media (min-width: 769px) {
        /* (alturas del cover ya definidas arriba en .cover-section + .no-image) */
        .cover-overlay { padding: 40px; }
        .cover-overlay h1 { font-size: 2.4rem; }
        .profile-card { max-width: 720px; margin: -50px auto 0; padding: 26px 28px; }
        .info-list { max-width: 720px; margin: 0 auto; }
        .about-card { max-width: 720px; margin: 0 auto 16px; }
        .social-row { max-width: 720px; margin: 0 auto; padding-bottom: 20px; }
        .promo-section { max-width: 720px; margin: 0 auto; }
        .profile-logo { width: 96px; height: 96px; }
        .profile-name { font-size: 1.5rem; }
    }

    /* ====== SUCURSALES (TARJETAS) ====== */
    .branches-section {
        margin: 0 16px 16px;
    }
    @media (min-width: 769px) {
        .branches-section { max-width: 600px; margin: 0 auto 16px; }
    }
    .branches-header {
        padding: 16px 4px 10px;
    }
    .branches-header h3 {
        margin: 0;
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--text-primary);
    }
    .branches-header p {
        margin: 4px 0 0;
        font-size: 0.85rem;
        color: var(--text-secondary);
    }
    .branches-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .branch-item {
        background: var(--card-bg);
        border-radius: 16px;
        padding: 16px 18px;
        box-shadow: var(--shadow-sm);
        border: 2px solid transparent;
        transition: all 0.2s;
        cursor: pointer;
        position: relative;
    }
    .branch-item:hover {
        border-color: var(--cb-orange);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(113,104,252,0.15);
    }
    .branch-item .name {
        font-weight: 800;
        font-size: 1.05rem;
        color: var(--text-primary);
        margin-bottom: 6px;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .branch-item .name i { color: var(--cb-orange); font-size: 1rem; }
    .branch-item .addr {
        font-size: 0.85rem;
        color: var(--text-secondary);
        margin-bottom: 3px;
        display: flex;
        align-items: flex-start;
        gap: 6px;
    }
    .branch-item .addr i {
        color: var(--text-tertiary);
        font-size: 0.8rem;
        margin-top: 3px;
        flex-shrink: 0;
    }
    .branch-item .city-badge {
        display: inline-block;
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        font-size: 0.72rem;
        padding: 2px 10px;
        border-radius: 10px;
        margin-bottom: 8px;
    }
    .branch-item .actions {
        margin-top: 12px;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .branch-item .btn-mini {
        font-size: 0.82rem;
        font-weight: 600;
        padding: 8px 14px;
        border-radius: 10px;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        transition: all 0.15s;
    }
    .branch-item .btn-mini.enter {
        background: linear-gradient(135deg, var(--cb-orange), var(--cb-orange-dark));
        color: #fff;
        flex: 1;
        justify-content: center;
        font-weight: 700;
        box-shadow: 0 3px 10px rgba(113,104,252,0.3);
    }
    .branch-item .btn-mini.enter:hover { transform: translateY(-1px); color:#fff; }
    /* Tintes translucidos: se ven bien tanto en tema claro como oscuro
       (antes usaban fondos claros fijos que en modo oscuro se veian como
       recuadros/esquinas blancas). */
    .branch-item .btn-mini.phone { background: var(--bg-tertiary); color: var(--text-primary); }
    .branch-item .btn-mini.wa { background: rgba(37,211,102,0.15); color: #25D366; }
    .branch-item .btn-mini.map { background: rgba(66,133,244,0.15); color: #4d90fe; }
    .branch-item .btn-mini:hover { opacity: 0.85; }
