/* =========================================================================
   WireVet · Buscador del menú lateral (filtra los módulos del sidebar)
   Componente autocontenido y scopeado a #sidebar. Soporta tema claro/oscuro
   y funciona en móvil, tablet y escritorio. Solo afecta al sidebar.
   ========================================================================= */

#sidebar .wv-sb-search {
    --wv-sb-accent: #0e7c66;
    --wv-sb-accent-soft: rgba(14, 124, 102, .12);
    position: sticky;
    top: 0;
    z-index: 5;
    list-style: none;
    margin: 0 0 .35rem;
    padding: .7rem .9rem .6rem;
    background: inherit;            /* hereda el fondo del sidebar (claro/oscuro) */
    backdrop-filter: saturate(1.1);
}
/* línea sutil bajo el buscador, separándolo de los módulos */
#sidebar .wv-sb-search::after {
    content: "";
    display: block;
    height: 1px;
    margin-top: .65rem;
    background: linear-gradient(90deg, transparent, rgba(120,130,150,.25) 18%, rgba(120,130,150,.25) 82%, transparent);
}

#sidebar .wv-sb-search__box {
    position: relative;
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #f1f3f7;
    border: 1px solid #e2e6ee;
    border-radius: 11px;
    padding: 0 .5rem 0 .7rem;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
#sidebar .wv-sb-search__box:focus-within {
    background: #fff;
    border-color: var(--wv-sb-accent);
    box-shadow: 0 0 0 3px var(--wv-sb-accent-soft);
}

#sidebar .wv-sb-search__icon {
    font-size: .9rem;
    color: #8a93a6;
    flex: none;
    transition: color .16s ease;
}
#sidebar .wv-sb-search__box:focus-within .wv-sb-search__icon { color: var(--wv-sb-accent); }

#sidebar .wv-sb-search__input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #2a3142;
    font-size: .9rem;
    line-height: 1.2;
    padding: .58rem 0;
    font-family: inherit;
}
#sidebar .wv-sb-search__input::placeholder { color: #9aa3b4; }

#sidebar .wv-sb-search__clear {
    flex: none;
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #8a93a6;
    cursor: pointer;
    font-size: .85rem;
    transition: background .15s, color .15s;
}
#sidebar .wv-sb-search__clear:hover { background: #e4574c1a; color: #e4574c; }
#sidebar .wv-sb-search.is-filled .wv-sb-search__clear { display: inline-flex; }

/* contador de coincidencias */
#sidebar .wv-sb-search__count {
    display: none;
    margin-top: .5rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: #6b7488;
    padding-left: .25rem;
}
#sidebar .wv-sb-search.is-filled .wv-sb-search__count { display: block; }

/* mensaje "sin resultados" */
#sidebar .wv-sb-noresults {
    display: none;
    list-style: none;
    margin: .4rem .6rem;
    padding: 1.2rem .8rem;
    text-align: center;
    color: #8a93a6;
    font-size: .82rem;
    border: 1px dashed #d7dbe6;
    border-radius: 12px;
}
#sidebar .wv-sb-noresults.is-visible { display: block; }
#sidebar .wv-sb-noresults i { display: block; font-size: 1.4rem; margin-bottom: .4rem; opacity: .6; }
#sidebar .wv-sb-noresults b { color: #5a6276; }

/* coincidencia: realce sutil del módulo encontrado */
#sidebar .nav-item.wv-sb-hit > .nav-link { background: var(--wv-sb-accent-soft); border-radius: 8px; }

/* fuerza la apertura del submenú durante la búsqueda, sin tocar Bootstrap collapse */
#sidebar .collapse.wv-sb-force { display: block !important; }

/* oculta elementos filtrados */
#sidebar .wv-sb-hidden { display: none !important; }

/* ---- Tema oscuro ---- */
body.dark #sidebar .wv-sb-search__box { background: #2a3042; border-color: #3a4153; }
body.dark #sidebar .wv-sb-search__box:focus-within { background: #232838; }
body.dark #sidebar .wv-sb-search__input { color: #e7ebf3; }
body.dark #sidebar .wv-sb-search__input::placeholder { color: #7b8398; }
body.dark #sidebar .wv-sb-noresults { border-color: #3a4153; color: #8a93a6; }
body.dark #sidebar .wv-sb-search__count { color: #9aa3b4; }

/* ---- Modo minimizado (icon-only): ocultar el buscador salvo al expandir por hover ---- */
/* Sidebar colapsado (icon-only): mostrar SOLO la lupa centrada, permanente.
   Al pasar el mouse (#sidebar:hover lo expande) reaparece el buscador completo,
   porque las reglas :not(:hover) dejan de aplicar. */
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search {
    padding: .7rem 0 .6rem;
}
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search::after {
    display: none;
}
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search__box {
    justify-content: center;
    gap: 0;
    padding: .5rem 0;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    cursor: pointer;
}
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search__input,
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search__clear,
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search__count {
    display: none;
}
body.sidebar-icon-only #sidebar:not(:hover) .wv-sb-search__icon {
    font-size: 1.15rem;
    color: var(--wv-sb-accent);
}

/* ---- Responsive: evitar zoom de iOS y dar área táctil cómoda ---- */
@media (max-width: 991px) {
    #sidebar .wv-sb-search__input { font-size: 16px; padding: .62rem 0; }
    #sidebar .wv-sb-search { padding: .8rem .9rem .65rem; }
}
