/**
 * HVM Commercial Search — frontend styles.
 *
 * Self-contained: does not assume undocumented design-system tokens from
 * variables.css (out of scope for this change). Local custom properties
 * are defined below with sensible defaults and can be re-pointed at the
 * shared HVM design tokens later without touching structural rules.
 */

.hvm-search-wrap {
	--hvm-search-accent: #2455e6;
	--hvm-search-text: #1f2328;
	--hvm-search-muted: #6b7280;
	--hvm-search-border: #e2e4e8;
	--hvm-search-bg: #ffffff;
	--hvm-search-danger: #c0392b;
	--hvm-search-success: #1e8e3e;
	--hvm-search-radius: 10px;
	--hvm-search-shadow: 0 12px 32px rgba(20, 20, 30, 0.14);

	position: relative;
	display: inline-flex;
	align-items: center;
	font-family: inherit;
	z-index: 100;
}

/* ---------------------------------------------------------------------- */
/* Trigger (mobile icon)                                                  */
/* ---------------------------------------------------------------------- */

.hvm-search-trigger {
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: none;
	background: transparent;
	cursor: pointer;
	border-radius: 50%;
	transition: background-color 150ms ease;
}

.hvm-search-trigger:hover,
.hvm-search-trigger:focus-visible {
	background-color: rgba(0, 0, 0, 0.06);
}

.hvm-search-trigger__icon {
	width: 18px;
	height: 18px;
	display: inline-block;
	border: 2px solid currentColor;
	border-radius: 50%;
	position: relative;
}

.hvm-search-trigger__icon::after {
	content: '';
	position: absolute;
	right: -6px;
	bottom: -6px;
	width: 7px;
	height: 2px;
	background: currentColor;
	transform: rotate(45deg);
}

/* ---------------------------------------------------------------------- */
/* Input field                                                            */
/* ---------------------------------------------------------------------- */

.hvm-search-field-wrap {
	position: relative;
	display: flex;
	align-items: center;
	width: 260px;
	max-width: 100%;
}

.hvm-search-icon {
	position: absolute;
	left: 12px;
	width: 14px;
	height: 14px;
	border: 2px solid var(--hvm-search-muted);
	border-radius: 50%;
	pointer-events: none;
}

.hvm-search-icon::after {
	content: '';
	position: absolute;
	right: -5px;
	bottom: -5px;
	width: 6px;
	height: 2px;
	background: var(--hvm-search-muted);
	transform: rotate(45deg);
}

.hvm-search-input {
	width: 100%;
	padding: 9px 34px 9px 32px;
	border: 1px solid var(--hvm-search-border);
	border-radius: 999px;
	font-size: 14px;
	color: var(--hvm-search-text);
	background-color: var(--hvm-search-bg);
	transition: border-color 150ms ease, box-shadow 150ms ease;
}

.hvm-search-input:focus {
	outline: none;
	border-color: var(--hvm-search-accent);
	box-shadow: 0 0 0 3px rgba(36, 85, 230, 0.15);
}

.hvm-search-clear,
.hvm-search-close {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	border: none;
	background: transparent;
	color: var(--hvm-search-muted);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
	border-radius: 50%;
}

.hvm-search-clear:hover,
.hvm-search-close:hover {
	color: var(--hvm-search-text);
	background-color: rgba(0, 0, 0, 0.06);
}

.hvm-search-close {
	display: none;
}

/* ---------------------------------------------------------------------- */
/* Results panel (desktop / tablet: floating)                             */
/* ---------------------------------------------------------------------- */

.hvm-search-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	width: 420px;
	max-width: 90vw;
	max-height: 70vh;
	overflow-y: auto;
	background: var(--hvm-search-bg);
	border-radius: var(--hvm-search-radius);
	box-shadow: var(--hvm-search-shadow);
	border: 1px solid var(--hvm-search-border);
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity 160ms ease, transform 160ms ease;
	padding: 8px 0;
}

.hvm-search-panel.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.hvm-search-status {
	padding: 8px 16px;
	font-size: 13px;
	color: var(--hvm-search-muted);
}

.hvm-search-panel.has-error .hvm-search-status {
	color: var(--hvm-search-danger);
	font-weight: 600;
}

.hvm-search-panel.is-empty .hvm-search-status {
	color: var(--hvm-search-muted);
}

