/**
 * Product Search Suggest – UI
 * Tuỳ biến qua CSS variables trên .vdc-product-search-suggest
 */
.vdc-product-search-suggest {
	--vdc-pss-bg: #fff;
	--vdc-pss-border: #e0e0e0;
	--vdc-pss-radius: 9999px;
	--vdc-pss-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
	--vdc-pss-input-height: 48px;
	--vdc-pss-font-size: 15px;
	--vdc-pss-spacing: 12px;
	--vdc-pss-dropdown-bg: #fff;
	--vdc-pss-dropdown-radius: 12px;
	--vdc-pss-dropdown-max-height: 420px;
	--vdc-pss-item-hover-bg: #f5f5f5;
	--vdc-pss-price-color: #c00;
	--vdc-pss-sale-old-color: #999;
	--vdc-pss-subtitle-color: #666;
	--vdc-pss-skeleton-bg: #e8e8e8;
	position: relative;
	width: 100%;
	max-width: 100%;
	overflow: visible;
}

.vdc-pss-wrap {
	overflow: hidden;
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	height: 40px;
	background: var(--vdc-pss-bg);
	border: 1px solid var(--vdc-pss-border);
	border-radius: var(--vdc-pss-radius);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
	transition: border-color 0.2s, box-shadow 0.2s;
}

.vdc-product-search-suggest:focus-within .vdc-pss-wrap,
.vdc-pss-wrap:hover {
	border-color: #999;
	box-shadow: var(--vdc-pss-shadow);
}

.vdc-pss-input {
	flex: 1;
	width: 100%;
	height: 100%;
	padding: 0 6px 0 calc(var(--vdc-pss-spacing) + 4px);
	border: 0;
	background: transparent;
	font-size: var(--vdc-pss-font-size);
	color: #111;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.vdc-pss-input::placeholder {
	color: #888;
}

@media (max-width: 767px) {
	.vdc-pss-wrap,
	.vdc-pss-input {
		touch-action: manipulation;
	}
	.vdc-pss-input {
		pointer-events: auto;
		-webkit-user-select: text;
		user-select: text;
	}
}

/* Portal: dropdown render trong body để không bị cắt bởi overflow hidden của header.
   Khai báo lại CSS variables vì dropdown không còn trong .vdc-product-search-suggest. */
.vdc-pss-dropdown-portal {
	--vdc-pss-dropdown-bg: #fff;
	--vdc-pss-dropdown-radius: 12px;
	--vdc-pss-dropdown-max-height: 420px;
	--vdc-pss-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
	--vdc-pss-border: #e0e0e0;
	--vdc-pss-spacing: 12px;
	--vdc-pss-font-size: 15px;
	--vdc-pss-item-hover-bg: #f5f5f5;
	--vdc-pss-price-color: #c00;
	--vdc-pss-sale-old-color: #999;
	--vdc-pss-subtitle-color: #666;
	--vdc-pss-skeleton-bg: #e8e8e8;
	position: fixed;
	z-index: 999999;
	left: 0;
	top: 0;
	pointer-events: none;
}
.vdc-pss-dropdown-portal .vdc-pss-dropdown {
	position: relative;
	top: 0;
	left: 0;
	right: 0;
	width: 100%;
}

/* Dropdown */
.vdc-pss-dropdown {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	z-index: 999999;
	background: var(--vdc-pss-dropdown-bg);
	border-radius: var(--vdc-pss-dropdown-radius);
	box-shadow: var(--vdc-pss-shadow);
	border: 1px solid var(--vdc-pss-border);
	max-height: var(--vdc-pss-dropdown-max-height);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}

.vdc-pss-dropdown.is-open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	min-height: 80px;
	background: var(--vdc-pss-dropdown-bg);
	box-shadow: var(--vdc-pss-shadow);
}

.vdc-pss-dropdown-inner {
	max-height: var(--vdc-pss-dropdown-max-height);
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	scrollbar-color: #bbb transparent;
}

.vdc-pss-dropdown-inner::-webkit-scrollbar {
	width: 6px;
}

.vdc-pss-dropdown-inner::-webkit-scrollbar-track {
	background: transparent;
}

.vdc-pss-dropdown-inner::-webkit-scrollbar-thumb {
	background: #bbb;
	border-radius: 3px;
}

.vdc-pss-dropdown-inner::-webkit-scrollbar-thumb:hover {
	background: #999;
}

/* States */
.vdc-pss-state {
	display: none;
	padding: var(--vdc-pss-spacing);
}

.vdc-pss-state[data-state="idle"] {
	display: block;
	min-height: 0;
}

.vdc-pss-state[data-state="loading"],
.vdc-pss-state[data-state="empty"],
.vdc-pss-state[data-state="results"] {
	display: none;
}

.vdc-pss-dropdown.is-open .vdc-pss-state[data-state="loading"] {
	display: block;
}

