/**
 * Layali Search — input pill + dropdown styles.
 * Token-bound (--ly-*). Falls back to literal values if the theme isn't active.
 */

/* =============================================================================
   Shell
   ============================================================================= */

.ly-search {
	position: relative;
	display: inline-block;
	width: 360px;
	max-width: 100%;
	font-family: var(--ly-text-body, 'DM Sans', sans-serif);
}

/* On phones the header search should fill its row (Passage du Désir treatment).
   It's a content-sized flex item in the Elementor header, so make both the
   widget (flex item) and the field full-width under the mobile breakpoint. */
@media ( max-width: 767px ) {
	.elementor-widget:has( > .elementor-widget-container > .ly-search ) {
		width: 100%;
	}
	.ly-search {
		display: block;
		width: 100% !important;
	}
}

.ly-search__form {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 10px;
	background: var(--ly-color-bg, #ffffff);
	border: 1.5px solid var(--ly-color-primary, #53225e);
	border-radius: 999px;
	padding: 10px 20px;
	/* Required for keyboard focus indication (WCAG 2.1 SC 2.4.7). The input's
	   own :focus-visible ring is suppressed below for visual cleanliness;
	   focus is signalled instead by a subtle border-color shift on the form
	   when any descendant is focused. */
	transition: border-color var(--ly-duration-base, 200ms) ease;
}

.ly-search__form:focus-within {
	border-color: var(--ly-color-secondary, #ff7477);
}

.ly-search__icon {
	display: inline-flex;
	align-items: center;
	color: var(--ly-color-primary, #53225e);
	pointer-events: none;
}

.ly-search__icon svg {
	width: 20px;
	height: 20px;
	display: block;
}

.ly-search__input {
	flex: 1;
	min-width: 0;
	background: transparent;
	border: 0;
	outline: 0;
	color: var(--ly-color-text, #53225e);
	font-family: inherit;
	font-size: 0.95rem;
	line-height: 1.2;
	padding: 0;
}

/* Suppress the theme's global :focus-visible coral outline on this input.
   The pill border already visually frames the field and the cursor indicates
   where typing goes — no extra ring needed. Keyboard focus is still detectable
   via the caret position. */
.ly-search__input:focus-visible,
.ly-search__input:focus {
	outline: none;
	box-shadow: none;
}

.ly-search__input::placeholder {
	color: var(--ly-color-text, #53225e);
	opacity: 0.7;
}

/* Hide native search clear button (we'd add our own if needed) */
.ly-search__input::-webkit-search-decoration,
.ly-search__input::-webkit-search-cancel-button,
.ly-search__input::-webkit-search-results-button,
.ly-search__input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
}

/* =============================================================================
   Dropdown
   ============================================================================= */

.ly-search__dropdown {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: var(--ly-z-overlay, 200);
	background: var(--ly-color-bg, #ffffff);
	border: 1px solid var(--ly-color-border, #e6e6e8);
	border-radius: 16px;
	box-shadow: var(--ly-shadow-lg, 0 12px 32px rgba(83, 34, 94, 0.12));
	max-height: 480px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ly-search__dropdown[hidden] {
	display: none;
}

.ly-search__section-label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px 6px;
	font-size: 0.7rem;
	font-weight: 600;
	color: var(--ly-color-text-muted, #4a4a52);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ly-search__clear-recent {
	background: transparent;
	border: 0;
	color: var(--ly-color-primary, #53225e);
	font-family: inherit;
	font-size: 0.7rem;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	cursor: pointer;
	padding: 0;
}

.ly-search__clear-recent:hover {
	color: var(--ly-color-secondary, #ff7477);
}

.ly-search__list {
	list-style: none;
	margin: 0;
	padding: 4px 0;
}

/* =============================================================================
   Result row
   ============================================================================= */

.ly-search__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 16px;
	cursor: pointer;
	color: inherit;
	text-decoration: none;
	transition: background-color var(--ly-duration-fast, 120ms) ease;
}

.ly-search__item:hover,
.ly-search__item[aria-selected="true"] {
	background: var(--ly-color-surface, #fbf5ef);
}

.ly-search__item-thumb {
	width: 44px;
	height: 44px;
	flex-shrink: 0;
	border-radius: 8px;
	overflow: hidden;
	background: var(--ly-color-surface, #fbf5ef);
	display: flex;
	align-items: center;
	justify-content: center;
}

.ly-search__item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.ly-search__item-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ly-search__item-name {
	font-family: var(--ly-text-heading, var(--ly-font-display, 'Bricolage Grotesque'), sans-serif);
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--ly-color-primary, #53225e);
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ly-search__item-price {
	font-size: 0.85rem;
	color: var(--ly-color-secondary, #ff7477);
	font-weight: 600;
}

.ly-search__item-price del,
.ly-search__item-price del .amount {
	color: var(--ly-color-text-muted, #4a4a52);
	font-weight: 400;
	margin-right: 6px;
}

.ly-search__item-price ins,
.ly-search__item-price ins .amount,
.ly-search__item-price .amount {
	text-decoration: none;
}

/* =============================================================================
   Recent search row (similar shape to results)
   ============================================================================= */

.ly-search__recent-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px;
	background: transparent;
	border: 0;
	width: 100%;
	text-align: left;
	cursor: pointer;
	color: var(--ly-color-text, #53225e);
	font-family: inherit;
	font-size: 0.9rem;
	transition: background-color var(--ly-duration-fast, 120ms) ease;
}

.ly-search__recent-item:hover,
.ly-search__recent-item[aria-selected="true"] {
	background: var(--ly-color-surface, #fbf5ef);
}

.ly-search__recent-icon {
	width: 16px;
	height: 16px;
	color: var(--ly-color-text-muted, #4a4a52);
	display: inline-flex;
	flex-shrink: 0;
}

/* =============================================================================
   Empty / loading state
   ============================================================================= */

.ly-search__status {
	padding: 16px;
	text-align: center;
	color: var(--ly-color-text-muted, #4a4a52);
	font-size: 0.875rem;
}

.ly-search__see-all {
	display: block;
	padding: 12px 16px;
	border-top: 1px solid var(--ly-color-border, #e6e6e8);
	color: var(--ly-color-primary, #53225e);
	text-decoration: none;
	font-size: 0.875rem;
	font-weight: 500;
	transition: background-color var(--ly-duration-fast, 120ms) ease;
}

.ly-search__see-all:hover,
.ly-search__see-all[aria-selected="true"] {
	background: var(--ly-color-surface, #fbf5ef);
}

.ly-search__see-all strong {
	color: var(--ly-color-secondary, #ff7477);
}

/* =============================================================================
   Loading spinner
   ============================================================================= */

.ly-search__form[data-ly-search-busy="1"] .ly-search__icon::after {
	content: "";
	display: block;
	width: 14px;
	height: 14px;
	border: 2px solid var(--ly-color-border, #e6e6e8);
	border-top-color: var(--ly-color-primary, #53225e);
	border-radius: 999px;
	margin-left: -16px;
	animation: ly-search-spin 600ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.ly-search__form[data-ly-search-busy="1"] .ly-search__icon::after {
		animation: none;
	}
}

/* =============================================================================
   Mobile
   ============================================================================= */

@media (max-width: 480px) {
	.ly-search {
		width: 100%;
	}

	.ly-search__dropdown {
		max-height: 70vh;
	}
}
