/**
 * TECNIGAL — Barra lateral de la tienda.
 *
 * Se aplica sobre .wd-sidebar.sidebar-container, que es el contenedor real que
 * imprime Woodmart. (Las reglas antiguas de .area-sidebar-shop nunca tuvieron
 * efecto porque esa clase no existe en el DOM.)
 */

:root {
	--tg-azul: #001f46;
	--tg-azul-claro: #1e73be;
	--tg-borde: #e6e9ee;
	--tg-texto: #2b3445;
	--tg-suave: #6b7684;
	--tg-fondo-suave: #f5f7fa;
}

/* ---------------------------------------------------------------- estructura */

.wd-sidebar.sidebar-container .widget-area {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.wd-sidebar.sidebar-container .sidebar-widget {
	margin: 0;
	padding: 20px;
	background-color: #fff;
	border: 1px solid var(--tg-borde);
	border-radius: 12px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.wd-sidebar.sidebar-container .sidebar-widget > .widget-title {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 14px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--tg-borde);
	color: var(--tg-azul);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	line-height: 1.3;
}

.wd-sidebar.sidebar-container .sidebar-widget > .widget-title::before {
	content: "";
	flex: 0 0 3px;
	width: 3px;
	height: 14px;
	border-radius: 2px;
	background-color: var(--tg-azul);
}

/* Barra pegajosa solo en escritorio. Sin align-self la columna se estira a la
   altura del listado de productos y position:sticky queda sin efecto. */
@media (min-width: 1025px) {
	.wd-sidebar.sidebar-container {
		align-self: flex-start;
		height: -moz-fit-content;
		height: fit-content;
		position: sticky;
		top: 120px;
		max-height: calc(100vh - 140px);
		overflow-y: auto;
		overscroll-behavior: contain;
		padding-bottom: 4px;
	}

	.wd-sidebar.sidebar-container::-webkit-scrollbar {
		width: 6px;
	}

	.wd-sidebar.sidebar-container::-webkit-scrollbar-thumb {
		border-radius: 3px;
		background-color: #ccd3dd;
	}
}

/* ----------------------------------------------------------------- buscador */

.wd-sidebar .widget_product_search form {
	position: relative;
}

.wd-sidebar .widget_product_search .search-field {
	width: 100%;
	height: 44px;
	padding: 0 44px 0 16px;
	border: 1px solid var(--tg-borde);
	border-radius: 999px;
	background-color: var(--tg-fondo-suave);
	color: var(--tg-texto);
	font-size: 14px;
	transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}

.wd-sidebar .widget_product_search .search-field:focus {
	border-color: var(--tg-azul-claro);
	background-color: #fff;
	box-shadow: 0 0 0 3px rgba(30, 115, 190, .12);
	outline: none;
}

.wd-sidebar .widget_product_search button[type="submit"] {
	position: absolute;
	top: 50%;
	right: 4px;
	transform: translateY(-50%);
	width: 36px;
	height: 36px;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--tg-azul);
	color: #fff;
	line-height: 36px;
	transition: background-color .2s ease;
}

.wd-sidebar .widget_product_search button[type="submit"]:hover {
	background-color: var(--tg-azul-claro);
}

/* --------------------------------------------------------------- categorías */

.wd-sidebar .widget_product_categories .product-categories {
	max-height: 400px;
	overflow-y: auto;
	overscroll-behavior: contain;
	margin: 0 -6px;
	/* el tema reserva 25px a la derecha y en esta columna estrecha no sobran */
	padding: 0 6px !important;
}

.wd-sidebar .widget_product_categories .product-categories::-webkit-scrollbar {
	width: 5px;
}

.wd-sidebar .widget_product_categories .product-categories::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background-color: #d5dbe4;
}

/* Rejilla en lugar de posicionado absoluto: con nombres largos y la columna
   estrecha, el contador se encimaba sobre el texto. */
.wd-sidebar .product-categories li.cat-item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	grid-template-areas:
		"enlace contador toggle"
		"hijas  hijas    hijas";
	align-items: center;
	margin: 0;
	padding: 0;
	border: 0;
	list-style: none;
}

.wd-sidebar .product-categories > li.cat-item + li.cat-item {
	border-top: 1px solid #f0f2f6;
}

.wd-sidebar .product-categories li.cat-item > a {
	grid-area: enlace;
	display: block;
	min-width: 0;
	width: auto;
	/* el tema le pone flex-basis calc(100% - 40px); dentro de la rejilla estorba */
	flex: none;
	padding: 9px 8px 9px 10px;
	border-radius: 8px;
	color: var(--tg-texto);
	font-size: 14px;
	line-height: 1.35;
	overflow-wrap: break-word;
	transition: background-color .18s ease, color .18s ease;
}

.wd-sidebar .product-categories > li.cat-item > a {
	font-weight: 600;
}

.wd-sidebar .product-categories li.cat-item > a:hover {
	background-color: var(--tg-fondo-suave);
	color: var(--tg-azul-claro);
}

