/* VIV Storefront - styles inherit from theme where possible */

/* ============ CSS VARIABLES ============ */
/* --vivsf-accent is set inline from settings; falls back to currentColor for theme inheritance */

.vivsf-storefront,
.vivsf-filters-group {
	--vivsf-accent: currentColor;
	--vivsf-card-bg: transparent;
	--vivsf-card-border: transparent;
	--vivsf-card-shadow: none;
	--vivsf-card-padding: 0;
	--vivsf-card-radius: 4px;
}

/* ============ STOREFRONT GRID ============ */

.vivsf-storefront {
	box-sizing: border-box;
	position: relative;
}

.vivsf-storefront-inner {
	transition: opacity 0.2s ease;
}

.vivsf-storefront.vivsf-loading .vivsf-storefront-inner {
	opacity: 0.4;
	pointer-events: none;
}

.vivsf-storefront.vivsf-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: var(--vivsf-accent, currentColor);
	border-radius: 50%;
	animation: vivsf-spin 0.8s linear infinite;
	z-index: 10;
	pointer-events: none;
}

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

.vivsf-storefront *,
.vivsf-storefront *::before,
.vivsf-storefront *::after {
	box-sizing: border-box;
}

.vivsf-result-count {
	margin: 0 0 1em;
	font-size: 0.9em;
	opacity: 0.7;
}

.vivsf-grid,
.vivsf-list {
	list-style: none;
	margin: 0 0 1.5em;
	padding: 0;
}

.vivsf-grid {
	display: grid;
	grid-template-columns: repeat(var(--vivsf-cols, 4), minmax(0, 1fr));
	gap: 1.5em;
}

.vivsf-cols-1 { --vivsf-cols: 1; }
.vivsf-cols-2 { --vivsf-cols: 2; }
.vivsf-cols-3 { --vivsf-cols: 3; }
.vivsf-cols-4 { --vivsf-cols: 4; }
.vivsf-cols-5 { --vivsf-cols: 5; }
.vivsf-cols-6 { --vivsf-cols: 6; }

@media (max-width: 1024px) {
	.vivsf-grid { grid-template-columns: repeat(min(var(--vivsf-cols, 4), 3), minmax(0, 1fr)); }
}
@media (max-width: 768px) {
	.vivsf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1em; }
}
@media (max-width: 480px) {
	.vivsf-grid { grid-template-columns: 1fr; }
}

.vivsf-list {
	display: flex;
	flex-direction: column;
	gap: 1em;
}

.vivsf-product {
	margin: 0;
	padding: var(--vivsf-card-padding);
	position: relative;
	background: var(--vivsf-card-bg);
	border: 1px solid var(--vivsf-card-border);
	box-shadow: var(--vivsf-card-shadow);
	border-radius: var(--vivsf-card-radius);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	display: flex;
	flex-direction: column;
}

.vivsf-list .vivsf-product {
	flex-direction: row;
	align-items: flex-start;
	gap: 1em;
}

.vivsf-product-info {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
}

.vivsf-product-actions {
	margin-top: auto;
	padding-top: 0.6em;
}

.vivsf-clickable-card:hover {
	transform: translateY(-2px);
}

/* Card style variants */
.vivsf-card-borderless { /* defaults already applied */ }

.vivsf-card-bordered {
	--vivsf-card-border: rgba(0, 0, 0, 0.1);
	--vivsf-card-padding: 0.8em;
}

.vivsf-card-shadowed {
	--vivsf-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	--vivsf-card-padding: 0.8em;
}
.vivsf-card-shadowed .vivsf-product:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.vivsf-card-filled {
	--vivsf-card-bg: rgba(0, 0, 0, 0.03);
	--vivsf-card-padding: 0.8em;
}

/* Text alignment */
.vivsf-align-center .vivsf-product-info {
	text-align: center;
}

.vivsf-product-link,
.vivsf-image-link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.vivsf-product-link {
	transition: transform 0.15s ease;
}

.vivsf-product-link:hover {
	transform: translateY(-2px);
}

.vivsf-list .vivsf-product-image-wrap {
	flex: 0 0 140px;
}

.vivsf-list .vivsf-product-info {
	flex: 1 1 auto;
}

.vivsf-product-image-wrap {
	position: relative;
	overflow: hidden;
	margin-bottom: 0.75em;
	border-radius: 3px;
}

.vivsf-product-image-wrap img {
	display: block;
	width: 100%;
	height: auto;
}

