/**
 * NetoCore — AJAX product search (header shortcode)
 */

.netocore-product-search,
.netocore-product-search * {
	font-family: "Vazirmatn FD", sans-serif;
	box-sizing: border-box;
}

.netocore-product-search {
	--ncps-primary: var(--nc-primary, #2563eb);
	--ncps-primary-dark: var(--nc-primary-dark, #1d4ed8);
	--ncps-text: var(--nc-text, #1f2937);
	--ncps-muted: var(--nc-text-muted, #6b7280);
	--ncps-border: var(--nc-border, #e5e7eb);
	--ncps-surface: var(--nc-surface, #ffffff);
	--ncps-radius: var(--nc-radius, 12px);

	position: relative;
	width: 100%;
	max-width: 100%;
	z-index: 100;
	direction: rtl;
	text-align: right;
}

.netocore-product-search__box {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 46px;
	padding: 0 14px;
	background: var(--ncps-field-bg, var(--ncps-surface));
	border: 1.5px solid var(--ncps-border);
	border-radius: 999px;
	box-shadow: none;
	transition: border-color 0.2s;
}

.netocore-product-search.is-focused .netocore-product-search__box,
.netocore-product-search.is-open .netocore-product-search__box {
	border-color: color-mix(in srgb, var(--ncps-primary) 55%, var(--ncps-border));
	box-shadow: none;
}

.netocore-product-search__icon {
	display: inline-flex;
	flex-shrink: 0;
	color: var(--ncps-muted);
	opacity: 0.85;
}

.netocore-product-search.is-focused .netocore-product-search__icon {
	color: var(--ncps-primary);
}

.netocore-product-search__input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	margin: 0;
	padding: 10px 0;
	border: 0 !important;
	outline: none !important;
	background: transparent !important;
	box-shadow: none !important;
	color: var(--ncps-text);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	appearance: none;
	-webkit-appearance: none;
}

.netocore-product-search__input::placeholder {
	color: var(--ncps-muted);
	opacity: 0.9;
	font-weight: 400;
}

.netocore-product-search--ph-color .netocore-product-search__input::placeholder {
	color: var(--ncps-placeholder);
	opacity: 1;
}

.netocore-product-search__input::-webkit-search-decoration,
.netocore-product-search__input::-webkit-search-cancel-button,
.netocore-product-search__input::-webkit-search-results-button,
.netocore-product-search__input::-webkit-search-results-decoration {
	display: none;
	-webkit-appearance: none;
}

.netocore-product-search--tinted .netocore-product-search__box {
	border-color: rgba(255, 255, 255, 0.22);
}

.netocore-product-search--tinted.is-focused .netocore-product-search__box,
.netocore-product-search--tinted.is-open .netocore-product-search__box {
	border-color: rgba(255, 255, 255, 0.4);
}

.netocore-product-search--tinted .netocore-product-search__icon,
.netocore-product-search--tinted.is-focused .netocore-product-search__icon {
	color: #fff;
	opacity: 1;
}

.netocore-product-search--tinted .netocore-product-search__input {
	color: #fff !important;
	caret-color: #fff;
}

.netocore-product-search__spinner {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	border: 2px solid color-mix(in srgb, var(--ncps-primary) 25%, transparent);
	border-top-color: var(--ncps-primary);
	border-radius: 50%;
	animation: ncps-spin 0.6s linear infinite;
}

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

.netocore-product-search__dropdown {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	left: 0;
	overflow: hidden;
	background: var(--ncps-surface);
	border: 1px solid var(--ncps-border);
	border-radius: var(--ncps-radius);
	box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
	animation: ncps-drop 0.18s ease-out;
}

@keyframes ncps-drop {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.netocore-product-search__status {
	padding: 16px 18px;
	color: var(--ncps-muted);
	font-size: 13px;
	text-align: center;
}

.netocore-product-search__results {
	margin: 0;
	padding: 6px;
	list-style: none;
	max-height: min(70vh, 420px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.netocore-product-search__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: calc(var(--ncps-radius) - 4px);
	text-decoration: none !important;
	color: inherit;
	cursor: pointer;
	transition: background 0.15s;
}

.netocore-product-search__item:hover,
.netocore-product-search__item.is-active,
.netocore-product-search__item:focus-visible {
	background: color-mix(in srgb, var(--ncps-primary) 8%, transparent);
	outline: none;
}

.netocore-product-search__thumb {
	flex-shrink: 0;
	width: 52px;
	height: 52px;
	overflow: hidden;
	border-radius: 10px;
	background: #f3f4f6;
	border: 1px solid color-mix(in srgb, var(--ncps-border) 80%, transparent);
}

.netocore-product-search__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.netocore-product-search__meta {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.netocore-product-search__name {
	margin: 0;
	color: var(--ncps-text);
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.45;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.netocore-product-search__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
}

.netocore-product-search__cat {
	color: var(--ncps-muted);
	font-size: 11.5px;
	font-weight: 500;
}

.netocore-product-search__badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 7px;
	border-radius: 999px;
	font-size: 10.5px;
	font-weight: 600;
	line-height: 1.3;
}

.netocore-product-search__badge--sale {
	background: color-mix(in srgb, #ef4444 12%, transparent);
	color: #dc2626;
}

.netocore-product-search__badge--out {
	background: color-mix(in srgb, #6b7280 14%, transparent);
	color: #4b5563;
}

.netocore-product-search__price {
	flex-shrink: 0;
	color: var(--ncps-primary-dark);
	font-size: 12.5px;
	font-weight: 700;
	white-space: nowrap;
	text-align: left;
}

.netocore-product-search__price del {
	display: block;
	color: var(--ncps-muted);
	font-size: 11px;
	font-weight: 500;
	opacity: 0.85;
}

.netocore-product-search__price ins {
	text-decoration: none;
	background: none;
}

.netocore-product-search__view-all {
	display: block;
	padding: 12px 16px;
	border-top: 1px solid var(--ncps-border);
	background: color-mix(in srgb, var(--ncps-primary) 5%, var(--ncps-surface));
	color: var(--ncps-primary) !important;
	font-size: 13px;
	font-weight: 600;
	text-align: center;
	text-decoration: none !important;
	transition: background 0.15s;
}

.netocore-product-search__view-all:hover {
	background: color-mix(in srgb, var(--ncps-primary) 10%, var(--ncps-surface));
}

/* iOS Safari zooms into inputs below 16px on focus */
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
	.netocore-product-search .netocore-product-search__input {
		font-size: 16px !important;
	}
}

/* Mobile / narrow header — dropdown directly under the field */
@media (max-width: 767px) {
	.netocore-product-search {
		z-index: 10050;
	}

	.netocore-product-search.is-open {
		z-index: 10060;
	}

	.netocore-product-search__box {
		min-height: 44px;
		padding: 0 12px;
	}

	.netocore-product-search__dropdown {
		position: absolute;
		top: calc(100% + 6px);
		right: 0;
		left: 0;
		bottom: auto;
		width: 100%;
		max-height: min(60vh, 360px);
		display: block;
		border-radius: 14px;
		z-index: 10061;
	}

	.netocore-product-search__results {
		max-height: min(52vh, 300px);
	}

	.netocore-product-search__thumb {
		width: 48px;
		height: 48px;
	}

	.netocore-product-search__price {
		font-size: 12px;
	}
}

@media (min-width: 768px) {
	.netocore-product-search__dropdown {
		position: absolute;
		top: calc(100% + 8px);
		right: 0;
		left: 0;
	}
}
