/**
 * Product Category List widget styles.
 */

.tv-product-cat-list {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
}

.tv-product-cat-list .tv-pcl-filters {
	flex: 0 0 220px;
	max-width: 100%;
	display: flex;
	flex-direction: column;
	gap: 28px;
}

.tv-product-cat-list .tv-pcl-content {
	flex: 1 1 0;
	min-width: 0;
}

.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 position (set via the widget's prefix_class on the Elementor wrapper)
 * ------------------------------------------------------------------------ */

/* Left (default): filters before the content. */
.tv-pcl-layout-left .tv-pcl-filters {
	order: 0;
}
.tv-pcl-layout-left .tv-pcl-content {
	order: 1;
}

/* Right: filters after the content. */
.tv-pcl-layout-right .tv-pcl-filters {
	order: 1;
}
.tv-pcl-layout-right .tv-pcl-content {
	order: 0;
}

/* Top: filters stacked above the results, laid out horizontally. */
.tv-pcl-layout-top .tv-product-cat-list {
	flex-direction: column;
}
.tv-pcl-layout-top .tv-pcl-filters {
	flex: 0 0 100%;
	flex-direction: row;
	flex-wrap: wrap;
}

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

/* Collapsible group title: the <h4> becomes a full-width toggle button with a
 * chevron. 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-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; the JS adds .tv-pcl--open to expand. The grid-rows
 * 0fr/1fr trick animates the height without needing a fixed max-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;
	margin: 0;
	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;
}

/* ---------------------------------------------------------------------------
 * Mobile filters: toggle button + drawer chrome.
 * Base state (desktop) hides the mobile UI; the per-instance media query
 * emitted by the widget reveals it below the chosen breakpoint.
 * ------------------------------------------------------------------------ */
.tv-pcl-filters-toggle {
	display: none;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	border: 1px solid currentColor;
	background: transparent;
	padding: 10px 16px;
	font: inherit;
	line-height: 1;
}

.tv-pcl-filters-toggle svg {
	flex: 0 0 auto;
}

.tv-pcl-filters__header,
.tv-pcl-filters__footer {
	display: none;
}

.tv-pcl-filters__header {
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}

.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__footer {
	margin-top: 24px;
}

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

.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;
}

/* 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) {
	.tv-product-cat-list {
		flex-direction: column;
	}

	.tv-product-cat-list .tv-pcl-filters,
	.tv-product-cat-list .tv-pcl-content {
		flex-basis: 100%;
		max-width: 100%;
	}

	/* Full-width cards on mobile: one column for both the child-category grid
	 * and the product results (the latter is 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;
	}
}