/* Image aspect ratio variants */
.vivsf-ratio-square .vivsf-product-image-wrap,
.vivsf-ratio-portrait .vivsf-product-image-wrap,
.vivsf-ratio-landscape .vivsf-product-image-wrap {
	overflow: hidden;
	background: var(--vivsf-card-bg, rgba(0, 0, 0, 0.02));
}
.vivsf-ratio-square .vivsf-product-image-wrap { aspect-ratio: 1 / 1; }
.vivsf-ratio-portrait .vivsf-product-image-wrap { aspect-ratio: 3 / 4; }
.vivsf-ratio-landscape .vivsf-product-image-wrap { aspect-ratio: 4 / 3; }

.vivsf-ratio-square .vivsf-product-image-wrap img,
.vivsf-ratio-portrait .vivsf-product-image-wrap img,
.vivsf-ratio-landscape .vivsf-product-image-wrap img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 0.5em;
}

.vivsf-badge {
	position: absolute;
	top: 0.5em;
	left: 0.5em;
	padding: 0.2em 0.6em;
	font-size: 0.75em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	border-radius: 3px;
	background: var(--vivsf-accent);
	color: #fff;
}

.vivsf-badge-sale {
	background: var(--vivsf-accent);
}

.vivsf-badge-oos {
	background: #555;
	left: auto;
	right: 0.5em;
}

.vivsf-badge-oos {
	background: #555;
	left: auto;
	right: 0.5em;
}

.vivsf-product-title {
	font-size: var(--vivsf-title-size, 0.95em);
	margin: 0 0 0.3em;
	font-weight: var(--vivsf-title-weight, 600);
	line-height: 1.3;
	color: var(--vivsf-title-color, inherit);
}

.vivsf-product-title a {
	color: inherit;
	text-decoration: none;
	transition: color 0.15s ease;
}

.vivsf-product-title a:hover {
	color: var(--vivsf-accent);
}

.vivsf-product-sku {
	font-size: 0.75em;
	opacity: 0.6;
	margin-bottom: 0.3em;
}

/* SKU label, e.g. "Part Number:" */
.vivsf-sku-label::after {
	content: ":";
}

.vivsf-sku-label {
	margin-right: 0.3em;
}

/* Lead with SKU: SKU takes the title's prominence, name becomes secondary. */
.vivsf-sku-first .vivsf-product-sku-lead {
	font-size: var(--vivsf-title-size, 1.05em);
	font-weight: var(--vivsf-title-weight, 700);
	color: var(--vivsf-title-color, inherit);
	opacity: 1;
	line-height: 1.3;
	margin: 0 0 0.25em;
}

.vivsf-sku-first .vivsf-product-sku-lead .vivsf-sku-label {
	font-size: 0.75em;
	font-weight: 400;
	opacity: 0.7;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.vivsf-sku-first .vivsf-sku-value {
	color: inherit;
	text-decoration: none;
	transition: color 0.15s ease;
}

.vivsf-sku-first .vivsf-sku-value:hover {
	color: var(--vivsf-accent);
}

.vivsf-sku-first .vivsf-product-title {
	font-size: 0.85em;
	font-weight: 400;
	opacity: 0.85;
}

.vivsf-product-price {
	font-size: var(--vivsf-price-size, 0.95em);
	font-weight: var(--vivsf-price-weight, 600);
	color: var(--vivsf-price-color, inherit);
}

.vivsf-align-center .vivsf-product-actions {
	text-align: center;
}

/* Button styles - inherit color/background from accent variable */
.vivsf-button,
.vivsf-product-actions .button,
.vivsf-product-actions .added_to_cart {
	display: inline-block;
	padding: 0.45em 1.1em;
	font-size: 0.85em;
	font-weight: 500;
	text-decoration: none;
	border-radius: 3px;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
	line-height: 1.2;
	border: 1.5px solid var(--vivsf-accent);
}

/* Solid (default) */
.vivsf-btn-solid .vivsf-button,
.vivsf-btn-solid .vivsf-product-actions .button,
.vivsf-btn-solid .vivsf-product-actions .added_to_cart {
	background: var(--vivsf-accent);
	color: #fff;
}
.vivsf-btn-solid .vivsf-button:hover,
.vivsf-btn-solid .vivsf-product-actions .button:hover,
.vivsf-btn-solid .vivsf-product-actions .added_to_cart:hover {
	opacity: 0.85;
}

/* Outline */
.vivsf-btn-outline .vivsf-button,
.vivsf-btn-outline .vivsf-product-actions .button,
.vivsf-btn-outline .vivsf-product-actions .added_to_cart {
	background: transparent;
	color: var(--vivsf-accent);
}
.vivsf-btn-outline .vivsf-button:hover,
.vivsf-btn-outline .vivsf-product-actions .button:hover,
.vivsf-btn-outline .vivsf-product-actions .added_to_cart:hover {
	background: var(--vivsf-accent);
	color: #fff;
}

/* Minimal (text only) */
.vivsf-btn-minimal .vivsf-button,
.vivsf-btn-minimal .vivsf-product-actions .button,
.vivsf-btn-minimal .vivsf-product-actions .added_to_cart {
	background: transparent;
	color: var(--vivsf-accent);
	border-color: transparent;
	padding-left: 0;
	padding-right: 0;
}
.vivsf-btn-minimal .vivsf-button:hover,
.vivsf-btn-minimal .vivsf-product-actions .button:hover {
	text-decoration: underline;
}
.vivsf-btn-minimal .vivsf-button::after {
	content: " →";
}

.vivsf-outofstock .vivsf-product-info {
	opacity: 0.6;
}

.vivsf-no-results {
	padding: 2em;
	text-align: center;
	background: rgba(0, 0, 0, 0.03);
	border-radius: 4px;
}

/* ============ TOOLBAR: result count + sorting ============ */

.vivsf-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75em 1.5em;
	margin: 0 0 1em;
}

