/**
 * Product Category List / Product Category Child List widgets styles.
 * Shared by both Elementor widgets (same markup/classes, the child list
 * widget just has no color filter group).
 */

.tv-product-cat-list {
	display: flex;
	flex-direction: column;
}

.tv-product-cat-list .tv-pcl-content {
	width: 100%;
	min-width: 0;
}

/* Row holding the page header (title + WooCommerce breadcrumb) on the left
 * and the filters bar on the right, both on the same line. When the page
 * header is absent (both hidden) this wraps the filters bar alone, so it
 * behaves exactly as before "flex: 1 1 auto" just fills the row. */
.tv-pcl-top-bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	width: 100%;
	gap: 16px;
}

.tv-pcl-top-bar .tv-pcl-filters-bar {
	width: auto;
	flex: 1 1 auto;
}

.tv-pcl-page-header {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	min-width: 0;
}

/* Vertical divider between the title and the breadcrumb, toggled via
 * "¿Mostrar separador entre título y breadcrumb?" and styled from
 * Estilo > Cabecera de página. Reuses the same gap value (as a custom
 * property) for the padding around the line so it stays visually centered
 * in the space the flex "gap" already reserves. */
.tv-pcl-page-header-divider-yes .tv-pcl-page-header {
	--tv-pcl-page-header-divider-color: rgba(0, 0, 0, 0.15);
	--tv-pcl-page-header-divider-weight: 1px;
}

.tv-pcl-page-header-divider-yes .tv-pcl-page-header > * + * {
	padding-left: var(--tv-pcl-page-header-gap, 12px);
	border-left: var(--tv-pcl-page-header-divider-weight) solid var(--tv-pcl-page-header-divider-color);
}

.tv-pcl-page-title {
	display: inline-flex;
	align-items: center;
	margin: 0;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1;
}

.tv-pcl-page-breadcrumb {
	display: inline-flex;
	align-items: center;
	line-height: 1;
}

/* WooCommerce's own breadcrumb markup ships with its own margin/padding
 * (e.g. a bottom margin meant for stacked layouts), which throws off
 * vertical centering against the title and the filter buttons on this
 * single-line toolbar. Reset it scoped to this widget only. */
.tv-pcl-page-breadcrumb .woocommerce-breadcrumb {
	margin: 0;
	padding: 0;
	line-height: 1;
}

/* Full-width toolbar (100% wide, "Dirección" control decides whether it
 * sits above the content or beside it) listing an optional title inline with
 * one trigger button per filter group (e.g. "Categorías", "Color") — à la
 * Zara Home. "Alineación del botón de filtros" controls where they sit
 * inside it (defaults to the right). Clicking a trigger never opens a
 * dropdown right there — it always opens the shared lateral panel, with
 * that group's dropdown already open inside it. Every item (title included)
 * is separated from the next by the same thin vertical divider. */
.tv-pcl-filters-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	width: 100%;
	gap: 12px;
	justify-content: flex-end;
}

/* Vertical divider between every item in the bar (title included), toggled
 * via "¿Mostrar separador entre elementos?" and styled from "Botones de
 * filtro" > "Separador entre elementos". */
.tv-pcl-bar-divider-yes .tv-pcl-filters-bar {
	--tv-pcl-bar-divider-color: rgba(0, 0, 0, 0.15);
	--tv-pcl-bar-divider-weight: 1px;
	--tv-pcl-bar-divider-spacing: 12px;
}

.tv-pcl-bar-divider-yes .tv-pcl-filters-bar > * + * {
	padding-left: var(--tv-pcl-bar-divider-spacing);
	border-left: var(--tv-pcl-bar-divider-weight) solid var(--tv-pcl-bar-divider-color);
}

.tv-pcl-filter-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	cursor: pointer;
	border: none;
	background: transparent;
	padding: 8px 0;
	font: inherit;
	font-family: inherit;
	line-height: 1;
	color: inherit;
}

/* Non-interactive elements (e.g. the filters bar title) reuse the trigger's
 * box model to look like one of the buttons, but must never react to hover
 * or look clickable — the matching Elementor hover selectors explicitly
 * exclude this class. */
.tv-pcl-filter-trigger--static {
	cursor: default;
}

/* Links inside the parent-categories filter group (plain navigation, not
 * checkboxes). Colors/typography are controlled from Elementor (Estilo >
 * Filtros > Enlaces de categorías padre); this just resets link chrome. */
