/**
 * Algolia InstantSearch — Premium UI
 * Búsqueda Global ConexiónLocal26 (Glassmorphism + Dual Layout)
 */

 :root {
    --search-bg-light: rgba(255, 255, 255, 0.85);
    --search-bg-dark: rgba(18, 18, 18, 0.92);
    --search-panel-light: #ffffff;
    --search-panel-dark: #1e1e1e;
    --search-text-light: #212529;
    --search-text-dark: #f8f9fa;
    --search-border-light: rgba(0, 0, 0, 0.08);
    --search-border-dark: rgba(255, 255, 255, 0.1);
}

/* ================================================================
   Overlay Container & Backdrop
   ================================================================ */
.cl26-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.cl26-search-overlay[hidden] {
    display: none;
}

.cl26-search-overlay__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: auto;
    animation: fadeIn 0.3s ease;
}

/* ================================================================
   Search Panel (The Modal)
   ================================================================ */
.cl26-search-overlay__panel {
    position: relative;
    width: 100%;
    max-width: 800px;
    background: var(--search-panel-light);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    z-index: 1;
    animation: searchSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--search-border-light);
}

/* Dark Mode (Mundial Layout) */
body.cl26-layout-mundial .cl26-search-overlay__panel {
    background: var(--search-panel-dark);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--search-border-dark);
    color: var(--search-text-dark);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes searchSlideDown {
    from { opacity: 0; transform: translateY(-30px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ================================================================
   Header / Input Box
   ================================================================ */
.cl26-search-overlay__header {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--search-border-light);
    gap: 16px;
    background: transparent;
}

body.cl26-layout-mundial .cl26-search-overlay__header {
    border-bottom: 1px solid var(--search-border-dark);
}

.cl26-algolia-searchbox {
    flex: 1;
    position: relative;
}

/* Ícono de lupa absoluto */
.cl26-algolia-searchbox::before {
    content: "search";
    font-family: 'Material Icons';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    color: #999;
    pointer-events: none;
}

body.cl26-layout-mundial .cl26-algolia-searchbox::before {
    color: #777;
}

.cl26-algolia-searchbox input[type="search"] {
    width: 100%;
    border: none;
    font-size: 1.4rem;
    font-weight: 500;
    outline: none;
    padding: 12px 12px 12px 40px; /* Espacio para el icono */
    background: transparent;
    color: var(--search-text-light);
}

body.cl26-layout-mundial .cl26-algolia-searchbox input[type="search"] {
    color: var(--search-text-dark);
}

.cl26-algolia-searchbox input::placeholder {
    color: #adb5bd;
    font-weight: 400;
}

body.cl26-layout-mundial .cl26-algolia-searchbox input::placeholder {
    color: #6c757d;
}

/* Botón cerrar */
.cl26-search-close {
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    color: #333;
}
.cl26-search-close:hover {
    background: rgba(0,0,0,0.1);
    color: #000;
}

body.cl26-layout-mundial .cl26-search-close {
    background: rgba(255,255,255,0.1);
    color: #ddd;
}
body.cl26-layout-mundial .cl26-search-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ================================================================
   Resultados Wrap
   ================================================================ */
.cl26-search-overlay__results {
    overflow-y: auto;
    padding: 16px 0;
    flex: 1;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}
.cl26-search-overlay__results::-webkit-scrollbar { width: 6px; }
.cl26-search-overlay__results::-webkit-scrollbar-track { background: transparent; }
.cl26-search-overlay__results::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }

body.cl26-layout-mundial .cl26-search-overlay__results {
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
body.cl26-layout-mundial .cl26-search-overlay__results::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

/* Section labels (Cabeceras de las categorías) */
.cl26-hits-section:not(:empty) {
    padding: 16px 24px 8px;
}

.cl26-hits-section:not(:empty)::before {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #999;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--search-border-light);
    margin-bottom: 12px;
}

body.cl26-layout-mundial .cl26-hits-section:not(:empty)::before {
    border-bottom-color: var(--search-border-dark);
    color: #777;
}

#cl26-hits-negocios::before  { content: 'Negocios Directorio'; }
#cl26-hits-partidos::before  { content: 'Partidos Mundial'; }
#cl26-hits-noticias::before  { content: 'Noticias y Reportajes'; }

/* ================================================================
   Hit (Fila de resultado)
   ================================================================ */
.cl26-hit {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    cursor: pointer;
}

.cl26-hit:hover {
    background: rgba(0, 0, 0, 0.03);
    text-decoration: none;
    color: inherit;
}

body.cl26-layout-mundial .cl26-hit:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Hit Thumbnails */
.cl26-hit__image {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.cl26-hit__placeholder {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #f1f3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    color: #adb5bd;
}

body.cl26-layout-mundial .cl26-hit__placeholder {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.4);
}

/* Hit Typography */
.cl26-hit__body { flex: 1; min-width: 0; }

.cl26-hit__name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--search-text-light);
}

body.cl26-layout-mundial .cl26-hit__name {
    color: var(--search-text-dark);
}

.cl26-hit__sub {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.cl26-layout-mundial .cl26-hit__sub { color: #adb5bd; }

/* Algolia Highlights (cuando el término coincide) */
.cl26-search-overlay mark, .cl26-search-overlay em.ais-Highlight-highlighted {
    background: rgba(0, 0, 0, 0.08); /* highlight sutil */
    color: inherit;
    font-style: normal;
    border-radius: 4px;
    padding: 0 3px;
    font-weight: 800;
}

body.cl26-layout-mundial .cl26-search-overlay mark, 
body.cl26-layout-mundial .cl26-search-overlay em.ais-Highlight-highlighted {
    background: rgba(255, 255, 255, 0.15);
}


/* ================================================================
   Mobile Adjustments
   ================================================================ */
@media (max-width: 768px) {
    .cl26-search-overlay {
        padding-top: 0;
        align-items: flex-end; /* Sube desde abajo tipo cajón en móvil */
    }
    
    .cl26-search-overlay__panel {
        border-radius: 24px 24px 0 0;
        max-height: 90vh;
        height: 90vh; /* Para llenar la pantalla mejor */
        border: none;
    }
    
    @keyframes searchSlideDown {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }
}