.vivsf-toolbar .vivsf-result-count {
	margin: 0;
}

.vivsf-toolbar .vivsf-sort {
	margin-left: auto;
}

.vivsf-sort-select {
	min-width: 13em;
	padding: 0.5em 0.7em;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 3px;
	background-color: #fff;
	font: inherit;
	font-size: 0.95em;
	color: inherit;
	cursor: pointer;
}

.vivsf-sort-standalone {
	display: flex;
	justify-content: flex-end;
}

.vivsf-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 480px) {
	.vivsf-toolbar .vivsf-sort,
	.vivsf-sort-select { width: 100%; }
}

/* ============ PAGINATION ============ */

.vivsf-pagination {
	margin: 1.5em 0;
}

.vivsf-page-numbers {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3em;
	list-style: none;
	margin: 0;
	padding: 0;
	justify-content: center;
}

.vivsf-page-link {
	display: inline-block;
	min-width: 2.2em;
	padding: 0.4em 0.7em;
	text-align: center;
	text-decoration: none;
	color: inherit;
	border: 1px solid currentColor;
	border-radius: 3px;
	opacity: 0.7;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.vivsf-page-link:hover {
	opacity: 1;
}

.vivsf-page-link.vivsf-current {
	opacity: 1;
	background: currentColor;
}

.vivsf-page-link.vivsf-current::after {
	color: #fff;
	content: attr(data-num);
}

.vivsf-page-numbers .vivsf-current {
	color: inherit;
	background: rgba(0, 0, 0, 0.08);
}

.vivsf-dots {
	padding: 0.4em 0.3em;
	opacity: 0.5;
}

/* ============ FILTER WIDGET ============ */

.vivsf-filter {
	margin: 0 0 1.5em;
	padding: 0;
	font-size: 0.95em;
}

.vivsf-filter * {
	box-sizing: border-box;
}

.vivsf-filter-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	margin: 0;
	padding: 0.6em 0;
	font-size: var(--vivsf-filter-title-size, 1em);
	font-weight: 600;
	text-align: left;
	color: var(--vivsf-filter-title-color, inherit);
	background: transparent;
	border: 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.1);
	cursor: default;
	transition: color 0.15s ease;
}

/* Make sure our button reset overrides theme global button styles */
button.vivsf-filter-title,
.vivsf-filter button.vivsf-filter-title {
	cursor: pointer;
	background: transparent !important;
	border: 0 !important;
	border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
	color: var(--vivsf-filter-title-color, inherit) !important;
	font-family: inherit;
	-webkit-appearance: none;
	appearance: none;
}

.vivsf-filter-title:hover,
button.vivsf-filter-title:hover,
.vivsf-filter button.vivsf-filter-title:hover {
	color: var(--vivsf-filter-title-hover-color, var(--vivsf-filter-title-color, inherit)) !important;
}

button.vivsf-filter-title:hover .vivsf-filter-title-text {
	opacity: 0.85;
}

.vivsf-filter-title-text {
	color: inherit;
}

.vivsf-filter-caret {
	width: 0;
	height: 0;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 6px solid currentColor;
	transition: transform 0.2s ease;
}

.vivsf-collapsed .vivsf-filter-caret {
	transform: rotate(-90deg);
}

.vivsf-collapsed .vivsf-filter-body {
	display: none;
}

.vivsf-filter-body {
	padding: 0.6em 0 0;
}

.vivsf-filter-search {
	width: 100%;
	padding: 0.5em 0.7em;
	margin-bottom: 0.6em;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 3px;
	font-size: 0.9em;
	background: #fff;
}

.vivsf-filter-search:focus {
	outline: none;
	border-color: rgba(0, 0, 0, 0.4);
}

.vivsf-filter-items {
	list-style: none;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.01);
}

