/* IDE Advanced Search — base styles */

/*
 * Wrapper: establishes a local stacking context for the spinner and input
 * focus ring.  The dropdown panel is rendered as a body-level portal by JS,
 * so isolation:isolate here only applies to field-level elements.
 */
.ide-advanced-search {
	position: relative;
	max-width: 320px;
	width: 100%;
	font-family: inherit;
	font-size: 1rem;
	isolation: isolate;
}

/* ---- Field wrapper ---- */

.ide-advanced-search__field {
    position: relative;
    display: flex;
    align-items: center;
}

.ide-advanced-search__field::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235679af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}

.ide-advanced-search__field:has(
    .ide-advanced-search__spinner:not([hidden])
)::after {
    opacity: 0;
}

.ide-advanced-search__input {
	width: 100%;
	max-width:320px;
	padding: 0.3rem 2.5rem 0.3rem 0.85rem;
	border: 1px solid #92aacc;
	border-radius: 4px!important;
	font-size: 0.9rem;
	line-height: 1.4;
	outline: none;
	background-color: #fff;
	color: #111;
	transition: border-color 0.2s;
	box-sizing: border-box;
}

.ide-advanced-search__input:focus {
	border-color: #0073aa;
	box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* ---- Spinner ---- */

.ide-advanced-search__spinner {
	position: absolute;
	right: 0.75rem;
	width: 1rem;
	height: 1rem;
	border: 2px solid #ccc;
	border-top-color: #0073aa;
	border-radius: 50%;
	animation: ide-as-spin 0.6s linear infinite;
	pointer-events: none;
}

/* Spinner is hidden by default via the HTML `hidden` attribute set in PHP.
   JS calls spinner.hidden = false only while a fetch is in flight. */
.ide-advanced-search__spinner[hidden] {
	display: none;
}

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

/* ---- Portal (body-level results panel) ----
 *
 * Appended to <body> by JS on init.
 *
 * position:fixed + z-index:2147483000 ensures the panel floats above every
 * stacking context in the page, including:
 *   - Avada sticky header   (z-index ~10000)
 *   - Fusion Builder rows
 *   - Newsletter popup blocks
 *   - Footer sticky bars
 *
 * JS sets: top / left / width  (desktop)
 *           bottom / left / right (mobile ≤480 px)
 */
.ide-advanced-search__portal {
	position: fixed;
	z-index: 2147483000;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	max-height: 420px;
	overflow-y: auto;
	overflow-x: hidden;
}

.ide-advanced-search__portal[hidden] {
	display: none;
}

/* ---- Results container (direct child of portal) ---- */

.ide-advanced-search__results {
	/* No extra padding needed — groups handle their own spacing. */
}

/* ---- No results ---- */

.ide-advanced-search__no-results {
	padding: 1rem;
	margin: 0;
	color: #666;
	font-size: 0.9rem;
	text-align: center;
}

/* ---- Groups ---- */

.ide-advanced-search__group {
	padding: 0.5rem 0;
}

.ide-advanced-search__group + .ide-advanced-search__group {
	border-top: 2px solid #f0f0f0;
}

.ide-advanced-search__group-label {
	margin: 0;
	padding: 0.4rem 0.85rem 0.25rem;
	font-size: 0.68rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: #999;
}

.ide-advanced-search__group-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* ---- Items ---- */

.ide-advanced-search__item {
	margin: 0;
}

.ide-advanced-search__item-link {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	padding: 0.65rem 0.85rem;
	text-decoration: none;
	color: inherit;
	transition: background-color 0.12s;
}

.ide-advanced-search__item-link:hover,
.ide-advanced-search__item.is-active .ide-advanced-search__item-link {
	background-color: #f0f4f8;
}

.ide-advanced-search__item-img {
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 3px;
	flex-shrink: 0;
	background: #eee;
}

.ide-advanced-search__item-text {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	min-width: 0;
	flex: 1;
}

.ide-advanced-search__item-title {
	font-size: 0.92rem;
	font-weight: 600;
	color: #111;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.3;
}

.ide-advanced-search__item-excerpt {
	font-size: 0.76rem;
	color: #777;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.35;
}

/* ---- "View all results" footer (inside portal) ---- */

.ide-advanced-search__view-all {
	border-top: 1px solid #f0f0f0;
	padding: 0;
}

.ide-advanced-search__view-all-link {
	display: block;
	padding: 0.65rem 0.85rem;
	font-size: 0.85rem;
	font-weight: 600;
	color: #0073aa;
	text-decoration: none;
	text-align: center;
	transition: background-color 0.12s;
}

.ide-advanced-search__view-all-link:hover {
	background-color: #f0f4f8;
	text-decoration: underline;
}

/* ---- Mobile: full-width bottom sheet ---- */

@media (max-width: 480px) {
	.ide-advanced-search__portal {
		/* JS sets bottom:0, left:0, right:0, width:100% */
		border-radius: 12px 12px 0 0;
		max-height: 65vh;
		box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
	}
}

/* =============================================================================
   Full results page — [ide_advanced_search_results]
   ============================================================================= */

.ide-advanced-search-results {
	max-width: 1100px;
	width: 100%;
	font-family: inherit;
	font-size: 1rem;
}

/*
 * Header search box: right-aligned inside the Avada header column.
 * (Previously achieved with display:flex + justify-content:flex-end on
 * .ide-advanced-search-results above, which turned the full results page
 * into a horizontal row: search box left, summary and results squeezed on
 * the right. Alignment now belongs to the widget itself, so the results
 * wrapper stays a normal block.)
 */
.fusion-tb-header .ide-advanced-search {
	margin-left: auto;
}

/*
 * Search box on the results page: full width of the results container (same
 * width as the group index below it) and a bit taller than the header one.
 * Everything is scoped to .ide-advanced-search-results, so the header widget
 * ([ide_advanced_search]) keeps its own 320px sizing untouched.
 */
.ide-advanced-search-results .ide-advanced-search {
	max-width: none;
	margin-bottom: 1.25rem;
}

.ide-advanced-search-results .ide-advanced-search__input {
	max-width: none;
	min-height: 3rem; /* 48px */
	padding: 0.65rem 3.25rem 0.65rem 1.1rem;
	font-size: 1rem;
	border-radius: 6px !important;
}

.ide-advanced-search-results .ide-advanced-search__field::after {
	right: 1rem;
	width: 20px;
	height: 20px;
}

.ide-advanced-search-results .ide-advanced-search__spinner {
	right: calc(1rem + 2px);
}

/* ---- Search form ---- */

.ide-advanced-search-results__form {
	margin-bottom: 1.5rem;
}

.ide-advanced-search-results__form-row {
	display: flex;
	gap: 0.5rem;
	align-items: center;
	flex-wrap: wrap;
}

.ide-advanced-search-results__input {
	flex: 1 1 240px;
	padding: 0.55rem 0.85rem;
	border: 1px solid #ccc;
	border-radius: 4px;
	font-size: 1rem;
	line-height: 1.4;
	outline: none;
	background: #fff;
	color: #111;
	transition: border-color 0.2s;
	box-sizing: border-box;
}

.ide-advanced-search-results__input:focus {
	border-color: #0073aa;
	box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.ide-advanced-search-results__submit {
	padding: 0.55rem 1.25rem;
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 4px;
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s;
	white-space: nowrap;
}

.ide-advanced-search-results__submit:hover {
	background: #005a87;
}

/* ---- Summary / prompt ---- */

.ide-advanced-search-results__summary {
	margin: 0 0 1.25rem;
	font-size: 0.95rem;
	color: #444;
}

.ide-advanced-search-results__no-results,
.ide-advanced-search-results__prompt {
	display:none;
	margin: 0 0 1.25rem;
	color: #666;
	font-size: 0.95rem;
}

/* ---- Group index / nav ---- */

.ide-advanced-search-results__index {
	margin: 0 0 1.5rem;
	padding: 0.6rem 0.85rem;
	background: #f6f8fa;
	border: 1px solid #e0e4e8;
	border-radius: 4px;
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem 0.85rem;
	align-items: center;
}

.ide-advanced-search-results__index-link {
	font-size: 0.88rem;
	color: #0073aa;
	text-decoration: none;
	white-space: nowrap;
}

.ide-advanced-search-results__index-link:hover {
	text-decoration: underline;
}

/* ---- Back to top link ---- */

.ide-advanced-search-results__back-to-index {
	display: inline-block;
	margin: 0.2rem 0 0.6rem;
	font-size: 0.78rem;
	color: #aaa;
	text-decoration: none;
}

.ide-advanced-search-results__back-to-index:hover {
	color: #0073aa;
	text-decoration: underline;
}

/* ---- Groups ---- */

.ide-advanced-search-results__group {
	margin-bottom: 1.5rem;
}

.ide-advanced-search-results__group-title {
	margin: 0 0 0.75rem;
	padding-bottom: 0.4rem;
	border-bottom: 2px solid #e0e0e0;
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #555;
	scroll-margin-top: 120px;
}

/* ---- Items ---- */

.ide-advanced-search-results__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 2px 20px;
}

.ide-advanced-search-results__item {
	margin: 0;
}

.ide-advanced-search-results__item-link {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 0.7rem 0.5rem;
	text-decoration: none;
	color: inherit;
	border-radius: 4px;
	transition: background-color 0.12s;
}

.ide-advanced-search-results__item-link:hover {
	background-color: #f4f7fa;
}

.ide-advanced-search-results__item-img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 3px;
	flex-shrink: 0;
	background: #eee;
}

.ide-advanced-search-results__item-body {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.ide-advanced-search-results__item-title {
	font-size: 0.97rem;
	font-weight: 600;
	color: #0073aa;
	line-height: 1.3;
}

.ide-advanced-search-results__item-link:hover .ide-advanced-search-results__item-title {
	text-decoration: underline;
}

.ide-advanced-search-results__item-excerpt {
	font-size: 0.85rem;
	color: #666;
	line-height: 1.45;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
	.ide-advanced-search-results__item-img {
		width: 44px;
		height: 44px;
	}

	.ide-advanced-search-results__submit {
		width: 100%;
	}

	.ide-advanced-search-results__form-row {
		flex-direction: column;
		align-items: stretch;
	}

	.ide-advanced-search-results__list {
		grid-template-columns: 1fr;
	}
}