.tv-pcl-filter-parent-cats .tv-pcl-filter-list a {
	text-decoration: none;
	color: inherit;
}

.tv-product-cat-list .tv-pcl-results {
	position: relative;
}

/* Default view shows the categories grid; product results appear only while
 * filtering (the JS toggles `tv-pcl--show-results` on the widget root). */
.tv-product-cat-list .tv-pcl-results {
	display: none;
}
.tv-product-cat-list.tv-pcl--show-results .tv-pcl-categories {
	display: none;
}
.tv-product-cat-list.tv-pcl--show-results .tv-pcl-results {
	display: block;
}

/* ---------------------------------------------------------------------------
 * Filter panel: one lateral panel, always the same on every screen size. A
 * fixed slide-in panel (from the configurable side) with a pinned header
 * (title + close) and footer (apply button), and an independently
 * scrollable middle section listing every filter group as a simple
 * accordion — click a group's title to expand just that group, every group
 * stays listed.
 * ------------------------------------------------------------------------ */

.tv-pcl-filters-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 99998;
}

body.tv-pcl-no-scroll {
	overflow: hidden;
}

.tv-product-cat-list .tv-pcl-filters {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	right: auto;
	height: 100%;
	width: min(86vw, 360px);
	max-width: none;
	margin: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	gap: 0;
	background: #fff;
	box-shadow: 0 0 32px rgba(0, 0, 0, 0.25);
	transform: translateX(-100%);
	transition: transform 0.3s ease;
	box-sizing: border-box;
}

.tv-product-cat-list[data-drawer-position="right"] .tv-pcl-filters {
	left: auto;
	right: 0;
	transform: translateX(100%);
}

.tv-product-cat-list.tv-pcl--filters-open .tv-pcl-filters {
	transform: none;
}

.tv-pcl-filters__header {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.tv-pcl-filters__title {
	font-weight: 600;
	font-size: 1.1rem;
}

.tv-pcl-filters-close {
	background: none;
	border: none;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	color: inherit;
}

.tv-pcl-filters-scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 28px;
}

.tv-pcl-filters__footer {
	display: flex;
	flex: 0 0 auto;
	padding: 16px 24px;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.tv-pcl-filters-apply {
	width: 100%;
	padding: 14px;
	cursor: pointer;
	font: inherit;
}

.tv-pcl-filter-title {
	margin: 0 0 12px;
	font-size: 1rem;
	font-weight: 600;
}

/* Collapsible group title inside the panel: the title becomes a full-width
 * toggle button with a chevron (Zara Home style accordion). Reset button
 * chrome but keep the title's font styles (set above and via the widget's
 * typography control). */
.tv-pcl-filter-toggle {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	width: 100%;
	gap: 8px;
	padding: 0;
	background: none;
	border: none;
	color: inherit;
	font-family: inherit;
	text-align: left;
	cursor: pointer;
}

.tv-pcl-filter-group {
	position: relative;
}

.tv-pcl-chevron {
	flex: 0 0 auto;
	transition: transform 0.25s ease;
}

.tv-pcl-filter-group.tv-pcl--open .tv-pcl-chevron {
	transform: rotate(180deg);
}

/* Collapsed by default (grid-template-rows 0fr); the JS adds .tv-pcl--open
 * to expand it (1fr) with an animated height. */
.tv-pcl-filter-collapse {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.25s ease;
}

.tv-pcl-filter-group.tv-pcl--open .tv-pcl-filter-collapse {
	grid-template-rows: 1fr;
}

.tv-pcl-filter-collapse > .tv-pcl-filter-list {
	overflow: hidden;
	min-height: 0;
}

.tv-pcl-filter-list {
	list-style: none;
	padding: 0;
}

.tv-pcl-filter-list li {
	margin: 0 0 8px;
}

.tv-pcl-filter-list label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-weight: 400;
}

.tv-pcl-filter-list input[type="checkbox"] {
	width: 16px;
	height: 16px;
	margin: 0;
	cursor: pointer;
}

.tv-pcl-filter-list small {
	opacity: 0.6;
}

/* Nicer interaction states */
.tv-pcl-filter-list label:hover {
	opacity: 0.75;
}

.tv-pcl-filter-list li:has(input:checked) > label {
	font-weight: 600;
}

