.vps-search,
.vps-search * {
	box-sizing: border-box;
}

/* Elements toggled via the HTML `hidden` attribute set their own `display`
   (flex/block/grid) for the visible state, which — because it comes from an
   author stylesheet — otherwise wins over the browser's default
   `[hidden] { display: none }` user-agent rule and makes them stuck visible. */
.vps-search [hidden] {
	display: none !important;
}

.vps-search {
	position: relative;
	width: var(--vps-width, 100%);
	max-width: 100%;
	margin: var(--vps-spacing-outer, 0) auto;
	direction: rtl;
	text-align: right;
	font-family: inherit;
}

/* ---------- search box ---------- */

.vps-box {
	position: relative;
	display: flex;
	flex-direction: row;
	direction: rtl;
	align-items: center;
	gap: 8px;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
	background: var(--vps-bg, #f5f5f7);
	border: var(--vps-border-width, 1px) solid var(--vps-border-color, #e1e4e8);
	border-radius: var(--vps-radius, 24px);
	padding: var(--vps-padding-y, 12px) var(--vps-padding-x, 16px);
	margin: 0;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vps-box.is-focused {
	border-color: var(--vps-primary, #007aff);
	box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

/* Themes commonly style bare `button`/`input[type=text]` with their own border,
   background and box-shadow at a specificity that can beat plain single-class
   rules. These controls must always render as bare, chrome-less parts of our
   own box, never with the theme's default form-control look — hence !important. */

.vps-box__submit {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	appearance: none;
	background: none !important;
	border: none !important;
	box-shadow: none !important;
	border-radius: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	min-width: 0;
	min-height: 0;
	line-height: 1;
	color: var(--vps-primary, #007aff);
	cursor: pointer;
}

.vps-box__input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	max-width: 100%;
	height: auto;
	appearance: none;
	border: none !important;
	background: transparent !important;
	box-shadow: none !important;
	border-radius: 0 !important;
	outline: none !important;
	padding: 0 !important;
	margin: 0;
	direction: rtl;
	text-align: right;
	font-size: var(--vps-placeholder-size, 14px);
	color: var(--vps-text-color, #1c1c1e);
	position: relative;
	z-index: 2;
}

.vps-box__input:focus {
	border: none !important;
	background: transparent !important;
	box-shadow: none !important;
	outline: none !important;
}

.vps-box__overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: row;
	direction: rtl;
	align-items: center;
	justify-content: flex-start;
	gap: 8px;
	min-width: 0;
	padding-inline-start: calc(var(--vps-padding-x, 16px) + 30px);
	padding-inline-end: var(--vps-padding-x, 16px);
	overflow: hidden;
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.12s ease;
}

.vps-box.is-focused .vps-box__overlay,
.vps-box.has-value .vps-box__overlay {
	opacity: 0;
}

.vps-box__placeholder {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: var(--vps-placeholder-size, 14px);
	color: var(--vps-placeholder-color, #8a8a8e);
}

.vps-box__brand-text {
	flex: 0 1 auto;
	min-width: 0;
	max-width: 45%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: var(--vps-brand-size, 16px);
	font-weight: 700;
	line-height: 1.2;
	color: var(--vps-placeholder-color, #8a8a8e);
}

.vps-box__brand-img {
	flex: 0 0 auto;
	max-width: 45%;
	height: var(--vps-brand-size, 16px);
	max-height: var(--vps-brand-size, 16px);
	width: auto;
	object-fit: contain;
}

.vps-box__clear {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	appearance: none;
	background: rgba(0, 0, 0, 0.06) !important;
	border: none !important;
	box-shadow: none !important;
	outline: none !important;
	border-radius: 50% !important;
	width: 22px;
	height: 22px;
	padding: 0;
	color: var(--vps-text-color, #1c1c1e);
	cursor: pointer;
	position: relative;
	z-index: 2;
}

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

.vps-grid {
	display: grid;
	grid-template-columns: repeat(var(--vps-columns, 3), minmax(0, 1fr));
	gap: 14px;
	width: 100%;
}

.vps-card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
	overflow: hidden;
	text-decoration: none;
	color: inherit;
	border-radius: 10px;
}

.vps-card__img-wrap {
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: 10px;
	background: #f0f0f0;
}

.vps-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.vps-card__name {
	font-size: 13px;
	line-height: 1.5;
	color: var(--vps-text-color, #1c1c1e);
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	min-width: 0;
}

.vps-card__price {
	font-size: 13px;
	font-weight: 700;
	color: var(--vps-primary, #007aff);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---------- list layout: image left, name right, price under name ---------- */

.vps-layout-list .vps-grid,
.vps-layout-compact .vps-grid {
	grid-template-columns: 1fr;
}

.vps-layout-list .vps-card {
	display: grid;
	grid-template-columns: 1fr 64px;
	grid-template-areas: "name img" "price img";
	align-items: start;
	gap: 4px 12px;
	direction: rtl;
}

.vps-layout-list .vps-card__img-wrap {
	grid-area: img;
	width: 64px;
}

.vps-layout-list .vps-card__name {
	grid-area: name;
}

.vps-layout-list .vps-card__price {
	grid-area: price;
}

/* ---------- compact layout: small image, single-line name + price ---------- */

.vps-layout-compact .vps-card {
	display: grid;
	grid-template-columns: auto 1fr 40px;
	grid-template-areas: "price name img";
	align-items: center;
	gap: 8px;
	direction: rtl;
}

.vps-layout-compact .vps-card__img-wrap {
	grid-area: img;
	width: 40px;
}

.vps-layout-compact .vps-card__name {
	grid-area: name;
	display: block;
	white-space: nowrap;
}

.vps-layout-compact .vps-card__price {
	grid-area: price;
}

/* ---------- extra large / medium / small icon grids ----------
   Icon-size views resize the product image itself (like Explorer's
   icon views), so they set their own column width instead of the
   fixed --vps-columns count used by the default "large" grid. */

.vps-layout-extra_large .vps-grid {
	grid-template-columns: repeat( auto-fill, minmax( 260px, 1fr ) );
	gap: 22px;
}

.vps-layout-extra_large .vps-card__name {
	font-size: 16px;
	-webkit-line-clamp: 3;
}

.vps-layout-extra_large .vps-card__price {
	font-size: 15px;
}

.vps-layout-medium .vps-grid {
	grid-template-columns: repeat( auto-fill, minmax( 110px, 1fr ) );
	gap: 10px;
}

.vps-layout-medium .vps-card__name,
.vps-layout-medium .vps-card__price {
	font-size: 12px;
}

.vps-layout-small .vps-grid {
	grid-template-columns: repeat( auto-fill, minmax( 80px, 1fr ) );
	gap: 6px;
}

.vps-layout-small .vps-card {
	gap: 4px;
}

.vps-layout-small .vps-card__img-wrap {
	border-radius: 6px;
}

.vps-layout-small .vps-card__name {
	font-size: 11px;
	-webkit-line-clamp: 1;
	white-space: nowrap;
}

.vps-layout-small .vps-card__price {
	font-size: 11px;
}

/* ---------- details layout: table-like rows with image / name / price columns ---------- */

.vps-layout-details .vps-grid {
	grid-template-columns: 1fr;
	gap: 0;
	border: 1px solid var(--vps-border-color, #e1e4e8);
	border-radius: 10px;
	overflow: hidden;
}

.vps-layout-details .vps-card {
	display: grid;
	grid-template-columns: 48px 1fr auto;
	grid-template-areas: "img name price";
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	border-bottom: 1px solid var(--vps-border-color, #e1e4e8);
	border-radius: 0;
	direction: rtl;
}

.vps-layout-details .vps-card:last-child {
	border-bottom: none;
}

.vps-layout-details .vps-card__img-wrap {
	grid-area: img;
	width: 40px;
}

.vps-layout-details .vps-card__name {
	grid-area: name;
	-webkit-line-clamp: 1;
	white-space: nowrap;
}

.vps-layout-details .vps-card__price {
	grid-area: price;
	font-variant-numeric: tabular-nums;
}

/* ---------- tiles layout: medium icon beside two lines of text ---------- */

.vps-layout-tiles .vps-grid {
	grid-template-columns: 1fr;
	gap: 10px;
}

.vps-layout-tiles .vps-card {
	display: grid;
	grid-template-columns: 56px 1fr;
	grid-template-areas: "img name" "img price";
	align-items: center;
	gap: 4px 12px;
	padding: 10px;
	border: 1px solid var(--vps-border-color, #e1e4e8);
	border-radius: 12px;
	direction: rtl;
}

.vps-layout-tiles .vps-card__img-wrap {
	grid-area: img;
	width: 56px;
}

.vps-layout-tiles .vps-card__name {
	grid-area: name;
}

.vps-layout-tiles .vps-card__price {
	grid-area: price;
}

/* ---------- content layout: larger icon beside full details, one row per item ---------- */

.vps-layout-content .vps-grid {
	grid-template-columns: 1fr;
	gap: 12px;
}

.vps-layout-content .vps-card {
	display: grid;
	grid-template-columns: 80px 1fr;
	grid-template-areas: "img name" "img price";
	align-items: center;
	gap: 6px 14px;
	padding: 12px;
	border: 1px solid var(--vps-border-color, #e1e4e8);
	border-radius: 14px;
	direction: rtl;
}

.vps-layout-content .vps-card__img-wrap {
	grid-area: img;
	width: 80px;
}

.vps-layout-content .vps-card__name {
	grid-area: name;
	font-size: 14px;
	-webkit-line-clamp: 2;
}

.vps-layout-content .vps-card__price {
	grid-area: price;
	font-size: 14px;
}

.vps-load-more {
	display: block;
	margin: 16px auto 0;
	padding: 8px 20px;
	background: var(--vps-bg, #f5f5f7);
	border: 1px solid var(--vps-border-color, #e1e4e8);
	border-radius: 999px;
	color: var(--vps-text-color, #1c1c1e);
	font-size: 13px;
	cursor: pointer;
}

.vps-empty,
.vps-hint {
	text-align: center;
	padding: 24px 8px;
	color: var(--vps-placeholder-color, #8a8a8e);
	font-size: 13px;
}

/* ---------- dropdown mode ---------- */

.vps-mode-dropdown .vps-dropdown {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	left: 0;
	z-index: 9999;
	background: #fff;
	border: 1px solid var(--vps-border-color, #e1e4e8);
	border-radius: 16px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
	padding: 16px;
	max-height: 70vh;
	overflow-y: auto;
}

/* ---------- fullscreen mode ---------- */

.vps-fullscreen {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: #fff;
	display: flex;
	flex-direction: column;
}

.vps-fullscreen[hidden] {
	display: none;
}

.vps-fullscreen__head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	border-bottom: 1px solid var(--vps-border-color, #e1e4e8);
}

.vps-fullscreen__head .vps-box {
	flex: 1 1 auto;
	min-width: 0;
}

.vps-fullscreen__close {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	color: var(--vps-text-color, #1c1c1e);
	cursor: pointer;
	padding: 6px;
}

.vps-fullscreen__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 20px;
}

body.vps-fullscreen-open {
	overflow: hidden;
}

/* ---------- page mode ---------- */

.vps-page-results {
	margin-top: 20px;
}

@media (max-width: 640px) {
	.vps-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
