/* Buscador .cbFinder  */

:root {
    --cb-navy: #081633;
    --cb-blue: #00a3e3;
    --cb-accent: #2f6bff;
    --cb-text: #0d2054;
    --cb-muted: #6b7280;
    --cb-border: #e4e7ef;
    --cb-chip-bg: #f1f3f7;
    --cb-chip-bg-hover: #e6e9f0;
    --cb-radius: 20px;
    --cb-shadow: 0 1px 3px rgba(13, 32, 84, 0.06), 0 12px 32px rgba(13, 32, 84, 0.08);
    --cb-ring: 0 0 0 4px rgba(47, 107, 255, 0.14);
}

/* ángulo animable para el borde giratorio  */
@property --cb-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

.cbFinder {
    position: relative;
    z-index: 30;
    margin-bottom: 40px;
}

/* .cursosBalanz > div trae flex/wrap/center desde style.css: lo pisamos */
.cursosBalanz > .cbFinder {
    display: block;
    width: calc(100% - 48px);
    max-width: 1140px;
    margin: 0 auto 40px;
}

/* ---------- input ---------- */

.cbFinder__search {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 0 10px 0 22px;
    border-radius: 999px;
    /* el relleno blanco vive en ::before, por encima del halo */
    background: transparent;
    box-shadow: 0 1px 2px rgba(13, 32, 84, 0.06), 0 6px 16px rgba(63, 99, 232, 0.12);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

/* relleno blanco sólido + borde (padding-box / border-box):
   fino y quieto en reposo, gira al abrir */
.cbFinder__search::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border: 1.5px solid transparent;
    border-radius: inherit;
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(rgba(13, 32, 85, 0.14), rgba(13, 32, 85, 0.14)) border-box;
    pointer-events: none;
}

/* halo difuso que acompaña el giro */
.cbFinder__search::after {
    content: "";
    position: absolute;
    inset: -4px;
    z-index: -2;
    border-radius: inherit;
    background: conic-gradient(
        from var(--cb-angle),
        transparent 0%,
        transparent 60%,
        rgba(0, 163, 227, 0.35) 80%,
        rgba(13, 32, 85, 0.25) 90%,
        transparent 100%
    );
    filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.cbFinder__search:hover {
    box-shadow: 0 2px 4px rgba(13, 32, 85, 0.08), 0 10px 24px rgba(13, 32, 85, 0.16);
}

.cbFinder.is-open .cbFinder__search {
    box-shadow: 0 2px 4px rgba(13, 32, 85, 0.08), 0 12px 32px rgba(13, 32, 85, 0.2);
}

.cbFinder.is-open .cbFinder__search::before {
    background:
        linear-gradient(#fff, #fff) padding-box,
        conic-gradient(
            from var(--cb-angle),
            transparent 0%,
            transparent 55%,
            var(--cb-blue) 72%,
            var(--cb-text) 88%,
            transparent 100%
        ) border-box,
        linear-gradient(rgba(13, 32, 85, 0.18), rgba(13, 32, 85, 0.18)) border-box;
    animation: cb-border-spin 3.5s linear infinite;
}

.cbFinder.is-open .cbFinder__search::after {
    opacity: 0.7;
    animation: cb-border-spin 3.5s linear infinite;
}

.cbFinder__icon {
    flex: none;
    color: var(--cb-navy);
}

.cbFinder__search input {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    outline: 0;
    font-size: 1.125rem;
    color: var(--cb-text);
}

.cbFinder__search input::placeholder {
    color: #9aa1b0;
}

.cbFinder__clear {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cb-chip-bg);
    color: var(--cb-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.cbFinder__clear:hover {
    background: var(--cb-chip-bg-hover);
    color: var(--cb-navy);
}

.cbFinder__clear[hidden] {
    display: none;
}

.cbFinder__kbd {
    flex: none;
    display: inline-flex;
    gap: 4px;
}

.cbFinder__kbd kbd {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--cb-chip-bg);
    color: var(--cb-muted);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
}

.cbFinder__toggle {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cb-navy);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.cbFinder__toggle:hover {
    background: var(--cb-text);
    transform: scale(1.05);
}

.cbFinder.is-open .cbFinder__toggle {
    background: var(--cb-blue);
}

.cbFinder__badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    border-radius: 999px;
    background: var(--cb-blue);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
}

.cbFinder__badge[hidden] {
    display: none;
}

/* ---------- dropdown ---------- */

.cbFinder__panel {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    padding: 22px 24px 18px;
    background: #fff;
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius);
    box-shadow: 0 4px 8px rgba(13, 32, 84, 0.06), 0 24px 56px rgba(13, 32, 84, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top center;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2), visibility 0s linear 0.25s;
}