/* Loop-template grid (used when an Elementor card template is selected) */
.tv-pcl-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 24px;
}

/* WooCommerce results grid: ensure spacing and remove list defaults so the
 * column control's grid layout looks right out of the box. */
.tv-pcl-results ul.products {
	margin: 0;
	padding: 0;
	list-style: none;
	gap: 24px;
}

.tv-pcl-results ul.products::before,
.tv-pcl-results ul.products::after {
	content: none;
}

.tv-pcl-results ul.products li.product {
	width: auto;
	margin: 0;
	float: none;
}

/* Child category cards: use a real CSS grid (not the Bootstrap row-cols flex
 * layout) so the column count is fully controllable from the widget. The
 * 2/3/4 responsive defaults mirror the previous row-cols-2/lg-3/xl-4 markup;
 * the "Columnas" control overrides these when set. */
.tv-pcl-categories-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 992px) {
	.tv-pcl-categories-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (min-width: 1200px) {
	.tv-pcl-categories-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* Neutralise the Bootstrap .col flex widths so each card fills its grid track
 * regardless of the chosen column count. */
.tv-pcl-categories-grid > .col {
	flex: none;
	width: auto;
	max-width: none;
}

/* Child category cards (archive-product.php markup). Force every image to the
 * same height: the .ratio box (3:4 by default, or a fixed height via control)
 * defines the size, and object-fit:cover makes the image fill it uniformly. */
.tv-pcl-categories-grid .ratio img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Load more */
.tv-pcl-load-more-wrap {
	display: flex;
	justify-content: center;
	margin-top: 32px;
}

.tv-pcl-load-more {
	cursor: pointer;
}

/* Results loading state */
.tv-pcl-results-inner {
	transition: opacity 0.2s ease;
}

.tv-pcl-not-found {
	width: 100%;
	padding: 32px 0;
	text-align: center;
	font-weight: 600;
}

.tv-pcl-spinner {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	justify-content: center;
	padding-top: 40px;
}

.tv-pcl-spinner span {
	width: 36px;
	height: 36px;
	border: 3px solid rgba(0, 0, 0, 0.15);
	border-top-color: rgba(0, 0, 0, 0.6);
	border-radius: 50%;
	animation: tv-pcl-spin 0.8s linear infinite;
}

@keyframes tv-pcl-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (max-width: 768px) {
	/* Full-width cards on mobile: one column for the child-category grid
	 * (the product results are also covered by the widget's mobile column
	 * default; this is the safety net for the categories grid). */
	.tv-product-cat-list .tv-pcl-categories-grid {
		grid-template-columns: 1fr;
	}
}

/* ---------------------------------------------------------------------------
 * Color swatches
 * ------------------------------------------------------------------------ */

.tv-pcl-color-swatch {
	display: inline-block;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.15);
	flex: 0 0 auto;
}

.tv-pcl-filter-list li:has(input:checked) .tv-pcl-color-swatch {
	box-shadow: 0 0 0 2px currentColor;
}

/* ---------------------------------------------------------------------------
 * Active filters bar
 * ------------------------------------------------------------------------ */

.tv-pcl-active-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;
}

.tv-pcl-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	font: inherit;
	font-size: 0.85em;
	cursor: pointer;
	line-height: 1;
	transition: opacity 0.15s ease;
}

.tv-pcl-chip:hover {
	opacity: 0.7;
}

.tv-pcl-chip-x {
	font-size: 1.1em;
	line-height: 1;
	margin-left: 2px;
}

.tv-pcl-chip-clear {
	border-style: dashed;
	opacity: 0.6;
}

/* ---------------------------------------------------------------------------
 * Optional separator between filter groups (categories, colors, ...).
 * ------------------------------------------------------------------------ */

.tv-pcl-group-separator-yes .tv-pcl-filter-group {
	--tv-pcl-group-separator-color: rgba(0, 0, 0, 0.1);
	--tv-pcl-group-separator-weight: 1px;
	--tv-pcl-group-separator-spacing: 16px;
}

.tv-pcl-group-separator-yes .tv-pcl-filter-group:not(:last-child) {
	padding-bottom: var(--tv-pcl-group-separator-spacing);
	border-bottom: var(--tv-pcl-group-separator-weight) solid var(--tv-pcl-group-separator-color);
}
