/*
 * Flatsome Smart Search – [fss_search] widget.
 * Fully self-contained: desktop shows an inline field + icon, mobile shows
 * just the icon and expands into a full-screen search on tap.
 */

.fss-search {
	--fss-accent: var( --fs-color-primary, #c0395c );
	--fss-text: var( --fs-color-base, #333 );
	--fss-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='m9 5 7 7-7 7'/%3E%3C/svg%3E");
	position: relative;
	display: block;
	width: 100%;
}

/* Icon: painted via mask instead of an inline <svg> so nothing in the
   theme's global stylesheet can reset it into invisibility, and so it
   automatically follows each button's own text color via currentColor. */
.fss-icon {
	display: block;
	width: 20px;
	height: 20px;
	flex-shrink: 0;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' d='M10.5 18a7.5 7.5 0 1 0 0-15 7.5 7.5 0 0 0 0 15Zm10.5 3-5.2-5.2'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' d='M10.5 18a7.5 7.5 0 1 0 0-15 7.5 7.5 0 0 0 0 15Zm10.5 3-5.2-5.2'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* --- toggle button (mobile only, see media query below) --- */

.fss-search-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: none;
	border: 0;
	color: inherit;
	cursor: pointer;
}

/* --- the field itself (always visible on desktop) --- */

.fss-search-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
}

.fss-search-form {
	display: flex;
	align-items: center;
	gap: 4px;
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	background: #fff;
	border: 1px solid rgba( 0, 0, 0, 0.12 );
	border-radius: 999px;
	padding: 6px 6px 6px 20px;
	box-sizing: border-box;
}

input.fss-search-input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	border: 0 !important;
	outline: 0;
	box-shadow: none !important;
	-webkit-appearance: none;
	appearance: none;
	background: none;
	color: var( --fss-text );
	font-size: 1em;
	padding: 8px 0;
}

.fss-search-submit {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 0;
	background: var( --fss-accent );
	color: #fff;
	cursor: pointer;
}

.fss-search-close {
	display: none;
}

/* --- the dropdown panel --- */

.fss-panel {
	display: block;
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 9990;
	max-height: 75vh;
	overflow-y: auto;
	margin-top: 8px;
	padding: 18px;
	background: #fff;
	color: var( --fss-text );
	border-radius: 12px;
	box-shadow: 0 12px 32px rgba( 0, 0, 0, 0.15 );
	text-align: left;
	box-sizing: border-box;
	/* Closed state: invisible and out of the way, ready to animate in. */
	opacity: 0;
	visibility: hidden;
	transform: translateY( -10px );
	transition: opacity 0.28s cubic-bezier( 0.16, 1, 0.3, 1 ),
		transform 0.28s cubic-bezier( 0.16, 1, 0.3, 1 ),
		visibility 0s linear 0.28s;
}

.fss-search.fss-open .fss-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY( 0 );
	transition: opacity 0.28s cubic-bezier( 0.16, 1, 0.3, 1 ),
		transform 0.28s cubic-bezier( 0.16, 1, 0.3, 1 ),
		visibility 0s linear 0s;
}

.fss-panel .fss-heading {
	margin: 0 0 10px;
	font-size: 0.95em;
	font-weight: 700;
	color: var( --fss-text );
}

/* --- section heading + "Alle anzeigen" link (categories, top sellers) ---
   Unlike the search-results head below, this one shows the link at both
   breakpoints – the mobile mockup has it right next to the heading too. */

.fss-section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.fss-panel .fss-section-head .fss-heading {
	margin: 0;
}

.fss-section-all {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.8em;
	font-weight: 700;
	color: var( --fss-accent );
	text-decoration: none;
	white-space: nowrap;
}

.fss-section-all::after {
	content: "";
	width: 14px;
	height: 14px;
	background-color: currentColor;
	-webkit-mask: var( --fss-chevron ) center / contain no-repeat;
	mask: var( --fss-chevron ) center / contain no-repeat;
}

/* --- popular-term chips: 3 per row on both mobile and desktop --- */

.fss-chips {
	display: grid;
	grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	gap: 8px;
}