.hvm-search-panel.has-results .hvm-search-status {
	/* Visually hidden but still announced via aria-live. */
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.hvm-search-results {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* ---------------------------------------------------------------------- */
/* Loading skeleton                                                       */
/* ---------------------------------------------------------------------- */

.hvm-search-skeleton {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	opacity: 0.6;
}

.hvm-search-skeleton__thumb {
	width: 48px;
	height: 48px;
	border-radius: 6px;
	background: linear-gradient(90deg, #eee 25%, #f5f5f5 37%, #eee 63%);
	background-size: 200% 100%;
	animation: hvm-search-shimmer 1.4s ease infinite;
	flex-shrink: 0;
}

.hvm-search-skeleton__lines {
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
}

.hvm-search-skeleton__lines span {
	display: block;
	height: 10px;
	border-radius: 4px;
	background: linear-gradient(90deg, #eee 25%, #f5f5f5 37%, #eee 63%);
	background-size: 200% 100%;
	animation: hvm-search-shimmer 1.4s ease infinite;
}

.hvm-search-skeleton__lines span:first-child {
	width: 70%;
}

.hvm-search-skeleton__lines span:last-child {
	width: 40%;
}

@keyframes hvm-search-shimmer {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* ---------------------------------------------------------------------- */
/* Result row / product card                                              */
/* ---------------------------------------------------------------------- */

.hvm-search-result {
	border-bottom: 1px solid var(--hvm-search-border);
}

.hvm-search-result:last-child {
	border-bottom: none;
}

.hvm-search-result__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	text-decoration: none;
	color: inherit;
	transition: background-color 120ms ease;
}

.hvm-search-result:hover .hvm-search-result__link,
.hvm-search-result.is-active .hvm-search-result__link {
	background-color: rgba(36, 85, 230, 0.06);
}

.hvm-search-result.is-active {
	outline: 2px solid var(--hvm-search-accent);
	outline-offset: -2px;
	border-radius: 6px;
}

.hvm-search-result__image {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: 6px;
	overflow: hidden;
	background: #f2f3f5;
}

.hvm-search-result__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.hvm-search-result__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.hvm-search-result__name {
	font-size: 14px;
	font-weight: 600;
	color: var(--hvm-search-text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hvm-search-result__category {
	font-size: 12px;
	color: var(--hvm-search-muted);
	margin-top: 2px;
}

.hvm-search-result__price {
	font-size: 13px;
	margin-top: 4px;
}

.hvm-search-result__price ins {
	text-decoration: none;
	font-weight: 600;
}

.hvm-search-result__price del {
	opacity: 0.6;
	margin-right: 4px;
}

.hvm-search-result__meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 4px;
	font-size: 11px;
}

.hvm-search-result__sku {
	color: var(--hvm-search-muted);
}

.hvm-search-result__stock {
	font-weight: 600;
	padding: 1px 6px;
	border-radius: 999px;
}

.hvm-search-result__stock.is-available {
	color: var(--hvm-search-success);
	background: rgba(30, 142, 62, 0.1);
}

.hvm-search-result__stock.is-out-of-stock {
	color: var(--hvm-search-danger);
	background: rgba(192, 57, 43, 0.1);
}

.hvm-search-result__cta {
	flex-shrink: 0;
	font-size: 12px;
	font-weight: 600;
	color: var(--hvm-search-accent);
	white-space: nowrap;
}

.hvm-search-viewall-item {
	border-top: 1px solid var(--hvm-search-border);
	margin-top: 4px;
}

.hvm-search-viewall {
	display: block;
	padding: 12px 16px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	color: var(--hvm-search-accent);
	text-decoration: none;
}

.hvm-search-viewall:hover {
	text-decoration: underline;
}

/* ---------------------------------------------------------------------- */
/* Tablet                                                                 */
/* ---------------------------------------------------------------------- */

@media (max-width: 1024px) {
	.hvm-search-field-wrap {
		width: 220px;
	}

	.hvm-search-panel {
		width: 360px;
	}
}

/* ---------------------------------------------------------------------- */
/* Mobile: full-screen overlay                                            */
/* ---------------------------------------------------------------------- */

@media (max-width: 782px) {
	.hvm-search-wrap.is-mobile .hvm-search-trigger {
		display: inline-flex;
	}

	.hvm-search-wrap.is-mobile .hvm-search-field-wrap {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		width: auto;
		padding: 10px 52px 10px 12px;
		background: var(--hvm-search-bg);
		border-bottom: 1px solid var(--hvm-search-border);
		z-index: 10000;
		opacity: 0;
		pointer-events: none;
		transition: opacity 160ms ease;
	}

	.hvm-search-wrap.is-mobile.is-open .hvm-search-field-wrap {
		opacity: 1;
		pointer-events: auto;
	}

	.hvm-search-wrap.is-mobile .hvm-search-close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	.hvm-search-wrap.is-mobile .hvm-search-panel {
		position: fixed;
		top: 56px;
		left: 0;
		right: 0;
		bottom: 0;
		width: auto;
		max-width: none;
		max-height: none;
		border-radius: 0;
		border: none;
		box-shadow: none;
		transform: none;
		z-index: 9999;
	}

	.hvm-search-wrap.is-mobile .hvm-search-panel.is-visible {
		transform: none;
	}

	body.hvm-search-locked {
		overflow: hidden;
	}
}

/* ---------------------------------------------------------------------- */
/* Reduced motion                                                         */
/* ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.hvm-search-panel,
	.hvm-search-result__link,
	.hvm-search-trigger,
	.hvm-search-skeleton__thumb,
	.hvm-search-skeleton__lines span {
		transition: none !important;
		animation: none !important;
	}
}
