/* ==========================================================================
   Swift AJAX Search
   All selectors are prefixed with .sas- / [data-sas-*] so this stylesheet
   can never collide with the active theme.
   ========================================================================== */

:root {
	--sas-accent: #02608E;
	--sas-accent-soft: rgba(2, 96, 142, 0.10);
	--sas-teal: #0D8A72;
	--sas-teal-soft: rgba(13, 138, 114, 0.10);
	--sas-amber: #B45309;
	--sas-amber-soft: rgba(180, 83, 9, 0.10);

	--sas-bg-overlay: rgba(10, 16, 24, 0.55);
	--sas-surface: #FFFFFF;
	--sas-surface-2: #F1F3F5;
	--sas-border: #E5E8EC;
	--sas-text: #12161C;
	--sas-text-dim: #667085;
	--sas-max-width: 1390px;
}

/* ---------- Trigger icon (the button you place on your site) ---------- */
.sas-trigger-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--sas-accent);
	color: #ffffff;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	transition: background-color 0.2s ease, transform 0.15s ease;
	margin-left:10px;
	margin-top:5px;
}

.sas-trigger-icon:hover {
	background-color: #000000;
	color: #ffffff;
	transform: scale(1.06);
}

.sas-trigger-icon:focus-visible {
	outline: 2px solid var(--sas-accent);
	outline-offset: 3px;
}

body.sas-lock-scroll {
	overflow: hidden;
}

/* ---------- Overlay ---------- */
.sas-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	justify-content: center;
	padding: 28px 20px 40px;
	background: var(--sas-bg-overlay);
	backdrop-filter: blur(10px) saturate(140%);
	-webkit-backdrop-filter: blur(10px) saturate(140%);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	overflow-y: auto;
	box-sizing: border-box;
}

.sas-overlay *,
.sas-overlay *::before,
.sas-overlay *::after {
	box-sizing: border-box;
}

.sas-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

/* Column that holds the two stacked pieces: the search bar, then (once
   there's a query) the results panel below it. */
.sas-shell {
	width: 100%;
	max-width: var(--sas-max-width);
	display: flex;
	flex-direction: column;
	gap: 16px;
	transform: translateY(-14px);
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}

.sas-overlay.is-open .sas-shell {
	transform: translateY(0);
	opacity: 1;
}

/* ---------- Search bar ---------- */
.sas-searchbar {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--sas-surface);
	border-radius: 20px;
	padding: 8px 8px 8px 20px;
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.02);
	transition: box-shadow 0.2s ease;
}

.sas-searchbar:focus-within {
	box-shadow: 0 0 0 4px var(--sas-accent-soft), 0 30px 80px -20px rgba(0, 0, 0, 0.4);
}

/* Single left-side control: magnifying glass when idle, turns into a
   clear (×) once there's a query. */
.sas-icon-btn {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--sas-text-dim);
	cursor: pointer;
	padding: 0;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.sas-icon-btn:hover {
	background: var(--sas-border);
}