.vdc-pss-dropdown.is-open .vdc-pss-state[data-state="empty"] {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 120px;
	padding: var(--vdc-pss-spacing) 16px;
}

.vdc-pss-dropdown.is-open .vdc-pss-state[data-state="results"] {
	display: block;
	padding: 8px 0;
}

.vdc-pss-empty-text {
	font-size: var(--vdc-pss-font-size);
	color: var(--vdc-pss-subtitle-color);
	text-align: center;
}

/* Skeleton */
.vdc-pss-skeleton {
	display: flex;
	flex-direction: column;
	gap: var(--vdc-pss-spacing);
}

.vdc-pss-skeleton-item {
	display: flex;
	align-items: center;
	gap: var(--vdc-pss-spacing);
}

.vdc-pss-skeleton-thumb {
	width: 48px;
	height: 48px;
	border-radius: 8px;
	background: var(--vdc-pss-skeleton-bg);
	animation: vdc-pss-skeleton-pulse 1.2s ease-in-out infinite;
}

.vdc-pss-skeleton-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.vdc-pss-skeleton-line {
	height: 14px;
	border-radius: 4px;
	background: var(--vdc-pss-skeleton-bg);
	animation: vdc-pss-skeleton-pulse 1.2s ease-in-out infinite;
}

.vdc-pss-skeleton-title {
	width: 75%;
}

.vdc-pss-skeleton-price {
	width: 40%;
}

@keyframes vdc-pss-skeleton-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

/* Result list */
.vdc-pss-list {
	display: flex;
	flex-direction: column;
}

.vdc-pss-item {
	display: flex;
	align-items: center;
	gap: var(--vdc-pss-spacing);
	padding: 10px var(--vdc-pss-spacing);
	margin: 0 4px;
	border-radius: 8px;
	cursor: pointer;
	text-decoration: none;
	color: inherit;
	transition: background 0.15s;
	-webkit-tap-highlight-color: transparent;
}

.vdc-pss-item:hover {
	background: var(--vdc-pss-item-hover-bg);
}

.vdc-pss-item:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.vdc-pss-item-thumb {
	width: 48px;
	height: 48px;
	flex-shrink: 0;
	border-radius: 8px;
	object-fit: cover;
	background: #f0f0f0;
}

.vdc-pss-item-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.vdc-pss-item-title {
	font-size: var(--vdc-pss-font-size);
	font-weight: 500;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: #111;
}

.vdc-pss-item-price-wrap {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 6px;
}

.vdc-pss-item-price {
	font-size: calc(var(--vdc-pss-font-size) + 1px);
	font-weight: 600;
	color: var(--vdc-pss-price-color);
}

.vdc-pss-item-price del {
	font-size: 12px;
	font-weight: 400;
	color: var(--vdc-pss-sale-old-color);
	text-decoration: line-through;
	margin-right: 4px;
}

.vdc-pss-item-badge {
	font-size: 11px;
	color: var(--vdc-pss-price-color);
	font-weight: 500;
}

.vdc-pss-item-subtitle {
	font-size: 12px;
	color: var(--vdc-pss-subtitle-color);
	line-height: 1.3;
}

/* Submit button */
.vdc-pss-submit {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 40px;
	height: 100%;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 0 var(--vdc-pss-radius) var(--vdc-pss-radius) 0;
	background: #1976d2;
	color: #fff;
	cursor: pointer;
	transition: background 0.2s;
	-webkit-tap-highlight-color: transparent;
}

.vdc-pss-submit:hover {
	background: #1565c0;
}

.vdc-pss-submit:focus {
	outline: 2px solid #1976d2;
	outline-offset: 2px;
}

.vdc-pss-submit svg {
	width: 18px;
	height: 18px;
}

/* View all results button */
.vdc-pss-view-all {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px var(--vdc-pss-spacing);
	margin: 4px 8px 8px;
	border-top: none;
	text-decoration: none;
	background: #1835C3;
	color: #fff;
	font-size: var(--vdc-pss-font-size);
	font-weight: 500;
	border-radius: 8px;
	transition: background 0.2s, transform 0.15s;
}

.vdc-pss-view-all:hover {
	background: #1835C3;
	color: #fff;
	transform: translateY(-1px);
}

.vdc-pss-view-all:focus {
	outline: 2px solid #1835C3;
	outline-offset: 2px;
}

.vdc-pss-view-all svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

/* Mobile: full width, tap friendly */
@media (max-width: 767px) {
	.vdc-product-search-suggest {
		--vdc-pss-input-height: 46px;
		--vdc-pss-spacing: 10px;
	}

	.vdc-pss-item {
		padding: 12px var(--vdc-pss-spacing);
		min-height: 56px;
	}

	.vdc-pss-submit {
		width: 44px;
		height: 100%;
	}
}