/* contador como pastilla */
.wd-sidebar .product-categories li.cat-item > .count {
	grid-area: contador;
	min-width: 24px;
	margin-left: 4px;
	padding: 1px 7px;
	border-radius: 999px;
	background-color: var(--tg-fondo-suave);
	color: var(--tg-suave);
	font-size: 11px;
	font-weight: 600;
	line-height: 18px;
	text-align: center;
	white-space: nowrap;
}

/* botón de despliegue */
.wd-sidebar .product-categories .wd-cats-toggle {
	grid-area: toggle;
	position: static;
	width: 28px;
	height: 28px;
	margin-left: 2px;
	border-radius: 8px;
	transition: background-color .18s ease, transform .2s ease;
}

.wd-sidebar .product-categories .wd-cats-toggle:hover {
	background-color: var(--tg-fondo-suave);
}

.wd-sidebar .product-categories .cat-item.wd-opened > .wd-cats-toggle {
	transform: rotate(180deg);
}

/* subcategorías con línea guía */
.wd-sidebar .product-categories .children {
	grid-area: hijas;
	margin: 2px 0 8px;
	padding-left: 12px;
	border-left: 2px solid #edf0f5;
}

.wd-sidebar .product-categories .children li.cat-item > a {
	padding: 6px 8px 6px 10px;
	color: var(--tg-suave);
	font-size: 13px;
	font-weight: 400;
}

.wd-sidebar .product-categories .children li.cat-item > .count {
	font-size: 10px;
	line-height: 16px;
}

/* Categoría activa. Ojo: .wd-active-parent NO marca la activa, Woodmart se la
   pone a toda categoría que tenga hijas; usar solo las clases de WooCommerce. */
.wd-sidebar .product-categories li.current-cat > a {
	background-color: rgba(0, 31, 70, .07);
	color: var(--tg-azul);
	font-weight: 700;
	box-shadow: inset 2px 0 0 var(--tg-azul);
}

.wd-sidebar .product-categories li.current-cat-parent > a,
.wd-sidebar .product-categories li.current-cat-ancestor > a {
	color: var(--tg-azul);
	font-weight: 700;
}

/* ------------------------------------------------- productos vistos (compacto) */

.wd-sidebar .widget_recently_viewed_products ul {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wd-sidebar .widget_recently_viewed_products li {
	margin: 0;
	padding: 0;
	border: 0;
}

.wd-sidebar .widget_recently_viewed_products li + li {
	border-top: 1px solid #f0f2f6;
}

/* como mucho 4 productos, para que el widget no crezca sin control */
.wd-sidebar .widget_recently_viewed_products li:nth-child(n+5) {
	display: none;
}

.wd-sidebar .widget_recently_viewed_products .widget-product-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 0;
}

/* La miniatura se fija a 64x64. El !important es necesario para ganarle al
   bloque TECNIGAL-SQUARE-THUMBS del CSS del personalizador. */
.wd-sidebar .widget_recently_viewed_products .widget-product-img {
	flex: 0 0 64px;
	width: 64px !important;
	height: 64px !important;
	padding: 4px;
	border: 1px solid var(--tg-borde);
	border-radius: 8px;
	background-color: #fff;
	overflow: hidden;
}

.wd-sidebar .widget_recently_viewed_products .widget-product-img img {
	width: 100% !important;
	height: 100% !important;
	max-width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain !important;
	margin: 0 !important;
}

.wd-sidebar .widget_recently_viewed_products .widget-product-info {
	flex: 1 1 auto;
	min-width: 0;
}

.wd-sidebar .widget_recently_viewed_products .wd-entities-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: var(--tg-texto);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
}

.wd-sidebar .widget_recently_viewed_products .wd-entities-title:hover {
	color: var(--tg-azul-claro);
}

/* en modo catálogo el precio viene vacío y solo deja un hueco */
.wd-sidebar .widget_recently_viewed_products .price:empty {
	display: none;
}

/* ---------------------------------------------- panel de filtros en móvil/tablet */

/* Woodmart deja el aside en display:none con
   .wd-sidebar-hidden-sm .wd-sidebar:not(.wd-side-hidden), y al pulsar
   "Mostrar filtro" solo añade .wd-opened: la pantalla se oscurecía pero el
   panel no aparecía. Esto lo restituye como panel deslizante. */
@media (max-width: 1024px) {
	.wd-sidebar.sidebar-container.wd-opened {
		display: block !important;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 500;
		width: min(320px, 88vw);
		max-width: 100%;
		height: 100%;
		margin: 0;
		padding: 16px;
		background-color: #fff;
		box-shadow: 4px 0 24px rgba(16, 24, 40, .18);
		overflow-y: auto;
		overscroll-behavior: contain;
		animation: tg-sidebar-in .25s ease;
	}

	.wd-sidebar.sidebar-container.wd-opened .wd-heading {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 14px;
		padding-bottom: 12px;
		border-bottom: 1px solid var(--tg-borde);
	}

	.wd-sidebar.sidebar-container.wd-opened .sidebar-widget {
		padding: 16px;
	}

	.wd-sidebar.sidebar-container.wd-opened .widget_product_categories .product-categories {
		max-height: none;
	}
}

@keyframes tg-sidebar-in {
	from {
		transform: translateX(-100%);
	}

	to {
		transform: translateX(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wd-sidebar.sidebar-container.wd-opened {
		animation: none;
	}
}
