/* Swift Product Search — styles. Accent colour comes from --sps-accent (set in plugin settings). */

.sps {
	--sps-accent: #1B3F3A;
	--sps-text: #1C2321;
	--sps-muted: #5F6B67;
	--sps-line: #E6E9E7;
	--sps-border: #D9DEDB;
	--sps-soft: #EDF2EF;
	--sps-hover: #F3F6F4;
	--sps-side: #FAFAF7;
	--sps-mark: #FFF1C9;
	--sps-radius: 16px;
	position: relative;
	width: 100%;
	font: inherit;
	color: var(--sps-text);
	line-height: 1.35;
	z-index: 50;
}
.sps *, .sps *::before, .sps *::after { box-sizing: border-box; }
.sps .screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}

/* ---------- the bar ---------- */

.sps__form { margin: 0; }
.sps__box {
	position: relative;
	background: #fff;
	border-radius: var(--sps-radius);
	box-shadow: 0 0 0 1px var(--sps-border);
	transition: box-shadow .15s ease;
}
.sps__box:hover { box-shadow: 0 0 0 1px #8FA39B, 0 6px 16px rgba(27, 63, 58, .08); }
.sps__box:focus-within {
	box-shadow: 0 0 0 2px var(--sps-accent), 0 18px 40px rgba(27, 63, 58, .14);
}

.sps__bar {
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 64px;
	padding: 0 10px 0 22px;
}
.sps__icon { display: flex; color: #7A8582; flex-shrink: 0; }
.sps__box:focus-within .sps__icon { color: var(--sps-accent); }
.sps__icon-spin { display: none; animation: sps-spin .8s linear infinite; }
.sps.is-loading .sps__icon-search { display: none; }
.sps.is-loading .sps__icon-spin { display: block; }
@keyframes sps-spin { to { transform: rotate(360deg); } }

.sps__input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0 !important;
	outline: 0;
	box-shadow: none !important;
	background: transparent !important;
	font: inherit;
	font-size: 18px;
	color: var(--sps-text);
	-webkit-appearance: none;
	appearance: none;
}
.sps__input::placeholder { color: #7A8582; opacity: 1; }
.sps__input::-webkit-search-cancel-button,
.sps__input::-webkit-search-decoration { -webkit-appearance: none; }

.sps__kbd {
	font: inherit; font-size: 12px; color: var(--sps-muted);
	border: 1px solid var(--sps-border); border-radius: 6px; padding: 2px 8px;
	background: transparent;
}
.sps.has-value .sps__kbd, .sps__box:focus-within .sps__kbd { display: none; }

.sps__clear, .sps__back {
	display: flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; flex-shrink: 0;
	margin: 0; padding: 0; border: 0; border-radius: 12px;
	background: #F1F3F2; color: #4A5653; cursor: pointer;
}
.sps__clear[hidden] { display: none; }
.sps__clear:hover { background: #E4E8E5; }
.sps__back { display: none; background: transparent; color: var(--sps-text); }

.sps__submit {
	height: 44px; padding: 0 22px; flex-shrink: 0;
	margin: 0; border: 0; border-radius: 12px;
	background: var(--sps-accent); color: #fff;
	font: inherit; font-size: 15px; font-weight: 600; line-height: 1;
	cursor: pointer;
}
.sps__submit:hover { filter: brightness(1.12); }

.sps button:focus-visible, .sps a:focus-visible {
	outline: 2px solid var(--sps-accent); outline-offset: 2px;
}

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

.sps.is-open .sps__box { border-radius: var(--sps-radius) var(--sps-radius) 0 0; }
.sps__panel {
	position: absolute;
	top: 100%;
	left: 0; right: 0;
	background: #fff;
	border-top: 1px solid var(--sps-line);
	border-radius: 0 0 var(--sps-radius) var(--sps-radius);
	box-shadow: 0 0 0 2px var(--sps-accent), 0 24px 40px rgba(27, 63, 58, .14);
	clip-path: inset(0 -60px -60px -60px);
	max-height: min(70vh, 640px);
	overflow-y: auto;
	overscroll-behavior: contain;
}
.sps__panel[hidden] { display: none; }

.sps__grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.sps__grid--single { grid-template-columns: minmax(0, 1fr); }
.sps__side {
	background: var(--sps-side);
	border-right: 1px solid var(--sps-line);
	padding: 18px 16px;
	display: flex; flex-direction: column; gap: 18px;
}
.sps__main { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.sps__group { display: flex; flex-direction: column; gap: 8px; }
.sps__label {
	font-size: 12px; font-weight: 600; letter-spacing: .6px;
	text-transform: uppercase; color: var(--sps-muted);
}
.sps__label-row {
	display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
	padding: 4px 8px 8px;
}
.sps__side .sps__label, .sps__idle .sps__label { padding: 0 8px; }
.sps__idle .sps__label-row { padding: 0 0 0 0; }
.sps__count { font-size: 13px; color: var(--sps-muted); }
.sps__link {
	border: 0; background: none; padding: 4px 8px; cursor: pointer;
	font: inherit; font-size: 13px; color: var(--sps-accent); text-decoration: underline;
}

.sps mark {
	background: var(--sps-mark); color: inherit; font-weight: 700;
	border-radius: 3px; padding: 0 1px;
}

/* suggestions */
.sps__sugg-list { display: flex; flex-direction: column; }
.sps__sugg {
	display: flex; align-items: center; gap: 10px;
	min-height: 44px; padding: 8px; width: 100%;
	margin: 0; border: 0; border-radius: 10px; background: transparent;
	font: inherit; font-size: 15px; color: var(--sps-text); text-align: left; cursor: pointer;
}
.sps__sugg svg { color: #7A8582; flex-shrink: 0; }
.sps__sugg mark { background: none; padding: 0; }

/* chips */
.sps__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 8px; }
.sps__chip {
	display: inline-flex; align-items: center; gap: 6px;
	min-height: 36px; padding: 8px 14px;
	margin: 0; border: 0; border-radius: 999px;
	background: var(--sps-soft); color: var(--sps-accent);
	font: inherit; font-size: 14px; line-height: 1.2; text-decoration: none; cursor: pointer;
}
.sps__chip svg { opacity: .7; }
.sps__chip--outline { background: transparent; color: var(--sps-text); box-shadow: inset 0 0 0 1px var(--sps-border); }
.sps__chip mark { background: none; padding: 0; }

/* product rows */
.sps__prod {
	display: flex; align-items: center; gap: 14px;
	padding: 10px; border-radius: 12px;
	color: var(--sps-text); text-decoration: none;
}
.sps__img {
	width: 56px; height: 56px; flex-shrink: 0;
	object-fit: cover; border-radius: 10px; background: #EEF1EC;
}
.sps__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sps__name { font-size: 16px; font-weight: 500; }
.sps__meta { font-size: 13px; color: var(--sps-muted); }
.sps__right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; flex-shrink: 0; }
.sps__price { font-size: 16px; font-weight: 700; color: var(--sps-accent); }
.sps__price del { color: var(--sps-muted); font-weight: 400; font-size: 13px; margin-right: 4px; }
.sps__price ins { text-decoration: none; }
.sps__stock { font-size: 12px; font-weight: 600; }
.sps__stock.is-in { color: #2E6B4F; }
.sps__stock.is-low { color: #9A4A12; }
.sps__stock.is-out { color: #A12B2B; }

.sps__all {
	display: flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 48px; margin-top: 8px; border-radius: 12px;
	background: #F1F5F3; color: var(--sps-accent);
	font-weight: 600; font-size: 15px; text-decoration: none;
}

/* hover + keyboard highlight */
.sps__sugg:hover, .sps__prod:hover, .sps__opt.is-active:not(.sps__chip):not(.sps__all) { background: var(--sps-hover); }
.sps__chip:hover, .sps__chip.is-active { background: #E0E9E4; }
.sps__chip--outline:hover, .sps__chip--outline.is-active { background: var(--sps-hover); }
.sps__all:hover, .sps__all.is-active { background: #E4ECE8; }
.sps__opt.is-active { outline: 2px solid var(--sps-accent); outline-offset: -2px; }

/* idle (recent + popular) */
.sps__idle { padding: 16px 16px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.sps__idle .sps__chips { padding: 0; }
.sps__idle .sps__label { padding: 0; }

/* empty + loading */
.sps__empty { padding: 24px 8px; display: flex; flex-direction: column; gap: 6px; }
.sps__empty-title { font-size: 16px; font-weight: 600; }
.sps__empty-hint { font-size: 14px; color: var(--sps-muted); }

.sps__loading { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.sps__skel { display: flex; align-items: center; gap: 14px; }
.sps__skel-img { width: 48px; height: 48px; border-radius: 10px; background: #EEF1EC; }
.sps__skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sps__skel-lines span { height: 12px; width: 65%; border-radius: 6px; background: #EEF1EC; animation: sps-pulse 1.2s ease-in-out infinite; }
.sps__skel-lines span + span { width: 38%; height: 10px; background: #F3F5F2; }
@keyframes sps-pulse { 50% { opacity: .5; } }

/* ---------- mobile: full-screen overlay ---------- */

@media (max-width: 767px) {
	.sps__submit, .sps__kbd { display: none; }
	.sps__bar { min-height: 52px; padding: 0 6px 0 14px; gap: 10px; }
	.sps__input[type="search"] { font-size: 16px; } /* 16px stops iOS zoom */
	.sps__idle { grid-template-columns: minmax(0, 1fr); }

	html.sps-lock, html.sps-lock body { overflow: hidden; }

	.sps.is-overlay {
		position: fixed; inset: 0; z-index: 999999;
		background: #fff;
		display: flex; flex-direction: column;
	}
	.sps.is-overlay .sps__form, .sps.is-overlay .sps__box {
		flex: 1; display: flex; flex-direction: column; min-height: 0;
	}
	.sps.is-overlay .sps__box,
	.sps.is-overlay .sps__box:hover,
	.sps.is-overlay .sps__box:focus-within { box-shadow: none; border-radius: 0; }
	.sps.is-overlay .sps__bar {
		padding: 12px 12px 12px 4px; gap: 6px;
		border-bottom: 1px solid var(--sps-line);
	}
	.sps.is-overlay .sps__back { display: flex; }
	.sps.is-overlay .sps__bar .sps__icon { display: none; }
	.sps.is-overlay .sps__input[type="search"] {
		height: 48px; padding: 0 14px !important;
		border-radius: 14px; background: #F3F5F2 !important;
		box-shadow: inset 0 0 0 2px var(--sps-accent) !important;
	}
	.sps.is-overlay .sps__panel {
		position: static; flex: 1; max-height: none;
		border: 0; border-radius: 0; box-shadow: none; clip-path: none;
		padding-bottom: env(safe-area-inset-bottom);
	}

	.sps__grid { grid-template-columns: minmax(0, 1fr); }
	.sps__side { background: transparent; border-right: 0; padding: 14px 8px 4px; gap: 12px; }
	.sps__side .sps__label { display: none; }
	/* suggestions become a swipeable chip row */
	.sps__sugg-list { flex-direction: row; gap: 8px; overflow-x: auto; padding: 0 8px; scrollbar-width: none; }
	.sps__sugg-list::-webkit-scrollbar { display: none; }
	.sps__sugg { width: auto; flex-shrink: 0; min-height: 40px; padding: 8px 14px; border-radius: 999px; background: var(--sps-soft); color: var(--sps-accent); font-size: 14px; }
	.sps__sugg svg { display: none; }
	.sps__chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
	.sps__chip { flex-shrink: 0; }

	.sps__main { padding: 6px 8px 0; }
	.sps__prod { padding: 12px 8px; border-radius: 0; border-bottom: 1px solid #EEF0EE; }
	.sps__img { width: 60px; height: 60px; border-radius: 12px; }
	/* sticky "See all" button pinned to the bottom of the overlay */
	.sps.is-overlay .sps__all {
		position: sticky; bottom: 0;
		margin: 12px -8px 0; min-height: 52px;
		background: var(--sps-accent); color: #fff;
		border: 12px solid #fff; border-bottom-width: 20px;
		border-radius: 26px; background-clip: padding-box;
	}
	.sps.is-overlay .sps__all:hover,
	.sps.is-overlay .sps__all.is-active { background: var(--sps-accent); filter: brightness(1.12); }
}

@media (prefers-reduced-motion: reduce) {
	.sps__icon-spin, .sps__skel-lines span { animation: none; }
}
