/* =========================================================
   Buscador global de la cabecera (public/js/buscadorGlobal.js)
   ========================================================= */

.bg-buscador {
    position: relative;
    flex: 1 1 auto !important;      /* header > * no encoge: este sí */
    min-width: 200px;
    max-width: 580px;
    margin: 0 24px;
}

.bg-caja {
    position: relative;
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 10px 0 38px;
    background: #f3f5f9;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.bg-caja:hover {
    background: #eef1f6;
}

.bg-activo .bg-caja,
.bg-caja:focus-within {
    background: #fff;
    border-color: #f2b394;
    box-shadow: 0 0 0 3px rgba(235, 110, 56, .12);
}

.bg-caja-icono {
    position: absolute;
    left: 12px;
    font-size: 18px;
    color: #8a97ab;
}

.bg-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 14px;
    font-weight: 400;
    color: #2d3748;
}

.bg-input::placeholder {
    color: #97a3b6;
    text-overflow: ellipsis;
}

.bg-input::-webkit-search-cancel-button {
    cursor: pointer;
}

.bg-atajo {
    flex-shrink: 0;
    margin-left: 8px;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 11px;
    color: #8a97ab;
    background: #fff;
    border: 1px solid #dfe4ec;
    border-radius: 5px;
    box-shadow: none;
}

.bg-activo .bg-atajo {
    display: none;
}

.bg-lupa {
    display: none;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #6b7a90;
    font-size: 24px;
}

.bg-lupa:hover {
    background: #f3f5f9;
    color: #eb6e38;
}

/* ---------- Panel de resultados ---------- */

.bg-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: max(100%, 560px);
    max-width: calc(100vw - 32px);
    max-height: min(70vh, 640px);
    overflow-y: auto;
    padding: 8px;
    background: #fff;
    border: 1px solid #eceff4;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
    z-index: 1060;
    white-space: normal;
    scrollbar-width: thin;
}

.bg-pestanas {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 6px 8px;
    border-bottom: 1px solid #f1f3f7;
    margin-bottom: 4px;
}

.bg-pestana {
    padding: 4px 12px;
    border: 1px solid #e4e8ef;
    border-radius: 999px;
    background: #fff;
    font-size: 12.5px;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.bg-pestana span {
    margin-left: 2px;
    color: #9aa6b8;
    font-weight: 400;
}

.bg-pestana:hover {
    border-color: #f2b394;
    color: #eb6e38;
}

.bg-pestana-on,
.bg-pestana-on:hover {
    background: #eb6e38;
    border-color: #eb6e38;
    color: #fff;
}

.bg-pestana-on span {
    color: rgba(255, 255, 255, .85);
}

.bg-detectado {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 8px;
    font-size: 11.5px;
    color: #8a97ab;
}

.bg-detectado span {
    padding: 1px 8px;
    background: #f3f5f9;
    border-radius: 999px;
    color: #4a5568;
    font-weight: 500;
}

.bg-detectado .bg-acotado {
    background: #fdf1eb;
    color: #eb6e38;
}

.bg-grupo + .bg-grupo {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #f1f3f7;
}

.bg-grupo-titulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .7px;
    text-transform: uppercase;
    color: #9aa6b8;
}

.bg-limpiar {
    border: 0;
    background: none;
    padding: 0;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: #9aa6b8;
    cursor: pointer;
}

.bg-limpiar:hover {
    color: #eb6e38;
}

.bg-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #2d3748;
    text-decoration: none;
    cursor: pointer;
}

.bg-item:hover,
.bg-item-activo {
    background: #fdf1eb;
    color: #2d3748;
    text-decoration: none;
}

.bg-item-icono {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f3f5f9;
    color: #6b7a90;
    font-size: 17px;
}

.bg-item-activo .bg-item-icono {
    background: #fff;
    color: #eb6e38;
}

.bg-item-texto {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bg-item-titulo {
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bg-item-sub {
    font-size: 12px;
    color: #8a97ab;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bg-item mark {
    padding: 0;
    background: transparent;
    color: #eb6e38;
    font-weight: 600;
}

.bg-item-enter {
    flex-shrink: 0;
    font-size: 14px;
    color: #eb6e38;
    opacity: 0;
    transform: rotate(90deg);
}

.bg-item-activo .bg-item-enter {
    opacity: .8;
}

.bg-estado {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.bg-estado-verde   { background: #e7f6ec; color: #23824a; }
.bg-estado-ambar   { background: #fff4de; color: #9a6400; }
.bg-estado-rojo    { background: #fdecec; color: #c0392b; }
.bg-estado-gris    { background: #eef0f3; color: #6b7280; }
.bg-estado-naranja { background: #fdf1eb; color: #d35a24; }

.bg-item-owi-img {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #fdf1eb;
}

.bg-cargando,
.bg-sin {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 10px;
    font-size: 13px;
    color: #8a97ab;
}

.bg-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #f2c7b2;
    border-top-color: #eb6e38;
    border-radius: 50%;
    animation: bg-girar .7s linear infinite;
}

@keyframes bg-girar {
    to { transform: rotate(360deg); }
}

/* ---------- Anchos estrechos ---------- */

@media (max-width: 1360px) {
    .bg-buscador {
        margin: 0 14px;
    }

    .bg-atajo {
        display: none;
    }
}

/* Poco sitio: queda solo la lupa; al pulsarla el buscador ocupa todo el ancho */
@media (max-width: 1100px) {
    .bg-buscador {
        flex: 0 0 auto !important;
        min-width: 0;
        margin: 0 4px 0 auto;
    }

    .bg-lupa {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .bg-buscador .bg-caja {
        display: none;
    }

    .bg-buscador.bg-abierto-movil {
        position: fixed;
        top: 8px;
        left: 12px;
        right: 12px;
        max-width: none;
        margin: 0;
        z-index: 1065;
    }

    .bg-buscador.bg-abierto-movil .bg-lupa {
        display: none;
    }

    .bg-buscador.bg-abierto-movil .bg-caja {
        display: flex;
        background: #fff;
        box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
    }

    .bg-buscador.bg-abierto-movil .bg-panel {
        width: 100%;
        max-width: none;
    }
}
