/* ==========================================================================
   MDM Live AJAX Search — Dropdown Styles
   ========================================================================== */

/* Wrapper injected by JS around the <input> */
.mdm-search-wrapper {
	position: relative;
	flex: 1 1 280px; /* mirrors the existing input flex rule */
}

/* Floating dropdown container */
.mdm-suggestions-dropdown {
	position: absolute;
	top: calc( 100% + 6px );
	left: 0;
	right: 0;
	z-index: 99999;

	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	box-shadow: 0 8px 32px rgba( 0, 0, 0, 0.12 ), 0 2px 8px rgba( 0, 0, 0, 0.06 );

	max-height: 420px;
	overflow-y: auto;
	overscroll-behavior: contain;

	/* Hidden by default — use visibility+opacity so pointer-events stay disabled while fading */
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	transform: translateY( -6px );
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}

/* Visible state (toggled by JS) */
.mdm-suggestions-dropdown.mdm-suggestions-open {
	visibility: visible;
	opacity: 1;
	pointer-events: auto;
	transform: translateY( 0 );
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
}

/* Custom scrollbar */
.mdm-suggestions-dropdown::-webkit-scrollbar        { width: 5px; }
.mdm-suggestions-dropdown::-webkit-scrollbar-track  { background: #f8fafc; border-radius: 0 10px 10px 0; }
.mdm-suggestions-dropdown::-webkit-scrollbar-thumb  { background: #cbd5e0; border-radius: 10px; }

/* ----- Suggestion item ----- */
.mdm-suggestion-item {
	display: block;
	padding: 11px 16px;
	text-decoration: none;
	color: inherit;
	border-bottom: 1px solid #f1f5f9;
	transition: background 0.1s;
	cursor: pointer;
	outline: none;
}

.mdm-suggestion-item:last-child {
	border-bottom: none;
}

.mdm-suggestion-item:hover,
.mdm-suggestion-item.mdm-suggestion-active {
	background: #eff6ff;
	text-decoration: none;
}

/* Top row: brand + badges */
.mdm-suggestion-top {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-bottom: 4px;
}

.mdm-suggestion-brand {
	font-size: 14px;
	font-weight: 700;
	color: #1e3a8a;
}

.mdm-suggestion-badge {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 600;
	white-space: nowrap;
}

.mdm-sg-strength {
	background: #dbeafe;
	color: #1e40af;
}

.mdm-sg-form {
	background: #f1f5f9;
	color: #475569;
}

/* Bottom row: generic · company · price */
.mdm-suggestion-bottom {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.mdm-suggestion-generic {
	font-size: 12px;
	color: #64748b;
}

.mdm-suggestion-sep {
	font-size: 11px;
	color: #cbd5e0;
}

.mdm-suggestion-company {
	font-size: 12px;
	color: #94a3b8;
}

.mdm-suggestion-price {
	margin-left: auto;
	font-size: 12px;
	font-weight: 700;
	color: #059669;
	white-space: nowrap;
}

/* ----- Loading state ----- */
.mdm-suggestion-loading {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	font-size: 13px;
	color: #64748b;
}

/* CSS-only spinner */
.mdm-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid #e2e8f0;
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: mdm-spin 0.7s linear infinite;
	flex-shrink: 0;
}

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

/* ----- Empty / error state ----- */
.mdm-suggestion-empty {
	padding: 16px;
	text-align: center;
	font-size: 13px;
	color: #94a3b8;
}

.mdm-suggestion-error {
	color: #dc2626;
}

/* ----- SELECT mode hint (shown on filter page only) ----- */
.mdm-suggestion-select-hint {
	margin-left: auto;
	font-size: 10px;
	font-weight: 600;
	color: #94a3b8;
	letter-spacing: 0.02em;
	flex-shrink: 0;
	white-space: nowrap;
}

.mdm-suggestion-select-mode:hover .mdm-suggestion-select-hint,
.mdm-suggestion-select-mode.mdm-suggestion-active .mdm-suggestion-select-hint {
	color: #2563eb;
}

/* ----- "View all results" footer link ----- */
.mdm-suggestion-footer {
	display: block;
	padding: 10px 16px;
	text-align: center;
	font-size: 12px;
	font-weight: 600;
	color: #2563eb;
	text-decoration: none;
	border-top: 1px solid #e2e8f0;
	background: #f8fafc;
	border-radius: 0 0 10px 10px;
	transition: background 0.1s;
}

.mdm-suggestion-footer:hover {
	background: #eff6ff;
	text-decoration: none;
	color: #1d4ed8;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media ( max-width: 640px ) {
	.mdm-search-wrapper {
		width: 100%;
		flex: 1 1 100%;
	}

	.mdm-suggestions-dropdown {
		/* On small screens pin to viewport edges */
		left: 0;
		right: 0;
		border-radius: 0 0 10px 10px;
	}

	.mdm-suggestion-price {
		margin-left: 0;
	}

	.mdm-suggestion-item {
		padding: 10px 14px;
	}
}
