/* ============================================================
   CLP TOOLBAR PREMIUM V2
   Eleva el toolbar de la categoría al nivel de la home:
   - Glass refinado con gradiente azul→índigo
   - Pills/chips con gradiente premium en estados activos
   - Mejor jerarquía tipográfica y micro-interacciones
   - Mobile: paddings reducidos sin sentirse apretado
   ============================================================ */

/* ====== Tokens del brand (alineados con navbar-tech.css) ====== */
:root {
    --tb-blue:        #3b82f6;
    --tb-indigo:      #6366f1;
    --tb-violet:      #8b5cf6;
    --tb-blue-glow:   rgba(59, 130, 246, 0.30);
    --tb-blue-soft:   rgba(59, 130, 246, 0.10);
    --tb-navy-900:    #0f172a;
    --tb-navy-700:    #1e293b;
    --tb-slate-100:   #f1f5f9;
    --tb-slate-200:   #e2e8f0;
    --tb-slate-500:   #64748b;
    --tb-slate-700:   #334155;
}

/* ============================================================
   1. SORTBAR — Glass refinado con borde gradiente premium
   ============================================================ */
body.clp-theme .clp-sortbar {
    background: rgba(255, 255, 255, 0.78) !important;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid transparent !important;
    /* Borde inferior con gradiente sutil azul→índigo (estilo home) */
    background-image:
        linear-gradient(rgba(255,255,255,0.82), rgba(255,255,255,0.82)),
        linear-gradient(90deg, var(--tb-blue) 0%, var(--tb-indigo) 50%, var(--tb-violet) 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    padding-top: 0.85rem !important;
    padding-bottom: 0.5rem;
    transition: box-shadow 0.25s ease, background 0.25s ease;
}

body.clp-theme .clp-sortbar.is-stuck {
    background: rgba(255, 255, 255, 0.92) !important;
    box-shadow:
        0 1px 0 rgba(59, 130, 246, 0.10),
        0 8px 24px -10px rgba(15, 23, 42, 0.12);
}

body.clp-theme .clp-sortbar-inner {
    align-items: center;
    gap: 0.85rem;
}

/* ============================================================
   2. FILTER TOGGLE — Botón premium con gradiente hover
   ============================================================ */
body.clp-theme .clp-filter-toggle {
    background: #ffffff !important;
    border: 1.5px solid var(--tb-slate-200) !important;
    border-radius: 12px !important;
    color: var(--tb-navy-900) !important;
    font-weight: 600 !important;
    padding: 0.6rem 1.05rem !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
    transition: all 0.22s ease !important;
    position: relative;
    overflow: hidden;
}

body.clp-theme .clp-filter-toggle i.fa-sliders {
    color: var(--tb-blue);
    transition: transform 0.3s ease;
}

body.clp-theme .clp-filter-toggle:hover {
    border-color: var(--tb-blue) !important;
    color: var(--tb-blue) !important;
    box-shadow:
        0 0 0 4px var(--tb-blue-soft),
        0 4px 12px -4px var(--tb-blue-glow) !important;
    transform: translateY(-1px);
}

body.clp-theme .clp-filter-toggle:hover i.fa-sliders {
    transform: rotate(-12deg);
}

/* Badge contador de filtros activos */
body.clp-theme .clp-filter-count {
    background: linear-gradient(135deg, var(--tb-blue), var(--tb-indigo)) !important;
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 2px 6px var(--tb-blue-glow);
}

/* ============================================================
   3. SEARCH INPUT — Glass premium con focus glow azul
   ============================================================ */
body.clp-theme .clp-search--enhanced .clp-search-input {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid var(--cat-clr, #3b82f6) !important;
    border-radius: 12px !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cat-clr, #3b82f6) 12%, transparent) !important;
    transition: all 0.22s ease !important;
}

body.clp-theme .clp-search--enhanced .clp-search-input:hover {
    border-color: rgba(59, 130, 246, 0.35) !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06) !important;
}

body.clp-theme .clp-search--enhanced .clp-search-input:focus {
    border-color: var(--tb-blue) !important;
    box-shadow:
        0 0 0 4px var(--tb-blue-soft),
        0 4px 16px -4px var(--tb-blue-glow) !important;
    background: #fff !important;
}

body.clp-theme .clp-search--enhanced:focus-within .clp-search-ic {
    color: var(--tb-blue) !important;
}

/* ============================================================
   4. RESULTS COUNT — Tipografía con número en gradiente
   ============================================================ */
body.clp-theme .clp-results-count {
    color: var(--tb-slate-500);
    font-size: 0.85rem;
    letter-spacing: 0.2px;
}

body.clp-theme .clp-results-count strong {
    background: linear-gradient(135deg, var(--tb-blue), var(--tb-indigo));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    font-size: 1rem;
    margin-right: 0.25rem;
}

body.clp-theme .clp-sort-label {
    color: var(--tb-slate-500);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* ============================================================
   5. SELECT (ordenar) — Coherente con filter toggle
   ============================================================ */
body.clp-theme .clp-select {
    background: #ffffff !important;
    border: 1.5px solid var(--tb-slate-200) !important;
    border-radius: 12px !important;
    color: var(--tb-navy-900) !important;
    font-weight: 600 !important;
    padding: 0.6rem 2.4rem 0.6rem 1rem !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
    transition: all 0.22s ease !important;
}

body.clp-theme .clp-select:hover,
body.clp-theme .clp-select:focus {
    border-color: var(--tb-blue) !important;
    box-shadow:
        0 0 0 4px var(--tb-blue-soft),
        0 4px 12px -4px var(--tb-blue-glow) !important;
}

body.clp-theme .clp-select-caret {
    color: var(--tb-blue);
}

/* ============================================================
   6. PRESET CHIPS — Glass elegante, gradiente cuando activos
   ============================================================ */
body.clp-theme .clp-presets-row {
    padding-top: 0.55rem;
    padding-bottom: 0.4rem;
}

body.clp-theme .clp-presets {
    gap: 0.5rem;
    padding: 0.15rem 0.05rem 0.4rem;
}

body.clp-theme .clp-preset {
    background: #ffffff !important;
    border: 1.5px solid var(--tb-slate-200) !important;
    border-radius: 100px !important;
    color: var(--tb-slate-700) !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    padding: 0.45rem 1rem !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
}

body.clp-theme .clp-preset i {
    color: var(--tb-blue);
    transition: transform 0.3s ease;
    font-size: 0.78rem;
    margin-right: 0.25rem;
}

body.clp-theme .clp-preset:hover {
    border-color: var(--tb-blue) !important;
    color: var(--tb-blue) !important;
    background: linear-gradient(135deg, rgba(59,130,246,0.06), rgba(99,102,241,0.04)) !important;
    box-shadow:
        0 0 0 3px var(--tb-blue-soft),
        0 4px 10px -3px var(--tb-blue-glow);
    transform: translateY(-1px);
}

body.clp-theme .clp-preset:hover i {
    transform: scale(1.15);
}

body.clp-theme .clp-preset[aria-pressed="true"] {
    background: linear-gradient(135deg, var(--tb-blue) 0%, var(--tb-indigo) 100%) !important;
    border-color: transparent !important;
    color: #ffffff !important;
    box-shadow:
        0 4px 14px -2px var(--tb-blue-glow),
        0 0 0 1px rgba(255,255,255,0.4) inset;
}

body.clp-theme .clp-preset[aria-pressed="true"] i {
    color: #ffffff;
}

/* ============================================================
   7. ACTIVE FILTER CHIPS — Premium con X destacado
   ============================================================ */
body.clp-theme .clp-activechips-row {
    padding-top: 0.5rem;
    padding-bottom: 0.55rem;
    background: linear-gradient(180deg, rgba(241,245,249,0.4), transparent);
}

body.clp-theme .clp-activechips-title {
    color: var(--tb-slate-500);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.clp-theme .clp-activechip {
    background: #ffffff !important;
    border: 1.5px solid rgba(59, 130, 246, 0.25) !important;
    color: var(--tb-blue) !important;
    border-radius: 100px !important;
    font-weight: 600 !important;
    font-size: 0.78rem !important;
    padding: 0.35rem 0.4rem 0.35rem 0.85rem !important;
    box-shadow: 0 2px 6px -2px var(--tb-blue-glow);
    transition: all 0.2s ease !important;
}

body.clp-theme .clp-activechip:hover {
    background: linear-gradient(135deg, var(--tb-blue), var(--tb-indigo)) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 4px 12px -2px var(--tb-blue-glow);
}

body.clp-theme .clp-activechip i {
    background: rgba(59, 130, 246, 0.10);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    margin-left: 0.35rem;
    font-size: 0.65rem;
    transition: all 0.2s ease;
}

body.clp-theme .clp-activechip:hover i {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

body.clp-theme .clp-activechip-clear {
    color: var(--tb-slate-500) !important;
    background: transparent !important;
    border: 1.5px dashed var(--tb-slate-200) !important;
    border-radius: 100px;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    padding: 0.35rem 0.85rem !important;
    transition: all 0.2s ease !important;
}

body.clp-theme .clp-activechip-clear:hover {
    color: #ef4444 !important;
    border-color: #ef4444 !important;
    border-style: solid !important;
    background: rgba(239, 68, 68, 0.05) !important;
}

/* ============================================================
   8. SUBCAT STRIP — Pills premium con gradiente activo
   ============================================================ */
body.clp-theme .clp-subcat-strip {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--tb-slate-200);
    padding: 0.7rem 0 !important;
}

body.clp-theme .clp-subcat-pill {
    background: #ffffff !important;
    border: 1.5px solid var(--tb-slate-200) !important;
    border-radius: 100px !important;
    color: var(--tb-slate-700) !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    padding: 0.5rem 1.05rem !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body.clp-theme .clp-subcat-pill:hover {
    border-color: var(--tb-blue) !important;
    color: var(--tb-blue) !important;
    background: linear-gradient(135deg, rgba(59,130,246,0.06), rgba(99,102,241,0.04)) !important;
    box-shadow:
        0 0 0 3px var(--tb-blue-soft),
        0 4px 10px -3px var(--tb-blue-glow);
    transform: translateY(-1px);
}

body.clp-theme .clp-subcat-pill.active {
    background: linear-gradient(135deg, var(--tb-blue) 0%, var(--tb-indigo) 100%) !important;
    border-color: transparent !important;
    color: #ffffff !important;
    box-shadow:
        0 4px 14px -2px var(--tb-blue-glow),
        0 0 0 1px rgba(255,255,255,0.4) inset;
}

body.clp-theme .clp-subcat-pill .clp-subcat-count {
    background: rgba(15, 23, 42, 0.06);
    color: var(--tb-slate-500);
    font-weight: 700;
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 100px;
    margin-left: 0.3rem;
}

body.clp-theme .clp-subcat-pill.active .clp-subcat-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* ============================================================
   9. MOBILE — < 992px: paddings reducidos sin verse apretado
   ============================================================ */
@media (max-width: 991px) {
    body.clp-theme .clp-sortbar {
        padding-top: 0.6rem !important;
        padding-bottom: 0.35rem;
        background: rgba(255, 255, 255, 0.96) !important;
    }

    body.clp-theme .clp-sortbar-inner {
        flex-wrap: wrap;
        gap: 0.5rem !important;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    body.clp-theme .clp-sortbar-left {
        flex: 1 1 100%;
        gap: 0.55rem !important;
        order: 1;
    }

    body.clp-theme .clp-sortbar-right {
        flex: 1 1 100%;
        order: 2;
        justify-content: space-between;
        gap: 0.5rem !important;
    }

    /* Filter toggle compacto pero accesible */
    body.clp-theme .clp-filter-toggle {
        padding: 0.55rem 0.85rem !important;
        font-size: 0.85rem !important;
        flex-shrink: 0;
    }

    /* Search ocupa todo el espacio restante en su fila */
    body.clp-theme .clp-search--enhanced {
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
    }

    body.clp-theme .clp-search--enhanced .clp-search-input {
        height: 40px;
        padding: 0 38px 0 38px !important;
        font-size: 0.88rem !important;
    }

    /* Resultados + ordenar en una línea */
    body.clp-theme .clp-results-count {
        flex: 0 0 auto;
        font-size: 0.8rem !important;
    }
    body.clp-theme .clp-results-count strong {
        font-size: 0.95rem !important;
    }
    body.clp-theme .clp-sort-label {
        display: none !important;
    }
    body.clp-theme .clp-select-wrap {
        flex: 1 1 auto;
        min-width: 0;
    }
    body.clp-theme .clp-select {
        width: 100%;
        max-width: none;
        min-width: 0 !important;
        padding: 0.55rem 2.2rem 0.55rem 0.85rem !important;
        font-size: 0.83rem !important;
    }

    /* Preset chips: scroll horizontal sin saltos visuales */
    body.clp-theme .clp-presets-row {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        padding-top: 0.4rem !important;
    }
    body.clp-theme .clp-presets {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0.15rem 0 0.5rem !important;
        gap: 0.45rem !important;
        scroll-snap-type: x proximity;
        /* Fade en los bordes para sugerir scroll */
        mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
        -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
    }
    body.clp-theme .clp-presets::-webkit-scrollbar { display: none; }
    body.clp-theme .clp-preset {
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 0.42rem 0.85rem !important;
        font-size: 0.78rem !important;
    }
    body.clp-theme .clp-preset i {
        font-size: 0.72rem;
    }

    /* Active filter chips */
    body.clp-theme .clp-activechips-row {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
    }
    body.clp-theme .clp-activechips-title {
        flex: 1 1 100%;
        margin-bottom: 0.2rem;
    }
    body.clp-theme .clp-activechip,
    body.clp-theme .clp-activechip-clear {
        font-size: 0.75rem !important;
        padding: 0.32rem 0.75rem !important;
    }

    /* Subcat strip: scroll horizontal con fade */
    body.clp-theme .clp-subcat-strip {
        padding: 0.55rem 0 !important;
    }
    body.clp-theme .clp-subcat-pills {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding: 0.15rem 1rem 0.45rem !important;
        gap: 0.45rem !important;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -ms-overflow-style: none;
        mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
        -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
    }
    body.clp-theme .clp-subcat-pills::-webkit-scrollbar { display: none; }
    body.clp-theme .clp-subcat-pill {
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 0.45rem 0.95rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
    }
    body.clp-theme .clp-subcat-pill .clp-subcat-count {
        font-size: 0.65rem;
        padding: 0.05rem 0.4rem;
    }
}

/* ============================================================
   10. MOBILE COMPACTO — < 480px: aún más ajustado
   ============================================================ */
@media (max-width: 480px) {
    body.clp-theme .clp-sortbar-inner {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
        gap: 0.4rem !important;
    }
    body.clp-theme .clp-filter-toggle {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.82rem !important;
    }
    body.clp-theme .clp-filter-toggle i.fa-sliders {
        margin-right: 0.2rem;
    }
    body.clp-theme .clp-search--enhanced .clp-search-input {
        height: 38px;
        padding: 0 34px 0 34px !important;
        font-size: 0.85rem !important;
    }
    body.clp-theme .clp-search-ic {
        font-size: 0.85rem;
        left: 12px;
    }
    body.clp-theme .clp-presets-row,
    body.clp-theme .clp-activechips-row {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }
    body.clp-theme .clp-subcat-pills {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }
}
