/* Panel lateral de filtros del listado de llantas (filtros_lateral.js).
   >= 1200px: columna a la izquierda que acompaña al bajar, y 3 llantas por fila.
   <  1200px: cajón que sale por la izquierda con el botón flotante "Filtros". */

.phb-zona {
    --phb-rojo: #e2231a;
    --phb-rojo-claro: #fff1f0;
    --phb-texto: #1f2329;
    --phb-gris: #6b7280;
    --phb-borde: #e6e8eb;
    --phb-fondo: #fff;
}

/* Los desplegables de siempre siguen ahí (las búsquedas los leen), pero no se ven */
.phb-lat #filtros-buscador { display: none !important; }

/* ---- Barra de encima del listado: lo filtrado, orden y comparar ---- */
.phb-barra-listado { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.phb-chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 320px; min-height: 34px; align-items: center; }
.phb-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--phb-rojo); border-radius: 16px; background: var(--phb-rojo-claro); color: var(--phb-rojo); font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer; transition: background .15s, color .15s; }
.phb-chip:hover, .phb-chip:focus-visible { background: var(--phb-rojo); color: #fff; outline: none; }
.phb-chip__x { font-size: 17px; line-height: 1; }
.phb-chip--limpiar { border-color: transparent; background: none; color: var(--phb-gris); text-decoration: underline; }
.phb-chip--limpiar:hover, .phb-chip--limpiar:focus-visible { background: none; color: var(--phb-texto); }
.phb-barra-listado #filtros_extra { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; margin: 0; flex: 0 1 auto; }
.phb-barra-listado #filtros_extra > [class*="col-"] { flex: 0 0 auto; max-width: none; width: auto; padding: 0; }
.phb-barra-listado #carOrderby { height: 38px; min-width: 220px; border: 1px solid var(--phb-borde); border-radius: 8px; font-size: 14px; color: var(--phb-texto); }

/* ---- El panel ---- */
.phb-lat { background: var(--phb-fondo); }
.phb-lat__cab { display: flex; align-items: center; gap: 10px; padding: 14px 18px 12px; border-bottom: 1px solid var(--phb-borde); }
.phb-lat__cab-tit { flex: 1 1 auto; margin: 0; font-size: 18px; font-weight: 800; color: var(--phb-texto); text-transform: none; }
.phb-lat__limpiar { border: 0; background: none; color: var(--phb-rojo); font-size: 13px; font-weight: 600; text-decoration: underline; cursor: pointer; visibility: hidden; }
.phb-lat__cerrar { display: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f3f4f6; color: var(--phb-texto); font-size: 22px; line-height: 1; cursor: pointer; }
.phb-lat__cuerpo { padding: 4px 18px 10px; }
.phb-lat__pie { display: none; }

.phb-lat__sec { padding: 14px 0; border-bottom: 1px solid var(--phb-borde); }
.phb-lat__sec:last-child { border-bottom: 0; }
.phb-lat__tit { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 10px; padding: 0; border: 0; background: none; color: var(--phb-texto); font-size: 14px; font-weight: 700; letter-spacing: .02em; text-align: left; text-transform: uppercase; }
.phb-lat__tit--boton { cursor: pointer; }
.phb-lat__tit--boton > span:first-child { flex: 0 0 auto; }
.phb-lat__tit--boton::after { content: ''; flex: 0 0 auto; width: 8px; height: 8px; margin: -4px 4px 0 auto; border-right: 2px solid var(--phb-gris); border-bottom: 2px solid var(--phb-gris); transform: rotate(45deg); transition: transform .2s; }
.phb-lat__sec.is-plegada .phb-lat__tit { margin-bottom: 0; }
.phb-lat__sec.is-plegada .phb-lat__tit--boton::after { transform: rotate(-45deg); margin-top: 0; }
.phb-lat__sec.is-plegada .phb-lat__cont { display: none; }
.phb-lat__resumen { overflow: hidden; color: var(--phb-rojo); font-size: 12px; font-weight: 600; text-overflow: ellipsis; text-transform: none; white-space: nowrap; }

/* Diámetro, ancho, anclaje, PCD */
.phb-lat__pastillas { display: flex; flex-wrap: wrap; gap: 8px; }
.phb-lat__pastilla { min-width: 52px; height: 38px; padding: 0 12px; border: 1.5px solid var(--phb-borde); border-radius: 8px; background: #fff; color: var(--phb-texto); font-size: 14px; font-weight: 700; cursor: pointer; transition: border-color .15s, background .15s, color .15s, transform .1s; }
.phb-lat__pastilla:hover { border-color: var(--phb-rojo); color: var(--phb-rojo); }
.phb-lat__pastilla:active { transform: scale(.96); }
.phb-lat__pastilla.is-on { border-color: var(--phb-rojo); background: var(--phb-rojo); color: #fff; box-shadow: 0 4px 10px -4px rgba(226, 35, 26, .6); }

/* Listas con buscador */
.phb-lat__buscar { width: 100%; height: 36px; margin-bottom: 8px; padding: 0 12px; border: 1px solid var(--phb-borde); border-radius: 8px; font-size: 14px; }
.phb-lat__buscar:focus { border-color: var(--phb-rojo); outline: none; box-shadow: 0 0 0 3px rgba(226, 35, 26, .12); }
.phb-lat__lista { margin: 0; padding: 0; list-style: none; }
.phb-lat__opcion { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--phb-texto); font-size: 14px; text-align: left; cursor: pointer; transition: background .12s; }
.phb-lat__opcion:hover { background: #f5f6f7; }
.phb-lat__opcion::before { content: ''; flex: 0 0 auto; width: 18px; height: 18px; border: 1.5px solid #c4c9cf; border-radius: 50%; background: #fff; transition: border-color .15s, box-shadow .15s; }
.phb-lat__opcion.is-on { background: var(--phb-rojo-claro); color: var(--phb-rojo); font-weight: 700; }
.phb-lat__opcion.is-on::before { border-color: var(--phb-rojo); box-shadow: inset 0 0 0 4px #fff; background: var(--phb-rojo); }
/* Donde se puede elegir más de uno (marca, modelo): casilla cuadrada con su visto */
.phb-lat__opcion--varias::before { border-radius: 4px; }
.phb-lat__opcion--varias.is-on::before { box-shadow: none; background: var(--phb-rojo) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.phb-lat__texto { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.phb-lat__punto { flex: 0 0 auto; width: 18px; height: 18px; border: 1px solid rgba(0, 0, 0, .15); border-radius: 50%; }
/* En Color el propio punto hace de casilla: un aro rojo cuando está elegido */
.phb-lat__opcion--color::before { display: none; }
.phb-lat__opcion--color.is-on .phb-lat__punto { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--phb-rojo); }
.phb-lat__punto--otro { background: conic-gradient(#c62828, #ef6c00, #c8a13a, #2e7d32, #1f4ea3, #c62828); }
.phb-lat__mas { margin: 6px 0 0 10px; padding: 0; border: 0; background: none; color: var(--phb-rojo); font-size: 13px; font-weight: 700; cursor: pointer; }
.phb-lat__mas:hover { text-decoration: underline; }

/* Interruptores */
.phb-lat__switch { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 4px 0; border: 0; background: none; color: var(--phb-texto); font-size: 14px; text-align: left; cursor: pointer; }
.phb-lat__palanca { position: relative; flex: 0 0 auto; width: 42px; height: 24px; border-radius: 12px; background: #d5d9de; transition: background .2s; }
.phb-lat__palanca::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.phb-lat__switch.is-on .phb-lat__palanca { background: var(--phb-rojo); }
.phb-lat__switch.is-on .phb-lat__palanca::after { transform: translateX(18px); }

.phb-lat button:focus-visible { outline: 2px solid var(--phb-rojo); outline-offset: 2px; }

/* Botón flotante y fondo del cajón: solo por debajo de 1200px */
.phb-btn-filtros, .phb-lat-fondo { display: none; }

/* ---- Escritorio ---- */
@media (min-width: 1200px) {
    .phb-zona { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; align-items: start; }
    .phb-lat { position: sticky; top: 100px; max-height: calc(100vh - 116px); overflow-y: auto; border: 1px solid var(--phb-borde); border-radius: 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06); scrollbar-width: thin; }
    .phb-lat__cab { position: sticky; top: 0; z-index: 1; background: var(--phb-fondo); }
    /* 3 llantas por fila con el panel al lado */
    .phb-zona #resultados .products > [class*="col-"] { flex: 0 0 33.3333%; max-width: 33.3333%; }
}

/* ---- Móvil y tablet: cajón ---- */
@media (max-width: 1199.98px) {
    /* Por encima de la cabecera fija del tema (.header-top, z-index 9999) */
    .phb-lat { position: fixed; top: 0; bottom: 0; left: 0; z-index: 10010; display: flex; flex-direction: column; width: 88%; max-width: 380px; transform: translateX(-105%); transition: transform .28s ease; }
    .phb-lat.is-abierto { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .phb-lat__cerrar { display: block; }
    .phb-lat__cuerpo { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .phb-lat__pie { display: block; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--phb-borde); background: #fff; }
    .phb-lat__ver { width: 100%; height: 48px; border: 0; border-radius: 10px; background: var(--phb-rojo); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; }
    .phb-lat-fondo { position: fixed; inset: 0; z-index: 10005; display: block; background: rgba(15, 18, 22, .45); opacity: 0; pointer-events: none; transition: opacity .28s; }
    .phb-lat.is-abierto ~ .phb-lat-fondo, .phb-lat-sin-scroll .phb-lat-fondo { opacity: 1; pointer-events: auto; }
    .phb-lat-sin-scroll, .phb-lat-sin-scroll body { overflow: hidden; }
    .phb-lat-sin-scroll .whatsappDiv, .phb-lat-sin-scroll .phb-btn-filtros { display: none !important; }
    .phb-lat__pastilla { height: 42px; min-width: 56px; }
    .phb-lat__opcion { min-height: 42px; }

    .phb-btn-filtros { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1040; display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 22px; border: 0; border-radius: 23px; background: var(--phb-texto, #1f2329); color: #fff; font-size: 15px; font-weight: 800; box-shadow: 0 8px 20px rgba(0, 0, 0, .3); transform: translateX(-50%); cursor: pointer; }
    .phb-btn-filtros__n { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #e2231a; font-size: 12px; }
    .phb-barra-listado #filtros_extra { width: 100%; }
    .phb-barra-listado #carOrderby { width: 100%; min-width: 0; }
    .phb-barra-listado #filtros_extra > [class*="col-"] { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .phb-lat, .phb-lat-fondo, .phb-lat__palanca, .phb-lat__palanca::after { transition: none; }
}