.sas-icon-clear {
	display: none;
	font-size: 22px;
	line-height: 1;
	color: var(--sas-text, #12161c);
}

.sas-searchbar.has-query .sas-icon-search {
	display: none;
}

.sas-searchbar.has-query .sas-icon-clear {
	display: block;
}

.sas-searchbar.has-query .sas-icon-btn:hover {
	color: var(--sas-accent);
}

.sas-input {
	flex: 1;
	min-width: 0;
	border: none;
	background: transparent;
	outline: none;
	color: var(--sas-text);
	font-size: 16px;
	line-height: 1;
	padding: 16px 8px;
	font-family: inherit;
}

.sas-input::placeholder {
	color: var(--sas-text-dim);
}

/* Solid accent "Search" button — forces an immediate search. */
.sas-search-btn {
	flex-shrink: 0;
	border: none;
	border-radius: 12px;
	background: var(--sas-accent);
	color: #ffffff;
	font-size: 14px;
	font-weight: 700;
	padding: 14px 24px;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color 0.2s ease;
}

.sas-search-btn:hover {
	background: #000000;
}

.sas-search-btn:focus-visible {
	outline: 2px solid var(--sas-accent);
	outline-offset: 2px;
}

/* Close (×) button — plain text glyph, not an SVG. Some theme/plugin CSS
   resets can silently strip stroke/fill from inline SVGs; a text character
   has no such failure mode, so this stays visible no matter what. */
.sas-close {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 1px solid var(--sas-border, #e5e8ec);
	border-radius: 12px;
	background: var(--sas-surface-2, #f1f3f5);
	color: var(--sas-text, #12161c);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sas-close:hover {
	background: var(--sas-text, #12161c);
	border-color: var(--sas-text, #12161c);
	color: #ffffff;
}

.sas-close:focus-visible {
	outline: 2px solid var(--sas-accent);
	outline-offset: 2px;
}

/* ---------- Results panel ---------- */
.sas-results-panel {
	width: 100%;
	display: flex;
	flex-direction: column;
	background: var(--sas-surface);
	border-radius: 20px;
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.02);
	max-height: 68vh;
	overflow: hidden;
}

.sas-results-panel[hidden] {
	display: none !important;
}

/* ---------- Results heading ("N Results for keyword") ---------- */
.sas-results-heading {
	margin: 0;
	padding: 20px 20px 4px;
	font-size: 16px;
	font-weight: 700;
	color: var(--sas-accent);
	min-height: 1.4em;
}

/* ---------- Tabs ---------- */
.sas-tabs {
	display: flex;
	gap: 8px;
	padding: 12px 20px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.sas-tab {
	flex-shrink: 0;
	border: 1px solid var(--sas-border);
	background: var(--sas-surface);
	color: var(--sas-text-dim);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	padding: 9px 16px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sas-tab:hover {
	color: var(--sas-text);
	border-color: var(--sas-text-dim);
}

.sas-tab.is-active {
	background: var(--sas-accent);
	color: #ffffff;
	border-color: var(--sas-accent);
}

.sas-tab-count {
	font-weight: 700;
}

/* ---------- Body / states ---------- */
.sas-body {
	flex: 1;
	overflow-y: auto;
	padding: 8px 20px 20px;
	background: var(--sas-surface);
}

.sas-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	gap: 10px;
	padding: 56px 24px;
	color: var(--sas-text-dim);
}

/*
 * Without this, the [hidden] attribute gets silently overridden: browsers'
 * built-in "[hidden] { display: none }" rule and our ".sas-state { display:
 * flex }" rule have equal specificity, and author CSS always wins over the
 * browser's default styles at equal specificity — so a "hidden" state would
 * still render as flex and stack on top of whichever state is active.
 * !important + a broad selector guarantees this can't silently break again.
 */
.sas-body [hidden] {
	display: none !important;
}

.sas-empty-title {
	color: var(--sas-text);
	font-size: 16px;
	font-weight: 600;
	margin: 0;
}

.sas-empty-sub {
	font-size: 13px;
	margin: 0;
}

.sas-spinner {
	width: 26px;
	height: 26px;
	border: 3px solid var(--sas-border);
	border-top-color: var(--sas-accent);
	border-radius: 50%;
	animation: sas-spin 0.7s linear infinite;
}

/* Small inline spinner row appended below results while loading the next
   batch on scroll — deliberately compact, not a full loading state. */
.sas-loading-more {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px 0 4px;
}

.sas-loading-more .sas-spinner {
	width: 20px;
	height: 20px;
	border-width: 2px;
}

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

/* ---------- Result rows ---------- */
/* The whole list sits on a light gray "card" — individual rows are just
   divided by thin lines inside it, not separately boxed. */
.sas-results {
	display: flex;
	flex-direction: column;
	background: var(--sas-surface-2);
	border-radius: 14px;
	overflow: hidden;
}

.sas-results:empty {
	display: none;
}

.sas-card {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	padding: 18px 18px;
	border-bottom: 1px solid var(--sas-border);
	text-decoration: none;
	color: inherit;
	transition: background-color 0.15s ease;
}

.sas-card:last-child {
	border-bottom: none;
}

.sas-card:hover,
.sas-card:focus-visible {
	background: var(--sas-surface);
}

.sas-card:focus-visible {
	outline: none;
	box-shadow: inset 0 0 0 2px var(--sas-accent);
}

.sas-card-main {
	flex: 1;
	min-width: 0;
}

.sas-card-title {
	margin: 0 0 6px;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--sas-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sas-card-excerpt {
	margin: 0 0 8px;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--sas-text-dim);
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.sas-card-category {
	display: inline-block;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
}

.sas-card-category.sas-type-services {
	color: var(--sas-accent);
}

.sas-card-category.sas-type-blogs {
	color: var(--sas-teal);
}

.sas-card-category.sas-type-pages {
	color: var(--sas-amber);
}

.sas-card-arrow {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	margin-top: 2px;
	border-radius: 50%;
	color: var(--sas-text-dim);
	background: transparent;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sas-card:hover .sas-card-arrow {
	color: var(--sas-accent);
	transform: translateX(2px);
}

/* ---------- Scrollbar polish (progressive enhancement) ---------- */
.sas-body::-webkit-scrollbar {
	width: 8px;
}

.sas-body::-webkit-scrollbar-thumb {
	background: var(--sas-border);
	border-radius: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
	.sas-overlay {
		padding: 12px 10px 20px;
	}

	.sas-shell {
		gap: 10px;
	}

	.sas-searchbar {
		border-radius: 16px;
		padding: 6px 6px 6px 14px;
	}

	.sas-input {
		padding: 12px 6px;
		font-size: 16px; /* keep >=16px to prevent iOS auto-zoom on focus */
	}

	.sas-search-btn {
		padding: 12px 16px;
		font-size: 13px;
	}

	.sas-close {
		width: 40px;
		height: 40px;
	}

	.sas-icon-btn {
		width: 26px;
		height: 26px;
	}

	.sas-results-panel {
		border-radius: 16px;
		max-height: 72vh;
	}

	.sas-results-heading {
		padding: 14px 14px 2px;
		font-size: 14px;
	}

	.sas-tabs {
		padding: 10px 14px;
		gap: 6px;
	}

	.sas-tab {
		padding: 7px 13px;
		font-size: 12.5px;
	}

	.sas-body {
		padding: 4px 12px 14px;
	}

	.sas-card {
		padding: 14px;
		gap: 10px;
	}

	.sas-card-title {
		font-size: 15px;
		white-space: normal;
		-webkit-line-clamp: 1;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	.sas-card-excerpt {
		font-size: 13px;
	}

	.sas-card-arrow {
		width: 26px;
		height: 26px;
	}

	.sas-trigger-icon {
		width: 40px;
		height: 40px;
	}
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.sas-overlay,
	.sas-shell,
	.sas-card,
	.sas-card-arrow,
	.sas-trigger-icon {
		transition: none !important;
		animation-duration: 0.01ms !important;
	}
}