.fss-chip {
	background: #f3e6e9; /* fallback for browsers without color-mix() */
	background: color-mix( in srgb, var( --fss-accent ) 12%, #fff );
	color: var( --fss-accent );
	border: 0;
	border-radius: 999px;
	padding: 8px 10px;
	width: 100%;
	box-sizing: border-box;
	font-size: 0.85em;
	line-height: 1.2;
	text-align: center;
	white-space: normal;
	cursor: pointer;
}

.fss-chip:hover {
	background: #ecd4da;
	background: color-mix( in srgb, var( --fss-accent ) 20%, #fff );
}

/* --- category tiles: image on top, label below, 3 per row on mobile;
   become a compact list (image left, label right) on desktop, see the
   min-width media query below. --- */

.fss-tiles {
	display: grid;
	grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	gap: 10px;
}

.fss-tile {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 8px;
	border-radius: 12px;
	background: #f7f0ec;
	text-decoration: none;
	color: var( --fss-text );
	overflow: hidden;
}

.fss-tile-img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 8px;
}

.fss-tile-label {
	font-weight: 700;
	font-size: 1em;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

/* --- quick-access links: icon on top, label below, 5 per row on mobile;
   become a compact list on desktop, see the min-width media query. --- */

.fss-quicklinks {
	display: grid;
	grid-template-columns: repeat( 5, minmax( 0, 1fr ) );
	gap: 8px;
}

.fss-quicklink {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	text-align: center;
	text-decoration: none;
	color: var( --fss-text );
}

.fss-quicklink-img {
	display: block;
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 50%;
	background: #f7f0ec;
}

.fss-quicklink-label {
	font-size: 1em;
	font-weight: 700;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

/* --- top sellers: a responsive grid of horizontal cards (image, title,
   price, chevron) – same card at every width, the column count just
   follows the available space. --- */

.fss-topsellers {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 210px, 1fr ) );
	gap: 12px;
}

.fss-topseller {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	border-radius: 10px;
	background: #f7f0ec;
	text-decoration: none;
	color: var( --fss-text );
}

.fss-topseller-img {
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 8px;
	background: #fff;
}

.fss-topseller-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.fss-topseller-title {
	font-weight: 700;
	font-size: 0.95em;
	line-height: 1.3;
}

.fss-topseller-price {
	font-size: 0.85em;
}

.fss-topseller::after {
	content: "";
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	margin-left: auto;
	background-color: currentColor;
	opacity: 0.4;
	-webkit-mask: var( --fss-chevron ) center / contain no-repeat;
	mask: var( --fss-chevron ) center / contain no-repeat;
}

/* --- results: hidden until a term is typed (.fss-mode-search on the root) --- */

.fss-section--results {
	display: none;
	position: relative;
	flex-direction: column;
	gap: 4px;
	min-height: 60px;
}

.fss-search.fss-mode-search .fss-section--results {
	display: flex;
}

.fss-section--results.fss-loading {
	pointer-events: none;
}

/* Dim only the old content, not the spinner below (opacity on the section
   itself would fade the ::after spinner too, since it shares that layer). */
.fss-section--results.fss-loading > * {
	opacity: 0.35;
}

.fss-section--results.fss-loading::after {
	content: "";
	position: absolute;
	top: 16px;
	left: 50%;
	width: 26px;
	height: 26px;
	margin-left: -13px;
	border: 3px solid rgba( 0, 0, 0, 0.1 );
	border-top-color: var( --fss-accent );
	border-radius: 50%;
	animation: fss-spin 0.7s linear infinite;
}

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

.fss-results-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 6px;
}

.fss-panel .fss-results-head .fss-heading {
	margin: 0;
}

.fss-results-all {
	display: none; /* desktop only, see media query */
	font-size: 0.8em;
	font-weight: 700;
	color: var( --fss-accent );
	text-decoration: none;
	white-space: nowrap;
}

.fss-results-more {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 6px;
	padding: 14px 4px 6px;
	border-top: 1px solid rgba( 0, 0, 0, 0.08 );
	font-size: 0.9em;
	text-decoration: none;
	color: var( --fss-text );
}

.fss-results-more .fss-icon {
	width: 18px;
	height: 18px;
}

.fss-results-more::after,
.fss-result::after {
	content: "";
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	margin-left: auto;
	background-color: currentColor;
	opacity: 0.55;
	-webkit-mask: var( --fss-chevron ) center / contain no-repeat;
	mask: var( --fss-chevron ) center / contain no-repeat;
}

.fss-result {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	margin: 0 -8px;
	border-radius: 8px;
	text-decoration: none;
	color: var( --fss-text );
}