.vivsf-filter-item {
	margin: 0;
	padding: 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.vivsf-filter-item:last-child {
	border-bottom: 0;
}

.vivsf-filter-item.vivsf-hidden {
	display: none;
}

.vivsf-filter-item.vivsf-unavailable .vivsf-filter-link {
	opacity: 0.35;
	cursor: not-allowed;
	pointer-events: none;
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

.vivsf-filter-item.vivsf-unavailable .vivsf-filter-label {
	text-decoration: inherit;
}

.vivsf-filter-item.vivsf-unavailable .vivsf-checkbox {
	border-style: dashed;
}

.vivsf-filter-link {
	display: flex;
	align-items: center;
	gap: 0.6em;
	padding: 0.5em 0.7em;
	color: var(--vivsf-filter-item-color, inherit);
	text-decoration: none;
	transition: background-color 0.1s ease, color 0.1s ease;
	font-size: var(--vivsf-filter-item-size, 1em);
}

.vivsf-filter-link:hover {
	background: var(--vivsf-filter-item-hover-bg, rgba(0, 0, 0, 0.04));
}

.vivsf-checked .vivsf-filter-link {
	background: var(--vivsf-checked-bg, rgba(0, 0, 0, 0.05));
	color: var(--vivsf-checked-text, var(--vivsf-filter-item-color, inherit));
}

.vivsf-checked .vivsf-checkbox {
	opacity: 1;
	background: var(--vivsf-checkbox-fill, var(--vivsf-accent));
	border-color: var(--vivsf-checkbox-fill, var(--vivsf-accent));
}

.vivsf-checkbox {
	flex: 0 0 16px;
	width: 16px;
	height: 16px;
	border: 1.5px solid currentColor;
	border-radius: 3px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	opacity: 0.6;
	color: inherit;
}

.vivsf-checked .vivsf-checkbox svg {
	color: #fff;
}

.vivsf-filter-label {
	flex: 1 1 auto;
}

.vivsf-filter-count {
	flex: 0 0 auto;
	font-size: 0.85em;
	opacity: 0.6;
}

.vivsf-filter-dropdown {
	width: 100%;
	padding: 0.5em 0.7em;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 3px;
	background: #fff;
	font: inherit;
	font-size: 0.95em;
}

.vivsf-filter-actions {
	margin-top: 0.6em;
	text-align: right;
}

.vivsf-clear-filter {
	font-size: 0.85em;
	opacity: 0.7;
	text-decoration: underline;
	color: inherit;
}

.vivsf-clear-filter:hover {
	opacity: 1;
}

/* Empty search state */
.vivsf-filter-items.vivsf-all-hidden::after {
	content: attr(data-empty-msg);
	display: block;
	padding: 0.6em 0.8em;
	font-size: 0.85em;
	opacity: 0.6;
	font-style: italic;
}

/* ============ ACTIVE FILTERS CHIPS ============ */

.vivsf-active-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em;
	align-items: center;
	margin: 0 0 1em;
	padding: 0.6em 0.8em;
	background: rgba(0, 0, 0, 0.04);
	border-radius: 3px;
}

.vivsf-active-filters-empty {
	display: none;
}

.vivsf-active-title {
	font-size: 0.85em;
	opacity: 0.7;
	margin-right: 0.3em;
}

.vivsf-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.25em 0.6em;
	background: var(--vivsf-chip-bg, var(--vivsf-checked-bg, #fff));
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 999px;
	font-size: 0.85em;
	color: var(--vivsf-chip-text, var(--vivsf-checked-text, inherit));
	text-decoration: none;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.vivsf-chip:hover {
	opacity: 0.85;
}

.vivsf-chip-x {
	font-size: 1.1em;
	line-height: 1;
	opacity: 0.6;
}

.vivsf-chip:hover .vivsf-chip-x {
	opacity: 1;
}

.vivsf-clear-all {
	font-size: 0.85em;
	margin-left: auto;
	opacity: 0.7;
	color: inherit;
	text-decoration: underline;
}

.vivsf-clear-all:hover {
	opacity: 1;
}

/* ============ THEME ISOLATION (v3.1) ============
 * Themes often style every `ul li` in content areas with bullets, markers, background-image
 * bullets or left padding. These rules win over typical theme selectors so the grid,
 * filter lists and pagination render the same on any theme. They only touch list styling;
 * the plugin's own spacing rules above still apply.
 */
.vivsf-storefront ul,
.vivsf-storefront li,
.vivsf-filter ul,
.vivsf-filter li {
	list-style: none !important;
}

.vivsf-storefront ul,
.vivsf-filter ul {
	margin-left: 0;
	padding-left: 0;
}

.vivsf-storefront li,
.vivsf-filter li {
	margin-left: 0;
	background-image: none;
}

.vivsf-storefront li::marker,
.vivsf-filter li::marker {
	content: none;
}

.vivsf-storefront ul > li::before,
.vivsf-filter ul > li::before {
	content: none !important;
	display: none !important;
}
