/* =========================================
   BUSCADOR UNIVERSAL + ACCESO RAPIDO
   Sección debajo del carrusel
   ========================================= */

/* ====== CONTENEDOR PRINCIPAL ====== */
.bu-section {
    padding: 2rem 0 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.bu-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Override category buttons inside bu-section:
   keep all 7 cards in a single row without crushing the text column */
.bu-section .category-buttons-inline {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.75rem;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
}
.bu-section .category-buttons-inline .category-btn {
    flex: 1 0 165px;
    width: auto;
    min-width: 165px;
    max-width: none;
    scroll-snap-align: start;
}
.bu-section .category-buttons-inline .category-card-layout {
    grid-template-columns: 4.1rem minmax(0, 1fr);
    gap: 0.35rem 0.55rem;
}
.bu-section .category-buttons-inline .category-card-icon-shell {
    width: 4.1rem;
    height: 4.1rem;
}
.bu-section .category-buttons-inline .category-card-icon-shell svg {
    width: 2.4rem;
    height: 2.4rem;
}
.bu-section .category-buttons-inline .category-card-heading,
.bu-section .category-buttons-inline .category-card-subtext {
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}
.bu-section .category-buttons-inline::-webkit-scrollbar {
    height: 8px;
}
.bu-section .category-buttons-inline::-webkit-scrollbar-thumb {
    background: rgba(123, 143, 160, 0.45);
    border-radius: 999px;
}
.bu-section .category-buttons-inline::-webkit-scrollbar-track {
    background: rgba(229, 231, 235, 0.7);
    border-radius: 999px;
}

/* ====== CARD DEL BUSCADOR ====== */
.bu-search-card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 2rem 2rem 1.5rem;
    box-shadow: 0 2px 16px rgba(15, 23, 42, 0.06);
    border: 1px solid #e5e7eb;
    margin-bottom: 2rem;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.bu-search-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.bu-search-title {
    font-size: 1.65rem;
    font-weight: 800;
    color: #1a2332;
    margin: 0;
    line-height: 1.2;
}
.bu-search-title::after {
    content: '';
    display: block;
    width: 48px;
    height: 3px;
    background: #008ea9;
    margin: 10px auto 0;
    border-radius: 2px;
}

/* ====== PASO 1 LABEL ====== */
.bu-control-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.bu-step-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: #008ea9;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.bu-step-chip--muted {
    background: #94a3b8;
}

.bu-control-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

/* ====== INPUT DE BUSQUEDA ====== */
.bu-search-box {
    position: relative;
    margin-bottom: 0;
}

.bu-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.bu-search-input {
    width: 100%;
    padding: 0.85rem 3rem 0.85rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: #1f2937;
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.bu-search-input:focus {
    border-color: #008ea9;
    box-shadow: 0 0 0 3px rgba(0, 142, 169, 0.12);
}
.bu-search-input::placeholder {
    color: #9ca3af;
}

.bu-search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #008ea9;
    font-size: 1.15rem;
    pointer-events: none;
    z-index: 2;
}

