.spr-widget {
	max-width: 100%;
	margin: 1.5em 0;
	font-family: var( --spr-font-family, inherit );
}

.spr-widget__title {
	margin: 0 0 0.75em;
}

.spr-widget__form {
	display: flex;
	gap: 0.5em;
	flex-wrap: wrap;
	align-items: flex-start;
}

.spr-widget__input {
	flex: 1 1 260px;
	min-width: 0;
	padding: 0.65em 0.8em;
	border: 1px solid #ccc;
	border-radius: 6px;
	font-size: 1em;
	resize: vertical;
}

.spr-widget__submit {
	padding: 0.7em 1.4em;
	border: none;
	border-radius: 6px;
	background: var( --spr-primary-color, #1e1e1e );
	color: var( --spr-primary-contrast, #fff );
	font-size: 1em;
	cursor: pointer;
	white-space: nowrap;
}

.spr-widget__submit:disabled {
	opacity: 0.6;
	cursor: default;
}

.spr-widget__status {
	margin-top: 0.6em;
	font-style: italic;
	opacity: 0.8;
}

.spr-widget__message {
	margin-top: 0.6em;
	font-weight: 500;
}

.spr-widget__results {
	margin-top: 1em;
}

.spr-widget__results-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1em;
}

.spr-card {
	border: 1px solid #e2e2e2;
	border-radius: 8px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background: #fff;
}

.spr-card__image-link {
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f5f5f5;
}

.spr-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.spr-card__body {
	padding: 0.8em;
	display: flex;
	flex-direction: column;
	gap: 0.4em;
	flex: 1;
}

.spr-card__title {
	margin: 0;
	font-size: 1em;
}

.spr-card__title-link {
	text-decoration: none;
	color: inherit;
}

.spr-card__price {
	font-weight: 600;
}

.spr-card__reason {
	margin: 0;
	font-size: 0.85em;
	color: #555;
	font-style: italic;
}

.spr-card__desc {
	margin: 0;
	font-size: 0.85em;
	color: #444;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
}

.spr-card__actions {
	margin-top: auto;
	display: flex;
	align-items: center;
	gap: 0.6em;
}

.spr-card__add-to-cart {
	padding: 0.5em 1em;
	border: none;
	border-radius: 6px;
	background: var( --spr-primary-color, #1e1e1e );
	color: var( --spr-primary-contrast, #fff );
	cursor: pointer;
}

.spr-card__add-to-cart:disabled {
	opacity: 0.6;
	cursor: default;
}

.spr-card__choose-options {
	display: inline-block;
	text-decoration: none;
	text-align: center;
}

.spr-card__view-cart {
	font-size: 0.85em;
}

.spr-card__out-of-stock {
	font-size: 0.85em;
	color: #a00;
}

/* Floating chat widget */

.spr-chat {
	position: fixed;
	z-index: 999999;
	font-family: var( --spr-font-family, inherit );
}

.spr-chat[data-position^="bottom-"] {
	bottom: 20px;
}

.spr-chat[data-position^="top-"] {
	top: 20px;
}

.spr-chat[data-position$="-right"] {
	right: 20px;
}

.spr-chat[data-position$="-left"] {
	left: 20px;
}

.spr-chat__launcher {
	display: flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.8em 1.1em;
	border: none;
	border-radius: 999px;
	background: var( --spr-primary-color, #1e1e1e );
	color: var( --spr-primary-contrast, #fff );
	cursor: pointer;
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.2 );
	font-size: 0.95em;
}

.spr-chat__launcher-icon,
.spr-chat__launcher-label {
	/* Taps land on whichever child element is directly under the finger; making
	   the icon/label themselves ignore pointer events guarantees every tap
	   inside the button -- icon, text, or padding -- is always handled by the
	   button itself instead of occasionally being swallowed by an SVG's inner
	   paths (an inconsistency some mobile browsers have with icon buttons). */
	pointer-events: none;
}

.spr-chat__launcher-icon svg {
	display: block;
}

.spr-chat__panel {
	position: absolute;
	width: min( 380px, calc( 100vw - 40px ) );
	height: min( 560px, calc( 100vh - 120px ) );
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba( 0, 0, 0, 0.25 );
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Bottom-docked launchers open the panel upward, above the bubble;
   top-docked launchers open it downward, below the bubble. */
.spr-chat[data-position^="bottom-"] .spr-chat__panel {
	bottom: calc( 100% + 12px );
}

.spr-chat[data-position^="top-"] .spr-chat__panel {
	top: calc( 100% + 12px );
}

.spr-chat[data-position$="-right"] .spr-chat__panel {
	right: 0;
}

.spr-chat[data-position$="-left"] .spr-chat__panel {
	left: 0;
}

.spr-chat__panel[hidden] {
	display: none;
}

.spr-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.9em 1em;
	background: var( --spr-primary-color, #1e1e1e );
	color: var( --spr-primary-contrast, #fff );
	flex-shrink: 0;
}

.spr-chat__header-title {
	font-weight: 600;
}

.spr-chat__close {
	background: none;
	border: none;
	color: inherit;
	font-size: 1.4em;
	line-height: 1;
	cursor: pointer;
	padding: 0 0.2em;
}

.spr-chat__thread {
	flex: 1;
	overflow-y: auto;
	padding: 1em;
	display: flex;
	flex-direction: column;
	gap: 0.9em;
}

.spr-chat__intro {
	color: #666;
	font-size: 0.9em;
}

.spr-chat__turn {
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.spr-chat__bubble {
	max-width: 85%;
	padding: 0.6em 0.9em;
	border-radius: 12px;
	font-size: 0.92em;
	line-height: 1.4;
}

.spr-chat__bubble--user {
	align-self: flex-end;
	background: var( --spr-primary-color, #1e1e1e );
	color: var( --spr-primary-contrast, #fff );
	border-bottom-right-radius: 2px;
}

.spr-chat__bubble--assistant {
	align-self: flex-start;
	background: #f2f2f2;
	color: #222;
	border-bottom-left-radius: 2px;
}

.spr-chat__thinking {
	align-self: flex-start;
	font-style: italic;
	color: #888;
	font-size: 0.85em;
}

.spr-chat__results {
	display: flex;
	flex-direction: column;
	gap: 0.7em;
}

.spr-chat__results .spr-card {
	flex-direction: row;
	align-items: stretch;
}

.spr-chat__results .spr-card__image-link {
	width: 84px;
	flex-shrink: 0;
	aspect-ratio: auto;
}

.spr-chat__results .spr-card__body {
	padding: 0.6em 0.7em;
}

.spr-chat__results .spr-card__title {
	font-size: 0.92em;
}

.spr-chat__results .spr-card__desc {
	display: none;
}

.spr-chat__form {
	display: flex;
	gap: 0.5em;
	padding: 0.7em;
	border-top: 1px solid #eee;
	flex-shrink: 0;
}

.spr-chat__input {
	flex: 1;
	resize: none;
	border: 1px solid #ccc;
	border-radius: 8px;
	padding: 0.6em 0.7em;
	font-size: 0.92em;
	font-family: inherit;
	max-height: 100px;
}

.spr-chat__send {
	border: none;
	border-radius: 8px;
	background: var( --spr-primary-color, #1e1e1e );
	color: var( --spr-primary-contrast, #fff );
	width: 40px;
	flex-shrink: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.spr-chat__send:disabled {
	opacity: 0.6;
	cursor: default;
}

@media ( max-width: 480px ) {
	.spr-chat[data-position^="bottom-"] {
		bottom: 12px;
	}

	.spr-chat[data-position^="top-"] {
		top: 12px;
	}

	.spr-chat[data-position$="-right"] {
		right: 12px;
	}

	.spr-chat[data-position$="-left"] {
		left: 12px;
	}

	.spr-chat__launcher {
		padding: 0.55em 0.85em;
		font-size: 0.8em;
		gap: 0.4em;
	}

	.spr-chat__launcher-icon svg {
		width: 18px;
		height: 18px;
	}

	.spr-chat__panel {
		position: fixed;
		inset: 0;
		border-radius: 0;
		/* 100vh doesn't shrink when the on-screen keyboard opens, which was
		   pushing the input/send button below the visible area and making
		   them look "missing." 100dvh tracks the actual visible viewport;
		   the plain vh line is a fallback for older browsers that don't
		   understand dvh and just ignore that declaration. */
		height: 100vh;
		height: 100dvh;
	}
}