.cbFinder.is-open .cbFinder__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2), visibility 0s;
}

/* mientras se escribe, la X reemplaza al atajo */
.cbFinder__clear:not([hidden]) + .cbFinder__kbd {
    display: none;
}

/* ---------- chips ---------- */

.cbFinder__filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px 20px;
}

.cbFinder__group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cbFinder__label {
    flex: none;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cb-muted);
}

.cbFinder__chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cbFinder__divider {
    width: 1px;
    height: 28px;
    background: var(--cb-border);
}

.cbChip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--cb-chip-bg);
    color: var(--cb-text);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}

.cbChip:hover {
    background: var(--cb-chip-bg-hover);
}

.cbChip:active {
    transform: scale(0.97);
}

.cbChip:focus-visible {
    outline: 0;
    box-shadow: var(--cb-ring);
}

.cbChip.is-active {
    background: var(--cb-navy);
    color: #fff;
}

/* barritas de nivel   */
.cbChip.is-active .levelBars i {
    background: #fff;
}

.cbChip.is-active .levelBars.-n1 i:nth-child(-n + 1),
.cbChip.is-active .levelBars.-n2 i:nth-child(-n + 2),
.cbChip.is-active .levelBars.-n3 i:nth-child(-n + 3) {
    background: var(--cb-blue);
}

/* ---------- pie: contador + limpiar ---------- */

.cbFinder__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 24px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--cb-border);
}

.cbFinder__count {
    margin: 0;
    font-size: 0.9rem;
    color: var(--cb-muted);
}

.cbFinder__count strong {
    color: var(--cb-text);
}

.cbFinder__reset {
    padding: 0;
    border: 0;
    background: none;
    color: var(--cb-accent);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.cbFinder__reset:hover {
    text-decoration: underline;
}

.cbFinder__reset[hidden] {
    display: none;
}

@keyframes cb-border-spin {
    to { --cb-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
    .cbFinder.is-open .cbFinder__search::before,
    .cbFinder.is-open .cbFinder__search::after {
        animation: none;
    }

    .cbFinder__panel {
        transition: none;
    }
}

/* ---------- responsive ---------- */

@media (max-width: 991px) {
    .cbFinder__divider {
        display: none;
    }

    .cbFinder__filters {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 767px) {
    .cursosBalanz > .cbFinder {
        width: calc(100% - 32px);
        margin: 16px auto 24px;
    }

    .cbFinder__search {
        height: 54px;
        padding: 0 7px 0 18px;
    }

    .cbFinder__toggle {
        width: 40px;
        height: 40px;
    }

    .cbFinder__panel {
        padding: 16px;
    }

    .cbFinder__search input {
        font-size: 1rem;
    }

    /* el atajo de teclado no aplica en touch */
    .cbFinder__kbd {
        display: none;
    }

    .cbFinder__group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* chips en una sola fila con scroll horizontal */
    .cbFinder__chips {
        flex-wrap: nowrap;
        width: calc(100% + 32px);
        margin: 0 -16px;
        padding: 0 16px 4px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .cbFinder__chips::-webkit-scrollbar {
        display: none;
    }

    .cbChip {
        height: 36px;
        padding: 0 14px;
        font-size: 0.9rem;
    }
}