.bu-search-clear {
    position: absolute;
    right: 2.8rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.bu-search-clear:hover {
    color: #374151;
}

/* ====== DROPDOWN RESULTADOS ====== */
.bu-search-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 50;
    margin-top: 0.45rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.bu-search-status {
    padding: 0.95rem 1rem;
    font-size: 0.92rem;
    color: #5f6b7a;
}

.bu-search-results {
    max-height: min(22rem, 50vh);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    touch-action: pan-y;
}

.bu-search-result-item {
    display: block;
    width: 100%;
    padding: 0.9rem 1rem;
    border-top: 1px solid rgba(241, 245, 249, 0.95);
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: inherit;
}
.bu-search-result-item:hover {
    background: rgba(0, 142, 169, 0.06);
}

.bu-result-group > .bu-search-result-item:first-of-type {
    border-top: 0;
}

.bu-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.bu-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.bu-result-badge--consulta {
    background: rgba(0, 142, 169, 0.12);
    color: #007a8f;
}

.bu-result-badge--imagen {
    background: rgba(15, 118, 110, 0.12);
    color: #0f766e;
}

.bu-result-badge--laboratorio {
    background: rgba(165, 191, 0, 0.18);
    color: #6d8300;
}

.bu-result-badge--tipo {
    background: rgba(71, 85, 105, 0.08);
    color: #475569;
}

.bu-result-badge--quickaccess {
    background: rgba(99, 102, 241, 0.12);
    color: #4338ca;
}

.bu-result-title {
    display: block;
    color: #111827;
    font-size: 0.97rem;
    font-weight: 800;
    line-height: 1.35;
}

.bu-result-subtitle {
    display: block;
    margin-top: 0.28rem;
    color: #5f6b7a;
    font-size: 0.85rem;
    line-height: 1.45;
}

/* ====== FILTROS (SUCURSALES) ====== */
.bu-filter-group {
    margin-top: 1.25rem;
}

.bu-filter-head {
    margin-bottom: 0.6rem;
}

.bu-filter-heading {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.bu-filter-label-wrap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.bu-filter-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.bu-filter-optional {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.bu-filter-hint {
    font-size: 0.78rem;
    color: #9ca3af;
    font-style: italic;
}

/* ====== PILLS (sucursales) ====== */
.bu-pill-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bu-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.bu-pill:hover {
    border-color: #008ea9;
    color: #008ea9;
    background: #f0fdfa;
}
.bu-pill.active {
    background: #008ea9;
    border-color: #008ea9;
    color: #fff;
}

/* ====== ACCESO RAPIDO TITULO ====== */
.bu-acceso-rapido {
    text-align: center;
    margin-bottom: 1.25rem;
}

/* ====== GRUPOS DE RESULTADOS ====== */
.bu-result-group {
    padding-bottom: 0;
}

.bu-result-group + .bu-result-group {
    border-top: 1px solid rgba(226, 232, 240, 0.9);
}

.bu-result-group-title {
    margin: 0;
    padding: 0.85rem 1rem 0.35rem;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.bu-search-loading {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: #6b7280;
    text-align: center;
    font-style: italic;
}

/* ====== HIDDEN UTILITY ====== */
.bu-section .hidden {
    display: none !important;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 767px) {
    .bu-section {
        padding: 1.25rem 0 0.75rem;
    }
    .bu-search-card {
        padding: 1.25rem 1rem 1rem;
        border-radius: 1rem;
    }
    .bu-search-title {
        font-size: 1.3rem;
    }
    .bu-pill-grid {
        gap: 0.4rem;
    }
    .bu-pill {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
    }
    .bu-container {
        padding: 0 0.75rem;
    }
    .bu-section .category-buttons-inline {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        flex-wrap: unset;
        overflow-x: visible;
    }
    .bu-section .category-buttons-inline .category-btn {
        flex: unset;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        scroll-snap-align: unset;
    }
}

@media (max-width: 639px) {
    body.bu-search-floating-open {
        overflow: hidden;
    }

    .bu-search-box.is-mobile-floating {
        z-index: 180;
    }

    .bu-search-box.is-mobile-floating .bu-control-label {
        display: none;
    }

    .bu-search-box.is-mobile-floating .bu-search-input-wrap {
        position: fixed;
        top: var(--bu-floating-top, 0.5rem);
        left: var(--bu-floating-side-gap, 0.75rem);
        right: var(--bu-floating-side-gap, 0.75rem);
        z-index: 180;
        padding: 0.35rem;
        border-radius: 1.25rem;
        background: rgba(248, 250, 252, 0.94);
        box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
        backdrop-filter: blur(12px);
    }

    .bu-search-box.is-mobile-floating .bu-search-dropdown {
        position: fixed;
        top: calc(
            var(--bu-floating-top, 0.5rem) +
            var(--bu-floating-input-height, 56px) +
            0.7rem
        );
        left: var(--bu-floating-side-gap, 0.75rem);
        right: var(--bu-floating-side-gap, 0.75rem);
        max-height: var(--bu-floating-results-height, 18rem);
        z-index: 179;
        border-radius: 1.1rem;
        box-shadow: 0 22px 40px rgba(15, 23, 42, 0.18);
    }

    .bu-search-box.is-mobile-floating .bu-search-status,
    .bu-search-box.is-mobile-floating .bu-search-results {
        max-height: var(--bu-floating-results-height, 18rem);
    }

    .bu-search-box.is-mobile-floating .bu-search-result-item {
        padding: 0.8rem 0.9rem;
    }

    .bu-search-box.is-mobile-floating .bu-result-group-title {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }

    .bu-search-box.is-mobile-floating .bu-result-group > .bu-search-result-item:first-of-type {
        border-top: 0;
    }
}
