/**
 * Ferrari Music Search — Frontend
 * Namespace: fm-search-
 */

.fm-search-wrapper {
	--fm-input-bg: #ececec;
	--fm-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
	position: relative;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	background: var(--fm-bg, #ffffff);
	border-radius: var(--fm-radius, 30px);
	padding: 12px 16px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
	font-family: inherit;
}

.fm-search-wrapper *,
.fm-search-wrapper *::before,
.fm-search-wrapper *::after {
	box-sizing: border-box;
}

.fm-search-form {
	margin: 0;
	padding: 0;
}

.fm-search-inner {
	position: relative;
	display: flex;
	align-items: center;
}

.fm-search-icon {
	position: absolute;
	left: 20px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #666;
	pointer-events: none;
}

.fm-search-icon svg {
	display: block;
	width: 22px;
	height: 22px;
}

.fm-search-input {
	width: 100%;
	height: var(--fm-bar-height, 60px);
	padding: 0 48px 0 54px;
	border: none;
	border-radius: calc(var(--fm-radius, 30px) - 4px);
	background: var(--fm-input-bg);
	color: var(--fm-text, #333);
	font-size: 16px;
	line-height: 1.4;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	transition: box-shadow 0.2s ease, background 0.2s ease;
}

.fm-search-input::placeholder {
	color: var(--fm-placeholder, #888);
	opacity: 1;
}

.fm-search-input:focus {
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.fm-search-input::-webkit-search-decoration,
.fm-search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.fm-search-loader {
	position: absolute;
	right: 18px;
	top: 50%;
	transform: translateY(-50%);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease;
	z-index: 2;
}

.fm-search-wrapper.is-loading .fm-search-loader {
	opacity: 1;
	visibility: visible;
}

.fm-search-spinner {
	display: block;
	width: 22px;
	height: 22px;
	border: 2px solid rgba(0, 0, 0, 0.1);
	border-top-color: #333;
	border-radius: 50%;
	animation: fm-search-spin 0.7s linear infinite;
}

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

/* Dropdown */
.fm-search-dropdown {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 99999;
	background: #fff;
	border-radius: 16px;
	box-shadow: var(--fm-shadow);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.fm-search-wrapper.is-open .fm-search-dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.fm-search-dropdown[hidden] {
	display: none !important;
}

.fm-search-wrapper.is-open .fm-search-dropdown[hidden] {
	display: block !important;
}

.fm-search-results {
	max-height: 420px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* Result item */
.fm-search-result-item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 16px;
	text-decoration: none;
	color: var(--fm-text, #333);
	border-bottom: 1px solid #f0f0f0;
	transition: background 0.15s ease;
	cursor: pointer;
}

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

.fm-search-result-item:hover,
.fm-search-result-item.is-active {
	background: var(--fm-hover, #f0f0f0);
}

.fm-search-result-thumb {
	flex-shrink: 0;
	width: 60px;
	height: 60px;
	border-radius: 8px;
	overflow: hidden;
	background: #f5f5f5;
}

.fm-search-result-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.fm-search-result-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.fm-search-result-title {
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: inherit;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fm-search-result-sku {
	font-size: 12px;
	color: #777;
}

.fm-search-result-excerpt {
	font-size: 12px;
	color: #888;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.fm-search-result-categories {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.fm-search-result-cat-badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 2px 8px;
	border-radius: 20px;
	background: #eee;
	color: #555;
}

.fm-search-result-price {
	flex-shrink: 0;
	font-size: 14px;
	font-weight: 700;
	color: inherit;
	text-align: right;
}

.fm-search-result-price .woocommerce-Price-amount {
	font-size: inherit;
}

/* No results */
.fm-search-no-results {
	padding: 24px 20px;
	text-align: center;
}

.fm-search-no-results-text {
	margin: 0 0 12px;
	font-size: 15px;
	color: #666;
}

.fm-search-view-all {
	display: inline-block;
	padding: 10px 20px;
	background: #333;
	color: #fff !important;
	text-decoration: none;
	border-radius: 24px;
	font-size: 14px;
	font-weight: 600;
	transition: background 0.2s ease;
}

.fm-search-view-all:hover {
	background: #000;
	color: #fff !important;
}

/* Divi compatibility */
.et_pb_module .fm-search-wrapper,
.et_pb_row .fm-search-wrapper,
#et-top-navigation .fm-search-wrapper,
.et_mobile_menu .fm-search-wrapper {
	position: relative;
	z-index: 100;
}

/* Mobile */
@media (max-width: 768px) {
	.fm-search-wrapper {
		padding: 10px 12px;
		border-radius: calc(var(--fm-radius, 30px) * 0.85);
	}

	.fm-search-input {
		height: var(--fm-bar-height-mobile, 50px);
		font-size: 16px;
		padding-left: 48px;
	}

	.fm-search-icon {
		left: 16px;
	}

	.fm-search-icon svg {
		width: 20px;
		height: 20px;
	}

	.fm-search-dropdown {
		position: fixed;
		top: auto;
		left: 12px;
		right: 12px;
		max-height: 70vh;
	}

	.fm-search-results {
		max-height: calc(70vh - 80px);
	}

	.fm-search-result-item {
		padding: 10px 12px;
		gap: 10px;
	}

	.fm-search-result-thumb {
		width: 50px;
		height: 50px;
	}
}
