/**
 * SAM Visual Search — storefront styles.
 *
 * Logical properties (inline-start/end, margin-inline) are used throughout so
 * the layout mirrors correctly under dir="rtl" without a separate stylesheet.
 */

.sam-vs-trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55em 1.1em;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
}

.sam-vs-trigger:hover {
	background: rgba( 0, 0, 0, 0.05 );
}

.sam-vs-trigger:focus-visible,
.sam-vs-btn:focus-visible,
.sam-vs-drop:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.sam-vs-trigger__icon {
	display: inline-flex;
}

body.sam-vs-locked {
	overflow: hidden;
}

/* ------------------------------------------------------------------ modal */

.sam-vs-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.sam-vs-modal[hidden] {
	display: none;
}

.sam-vs-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.55 );
}

.sam-vs-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min( 680px, 100% );
	max-height: min( 90vh, 900px );
	overflow: hidden;
	border-radius: 14px;
	background: #fff;
	color: #1a1a1a;
	box-shadow: 0 24px 60px rgba( 0, 0, 0, 0.3 );
}

.sam-vs-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid #e6e6e6;
}

.sam-vs-modal__title {
	margin: 0;
	font-size: 1.15rem;
	line-height: 1.3;
}

.sam-vs-modal__close {
	flex: 0 0 auto;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #f1f1f1;
	color: inherit;
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
}

.sam-vs-modal__body {
	overflow-y: auto;
	padding: 1.25rem;
}

/* ------------------------------------------------------------------ steps */

.sam-vs-step[hidden] {
	display: none;
}

.sam-vs-step--center {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	padding: 2.5rem 0;
}

.sam-vs-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	min-height: 170px;
	padding: 1.5rem;
	border: 2px dashed #c9c9c9;
	border-radius: 12px;
	color: #666;
	text-align: center;
	cursor: pointer;
}

.sam-vs-drop.is-active {
	border-color: #1a1a1a;
	background: #fafafa;
	color: #1a1a1a;
}

.sam-vs-drop__hint {
	margin: 0;
}

.sam-vs-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
	margin-block-start: 1rem;
}

.sam-vs-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.6em 1.2em;
	border: 1px solid transparent;
	border-radius: 8px;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
}

.sam-vs-btn--primary {
	background: #1a1a1a;
	color: #fff;
}

.sam-vs-btn--ghost {
	border-color: #c9c9c9;
	background: transparent;
	color: inherit;
}

.sam-vs-btn--link {
	padding-inline: 0.25em;
	border: 0;
	background: none;
	color: #555;
	text-decoration: underline;
}

/* The file inputs are visually hidden but stay focusable via their labels. */
.sam-vs-file {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	white-space: nowrap;
	border: 0;
}

.sam-vs-note {
	margin: 0.75rem 0 0;
	color: #666;
	font-size: 0.85rem;
	line-height: 1.5;
}

.sam-vs-note--lead {
	margin: 0 0 0.75rem;
}

.sam-vs-error {
	margin: 1rem 0 0;
	padding: 0.7rem 0.9rem;
	border-radius: 8px;
	background: #fdecec;
	color: #8a1f1f;
	font-size: 0.9rem;
}

.sam-vs-error[hidden] {
	display: none;
}

/* --------------------------------------------------------------- cropper */

.sam-vs-cropper {
	position: relative;
	margin-inline: auto;
	overflow: hidden;
	border-radius: 10px;
	background: #f4f4f4;
	touch-action: none;   /* pointer events drive the crop box, not scrolling */
	user-select: none;
}

.sam-vs-cropper__canvas {
	display: block;
}

.sam-vs-cropper__box {
	position: absolute;
	box-sizing: border-box;
	border: 2px solid #fff;
	box-shadow: 0 0 0 9999px rgba( 0, 0, 0, 0.42 );
	cursor: move;
}

.sam-vs-handle {
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #1a1a1a;
}

.sam-vs-handle[data-sam-vs-handle="nw"] { inset-block-start: -9px; inset-inline-start: -9px; cursor: nwse-resize; }
.sam-vs-handle[data-sam-vs-handle="ne"] { inset-block-start: -9px; inset-inline-end: -9px; cursor: nesw-resize; }
.sam-vs-handle[data-sam-vs-handle="sw"] { inset-block-end: -9px; inset-inline-start: -9px; cursor: nesw-resize; }
.sam-vs-handle[data-sam-vs-handle="se"] { inset-block-end: -9px; inset-inline-end: -9px; cursor: nwse-resize; }

.sam-vs-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid #e0e0e0;
	border-top-color: #1a1a1a;
	border-radius: 50%;
	animation: sam-vs-spin 0.8s linear infinite;
}

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

@media ( prefers-reduced-motion: reduce ) {
	.sam-vs-spinner {
		animation-duration: 2.4s;
	}
}

/* --------------------------------------------------------------- results */

.sam-vs-results__title {
	margin: 0 0 0.9rem;
	font-size: 1rem;
}

.sam-vs-results {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 140px, 1fr ) );
	gap: 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sam-vs-result__link {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	color: inherit;
	text-decoration: none;
}

.sam-vs-result__image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 8px;
	object-fit: cover;
	aspect-ratio: 3 / 4;
}

.sam-vs-result__name {
	font-size: 0.9rem;
	line-height: 1.35;
}

.sam-vs-result__price {
	font-size: 0.85rem;
	font-weight: 600;
}

.sam-vs-result__score {
	color: #777;
	font-size: 0.75rem;
}

@media ( max-width: 480px ) {
	.sam-vs-modal {
		padding: 0;
	}

	.sam-vs-modal__dialog {
		width: 100%;
		max-height: 100vh;
		border-radius: 0;
	}
}