.fss-result:hover {
	background: #f3e6e9; /* fallback for browsers without color-mix() */
	background: color-mix( in srgb, var( --fss-accent ) 8%, #fff );
}

.fss-result-img {
	flex-shrink: 0;
	width: 66px;
	height: 66px;
	object-fit: cover;
	border-radius: 8px;
	background: #f0f0f1;
}

.fss-result-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.fss-result-title {
	font-size: 1.05em;
	font-weight: 700;
	line-height: 1.3;
}

.fss-result-price {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	font-size: 0.85em;
}

.fss-sale-badge {
	display: inline-block;
	background: var( --fss-accent );
	color: #fff;
	font-size: 0.75em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	padding: 2px 6px;
	border-radius: 4px;
	line-height: 1.4;
}

/* wc_price() wraps the number in its own ".amount" span, which some
   theme/WooCommerce core styles color directly – override that too, not
   just the del/ins wrapper, so our colors actually win. */
.fss-price-old,
.fss-price-old .amount {
	color: #888 !important;
	text-decoration: line-through;
}

.fss-price-new,
.fss-price-new .amount {
	color: #111 !important;
	font-weight: 700;
	text-decoration: none;
}

.fss-no-results {
	margin: 0;
	font-size: 0.9em;
	opacity: 0.7;
}

/* --- responsive: icon-only on mobile, full-screen search on tap --- */

@media ( max-width: 991px ) {
	.fss-search {
		width: auto;
	}

	.fss-search-toggle {
		display: inline-flex;
	}

	.fss-search-body {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 99999;
		background: #fff;
		overflow-y: auto;
		padding: 16px;
		opacity: 0;
		visibility: hidden;
		transform: translateY( 16px );
		transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
	}

	.fss-search.fss-open .fss-search-body {
		opacity: 1;
		visibility: visible;
		transform: translateY( 0 );
		transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0s;
		top: 30px;
	}

	/* The full-screen overlay above already animates itself; the panel just
	   sits inside it at full, static visibility. */
	.fss-panel {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: none;
	}

	/* Avoid a focusable, invisible toggle button sitting behind the overlay. */
	.fss-search.fss-open .fss-search-toggle {
		visibility: hidden;
	}

	.fss-search-close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		box-sizing: border-box;
		width: 30px;
		height: 30px;
		padding: 0;
		background: #f0f0f1;
		border: 0;
		border-radius: 50%;
		/* Explicit, not "inherit" – this sits in a full-screen overlay whose
		   ambient text color depends on wherever the shortcode is placed. */
		color: var( --fss-text );
		cursor: pointer;
	}

	/* A slim mask icon instead of a big "×" glyph (which, combined with the
	   button's default padding, was rendering far bigger than the 30px
	   circle around it). */
	.fss-search-close .fss-icon {
		width: 13px;
		height: 13px;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E") center / contain no-repeat;
		mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E") center / contain no-repeat;
	}

	.fss-search.fss-open .fss-panel {
		display: flex;
		flex-direction: column;
		gap: 24px;
		position: static;
		margin-top: 20px;
		padding: 0;
		box-shadow: none;
		border-radius: 0;
		max-height: none;
		overflow: visible;
	}

	/* While searching: results appear right under the search field, nothing
	   else. */
	.fss-search.fss-mode-search .fss-section--tiles,
	.fss-search.fss-mode-search .fss-section--quicklinks,
	.fss-search.fss-mode-search .fss-section--terms,
	.fss-search.fss-mode-search .fss-section--topsellers {
		display: none;
	}
}

html.fss-scroll-lock {
	overflow: hidden;
}

/* --- desktop panel –
   no query:  categories | popular terms | quick links, with top sellers
              in a full-width row underneath
   with query: live results | quick links | categories, side by side
              (popular terms and top sellers are hidden) --- */

@media ( min-width: 992px ) {
	.fss-panel {
		width: 900px;
		max-width: calc( 100vw - 32px );
		display: grid;
		grid-template-columns: 1fr 1fr 1fr;
		grid-template-areas:
			"tiles terms quicklinks"
			"topsellers topsellers topsellers";
		align-items: start;
		gap: 24px 28px;
	}

	.fss-section--results     { grid-area: results; }
	.fss-section--tiles       { grid-area: tiles; }
	.fss-section--terms       { grid-area: terms; }
	.fss-section--quicklinks  { grid-area: quicklinks; }
	.fss-section--topsellers  { grid-area: topsellers; }

	.fss-search.fss-mode-search .fss-panel {
		grid-template-columns: 1.4fr 1fr 1fr;
		grid-template-areas: "results quicklinks tiles";
		gap: 0 28px;
	}

	.fss-search.fss-mode-search .fss-section--terms,
	.fss-search.fss-mode-search .fss-section--topsellers {
		display: none;
	}

	.fss-results-all {
		display: inline;
	}

	.fss-results-more {
		display: none;
	}

	/* Categories and quick links are a compact image-left / label-right
	   list on desktop, in both states (not just while searching). */
	.fss-tiles,
	.fss-quicklinks {
		display: flex;
		flex-direction: column;
		gap: 8px;
	}

	.fss-tile,
	.fss-quicklink {
		flex-direction: row;
		align-items: center;
		text-align: left;
		gap: 12px;
		padding: 6px 0;
	}

	.fss-tile::after,
	.fss-quicklink::after {
		content: "";
		flex-shrink: 0;
		width: 14px;
		height: 14px;
		margin-left: auto;
		margin-right: 10px;
		background-color: currentColor;
		opacity: 0.4;
		-webkit-mask: var( --fss-chevron ) center / contain no-repeat;
		mask: var( --fss-chevron ) center / contain no-repeat;
	}

	.fss-tile-img {
		flex-shrink: 0;
		width: 44px;
		height: 44px;
		aspect-ratio: auto;
		border-radius: 8px;
	}

	.fss-quicklink-img {
		flex-shrink: 0;
		width: 36px;
		height: 36px;
	}

	.fss-quicklink-label {
		font-size: 0.9em;
	}
}
