/* SarvTheme compare.css — built from modules. Edit modules + run npm run build */

/* --- compare.css --- */
/**
 * SarvTheme Product Compare — page + modal styles.
 */

.st-compare {
	--st-compare-border: color-mix(in srgb, currentColor 12%, transparent);
	--st-compare-surface: color-mix(in srgb, currentColor 4%, transparent);
	--st-compare-muted: color-mix(in srgb, currentColor 55%, transparent);
	width: 100%;
}

.st-compare__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1.25rem;
	margin-bottom: 1.25rem;
}

.st-compare__toolbar-end {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.st-compare__count {
	font-size: 0.875rem;
	color: var(--st-compare-muted);
}

.st-compare__add-btn,
.st-compare__clear-btn,
.st-compare-search__btn {
	appearance: none;
	border: 1px solid var(--st-compare-border);
	background: transparent;
	color: inherit;
	border-radius: 0.5rem;
	padding: 0.55rem 1rem;
	font: inherit;
	font-size: 0.9rem;
	line-height: 1.3;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.st-compare__add-btn {
	background: var(--sarv-color-primary, #111);
	border-color: transparent;
	color: var(--sarv-color-primary-contrast, #fff);
}

.st-compare__add-btn:hover,
.st-compare__add-btn:focus-visible {
	opacity: 0.92;
}

.st-compare__clear-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.st-compare__empty {
	text-align: center;
	padding: 3rem 1.25rem;
	border: 1px dashed var(--st-compare-border);
	border-radius: 0.75rem;
	background: var(--st-compare-surface);
}

.st-compare__empty-text {
	margin: 0 0 1rem;
	color: var(--st-compare-muted);
}

.st-compare__table-wrap {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--st-compare-border);
	border-radius: 0.75rem;
}

.st-compare__table {
	width: 100%;
	min-width: 40rem;
	border-collapse: collapse;
	table-layout: fixed;
}

.st-compare__table th,
.st-compare__table td {
	padding: 0.85rem 1rem;
	border-bottom: 1px solid var(--st-compare-border);
	border-inline-end: 1px solid var(--st-compare-border);
	vertical-align: middle;
	text-align: center;
	font-size: 0.9rem;
}

.st-compare__table th:last-child,
.st-compare__table td:last-child {
	border-inline-end: 0;
}

.st-compare__table tbody tr:last-child th,
.st-compare__table tbody tr:last-child td {
	border-bottom: 0;
}

.st-compare__label-col,
.st-compare__table tbody th {
	width: 10rem;
	text-align: start;
	font-weight: 600;
	background: var(--st-compare-surface);
	position: sticky;
	inset-inline-start: 0;
	z-index: 1;
}

.st-compare__product-head {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.65rem;
	padding-top: 0.35rem;
}

.st-compare__remove {
	position: absolute;
	inset-block-start: -0.15rem;
	inset-inline-end: -0.15rem;
	width: 1.75rem;
	height: 1.75rem;
	border: 0;
	border-radius: 999px;
	background: color-mix(in srgb, currentColor 8%, transparent);
	color: inherit;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
}

.st-compare__remove:hover,
.st-compare__remove:focus-visible {
	background: color-mix(in srgb, currentColor 16%, transparent);
}

.st-compare__product-media {
	display: block;
	width: 6.5rem;
	aspect-ratio: 1;
}

.st-compare__product-media img,
.st-compare__product-image {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

.st-compare__product-title {
	display: block;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.45;
	color: inherit;
	text-decoration: none;
}

.st-compare__product-title:hover,
.st-compare__product-title:focus-visible {
	text-decoration: underline;
}

.st-compare__stock--outofstock {
	color: #b42318;
}

.st-compare__stock--instock {
	color: #067647;
}

.st-compare__cart-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.35rem;
	padding: 0.45rem 0.85rem;
	text-decoration: none;
	white-space: nowrap;
	position: relative;
}

.st-compare__cart-btn.is-loading {
	pointer-events: none;
	cursor: wait;
}

.st-compare__cart-btn.is-loading .st-compare__cart-btn-label {
	opacity: 0;
}

.st-compare__cart-btn::after {
	content: "";
	position: absolute;
	width: 1rem;
	height: 1rem;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	opacity: 0;
	visibility: hidden;
	animation: sarv-spin 0.8s linear infinite;
}

.st-compare__cart-btn.is-loading::after {
	opacity: 1;
	visibility: visible;
}

.st-compare__cart-btn.is-added {
	opacity: 0.85;
}

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

.st-compare.is-loading .st-compare__body {
	opacity: 0.55;
	pointer-events: none;
}

/* ── Modal ─────────────────────────────────────────────── */

.st-compare-modal[hidden] {
	display: none !important;
}

.st-compare-modal {
	position: fixed;
	inset: 0;
	z-index: 10050;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.st-compare-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
}

.st-compare-modal__dialog {
	position: relative;
	z-index: 1;
	width: min(36rem, 100%);
	max-height: min(85vh, 40rem);
	display: flex;
	flex-direction: column;
	background: var(--sarv-color-surface, #fff);
	color: inherit;
	border-radius: 0.85rem;
	box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.18);
	overflow: hidden;
}

.st-compare-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.15rem;
	border-bottom: 1px solid var(--st-compare-border);
}

.st-compare-modal__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
}

.st-compare-modal__close,
.sarv-compare-modal__close {
	appearance: none;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	padding: 0.15rem;
}

.st-compare-modal__search {
	padding: 0.85rem 1.15rem 0;
}

.st-compare-modal__input {
	width: 100%;
	border: 1px solid var(--st-compare-border);
	border-radius: 0.55rem;
	padding: 0.7rem 0.9rem;
	font: inherit;
	background: transparent;
	color: inherit;
}

.st-compare-modal__input:focus {
	outline: 2px solid color-mix(in srgb, currentColor 25%, transparent);
	outline-offset: 1px;
}

.st-compare-modal__results {
	flex: 1;
	overflow-y: auto;
	padding: 0.85rem 1.15rem 1.15rem;
	min-height: 12rem;
}

.st-compare-modal__hint,
.st-compare-modal__empty {
	margin: 1.5rem 0;
	text-align: center;
	color: var(--st-compare-muted);
	font-size: 0.9rem;
}

.st-compare-search__item {
	display: grid;
	grid-template-columns: 3.5rem 1fr auto;
	gap: 0.75rem;
	align-items: center;
	padding: 0.65rem 0;
	border-bottom: 1px solid var(--st-compare-border);
}

.st-compare-search__item:last-child {
	border-bottom: 0;
}

.st-compare-search__media {
	width: 3.5rem;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 0.4rem;
	background: var(--st-compare-surface);
}

.st-compare-search__media img,
.st-compare-search__thumb {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

.st-compare-search__title {
	margin: 0 0 0.25rem;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.4;
}

.st-compare-search__price {
	font-size: 0.85rem;
	color: var(--st-compare-muted);
}

.st-compare-search__btn.is-added,
.st-compare-search__btn:disabled {
	opacity: 0.55;
	cursor: default;
}

.st-compare-search__btn:not(:disabled):hover,
.st-compare-search__btn:not(:disabled):focus-visible {
	background: var(--st-compare-surface);
}

@media (max-width: 640px) {
	.st-compare__label-col,
	.st-compare__table tbody th {
		width: 7.5rem;
		font-size: 0.8rem;
	}

	.st-compare__table th,
	.st-compare__table td {
		padding: 0.65rem 0.7rem;
	}

	.st-compare__product-media {
		width: 5rem;
	}
}

/* ── Display modal (standard theme component) ─────────────
 * Base: .sarv-compare-modal
 * Modifiers (from Theme Options only):
 *   --large | --full-width | --full-height | --auto | --slide
 * Visual tokens (color, radius, overlay, padding) stay in CSS.
 */

.sarv-compare-modal[hidden] {
	display: none !important;
}

.sarv-compare-modal {
	position: fixed;
	inset: 0;
	z-index: 10040;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.sarv-compare-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.5);
}

.sarv-compare-modal__dialog {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	background: var(--sarv-color-surface, #fff);
	color: inherit;
	border-radius: 0.85rem;
	box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.2);
	overflow: hidden;
}

/* Width */
.sarv-compare-modal--large .sarv-compare-modal__dialog {
	width: min(72rem, 100%);
}

.sarv-compare-modal--full-width .sarv-compare-modal__dialog {
	width: min(100vw - 2rem, 100%);
}

/* Height — table scrolls inside .sarv-compare-modal__body */
.sarv-compare-modal--full-height .sarv-compare-modal__dialog {
	height: min(96vh, 100%);
	max-height: min(96vh, 100%);
}

.sarv-compare-modal--auto .sarv-compare-modal__dialog {
	height: auto;
	max-height: min(92vh, 56rem);
}

.sarv-compare-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--st-compare-border, rgba(15, 23, 42, 0.1));
	flex-shrink: 0;
}

.sarv-compare-modal__title {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 700;
}

.sarv-compare-modal__body {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 1rem 1.25rem 1.25rem;
}

/* Animation */
.sarv-compare-modal--slide .sarv-compare-modal__dialog {
	animation: sarv-compare-slide-in 0.28s ease-out;
}

@keyframes sarv-compare-slide-in {
	from {
		opacity: 0;
		transform: translateY(1.25rem);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

html.sarv-compare-display-open {
	overflow: hidden;
}
