/* RICERCA PRODOTTI AJAX - frontend
 * Stili di base volutamente neutri: tutto è sovrascrivibile dal widget Elementor
 * o tramite le variabili CSS qui sotto.
 */
.rpa-search {
	--rpa-accent: #1f6feb;
	--rpa-text: inherit;
	--rpa-muted: #667085;
	--rpa-border: #d0d5dd;
	--rpa-bg: #fff;
	--rpa-hover: #f2f4f7;
	--rpa-radius: 8px;
	--rpa-height: 46px;
	--rpa-img: 56px;
	--rpa-cols: 3;
	--rpa-gap: 12px;
	position: relative;
	width: 100%;
	box-sizing: border-box;
	color: var(--rpa-text);
}
.rpa-search *,
.rpa-search *::before,
.rpa-search *::after { box-sizing: border-box; }

/* Modalità: inline (default) o icona con overlay. Le variabili vengono impostate per dispositivo dal widget. */
.rpa-trigger { display: var(--rpa-trigger-display, none); }
.rpa-panel { display: var(--rpa-panel-display, block); }
.rpa-search.rpa-mode-icon { --rpa-trigger-display: inline-flex; --rpa-panel-display: none; width: auto; }

.rpa-trigger {
	align-items: center;
	gap: .4em;
	margin: 0;
	padding: .4em;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	line-height: 1;
	cursor: pointer;
	font-size: 22px;
	transition: color .15s, background-color .15s;
}
.rpa-trigger__text { font-size: .7em; }
.rpa-svg { display: block; }
.rpa-trigger svg, .rpa-submit svg, .rpa-input-icon svg, .rpa-close svg, .rpa-clear svg { width: 1em; height: 1em; fill: currentColor; }
.rpa-trigger i, .rpa-submit i, .rpa-input-icon i, .rpa-close i { font-size: 1em; line-height: 1; }

.rpa-overlay-head { display: none; }

.rpa-search.is-overlay-open .rpa-panel {
	display: block;
	position: fixed;
	inset: 0;
	z-index: var(--rpa-overlay-z, 999999);
	background: var(--rpa-overlay-bg, rgba(255, 255, 255, .98));
	padding: var(--rpa-overlay-pad, 24px 16px);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	animation: var(--rpa-overlay-anim, rpa-fade) .22s ease both;
}
.rpa-search.is-overlay-open .rpa-overlay-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	max-width: var(--rpa-overlay-max, 900px);
	margin: 0 auto 16px;
}
.rpa-overlay-title { font-weight: 600; font-size: 1.1em; }
.rpa-close {
	display: inline-flex;
	margin: 0 0 0 auto;
	padding: 6px;
	border: 0;
	background: none;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}
.rpa-search.is-overlay-open .rpa-form { max-width: var(--rpa-overlay-max, 900px); margin: 0 auto; }
.rpa-search.is-overlay-open .rpa-dropdown {
	position: static;
	margin-top: 12px;
	max-height: none;
	box-shadow: none;
}
html.rpa-lock, html.rpa-lock body { overflow: hidden !important; }

/* Campo */
.rpa-form { position: relative; margin: 0; padding: 0; }
.rpa-field {
	display: flex;
	align-items: stretch;
	height: var(--rpa-height);
	border: 1px solid var(--rpa-border);
	border-radius: var(--rpa-radius);
	background: var(--rpa-bg);
	overflow: hidden;
	transition: border-color .15s, box-shadow .15s;
}
.rpa-field:focus-within { border-color: var(--rpa-accent); box-shadow: 0 0 0 3px rgba(31, 111, 235, .15); }
.rpa-input-wrap { position: relative; display: flex; align-items: center; flex: 1 1 auto; min-width: 0; }
.rpa-input-icon { display: flex; align-items: center; padding-left: 12px; color: var(--rpa-muted); font-size: 18px; }
.rpa-search .rpa-input,
.rpa-search input.rpa-input[type="search"] {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0 12px;
	border: 0 !important;
	border-radius: 0;
	outline: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: inherit;
	font: inherit;
	line-height: normal;
	-webkit-appearance: none;
	appearance: none;
}
.rpa-input::-webkit-search-cancel-button,
.rpa-input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.rpa-input::placeholder { color: var(--rpa-muted); opacity: 1; }

.rpa-loader {
	display: none;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin-right: 10px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	color: var(--rpa-accent);
	animation: rpa-spin .7s linear infinite;
}
.rpa-search.is-loading .rpa-loader { display: block; }
.rpa-search.is-loading .rpa-clear { display: none; }
.rpa-clear {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	margin: 0 6px 0 0;
	padding: 6px;
	border: 0;
	background: none;
	color: var(--rpa-muted);
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
}
.rpa-clear[hidden] { display: none; }

.rpa-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .45em;
	flex: 0 0 auto;
	min-width: var(--rpa-height);
	margin: 0;
	padding: 0 16px;
	border: 0;
	border-radius: 0;
	background: var(--rpa-accent);
	color: #fff;
	font: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: background-color .15s, color .15s, filter .15s;
}
.rpa-submit:hover { filter: brightness(.94); }
.rpa-submit__text { font-size: 15px; font-weight: 600; }

.rpa-cat-wrap { display: flex; flex: 0 0 auto; border-right: 1px solid var(--rpa-border); }
.rpa-search select.rpa-cat {
	height: 100%;
	max-width: 200px;
	margin: 0;
	padding: 0 28px 0 12px;
	border: 0;
	border-radius: 0;
	outline: 0;
	background-color: transparent;
	color: inherit;
	font: inherit;
	font-size: .9em;
	cursor: pointer;
	box-shadow: none;
}

/* Dropdown */
.rpa-dropdown {
	position: absolute;
	top: calc(100% + var(--rpa-dd-offset, 6px));
	left: 0;
	right: 0;
	z-index: var(--rpa-dd-z, 9999);
	max-height: var(--rpa-dd-max-h, 70vh);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 6px 0;
	border: 1px solid #e4e7ec;
	border-radius: var(--rpa-radius);
	background: #fff;
	box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
	text-align: left;
	color: #1d2939;
	font-size: 15px;
}
.rpa-dropdown[hidden] { display: none; }
.rpa-section + .rpa-section { border-top: 1px solid #f0f1f3; margin-top: 4px; padding-top: 4px; }
.rpa-section-title {
	padding: 8px 14px 4px;
	color: var(--rpa-muted);
	font-size: .72em;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.rpa-cats { margin: 0; padding: 0 0 4px; list-style: none; }
.rpa-cats__item { margin: 0; padding: 0; }
.rpa-cats__link { display: block; padding: 7px 14px; color: inherit; text-decoration: none; }
.rpa-cats__count { color: var(--rpa-muted); font-size: .85em; }
.rpa-cats__link:hover, .rpa-cats__link.is-active { background: var(--rpa-hover); }

/* Layout del plugin - lista */
.rpa-products--plugin { display: flex; flex-direction: column; }
.rpa-item {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 14px;
	cursor: pointer;
	transition: background-color .12s;
}
.rpa-item:hover, .rpa-item.is-active { background: var(--rpa-hover); }
.rpa-item + .rpa-item { border-top: var(--rpa-sep, 0) solid #f0f1f3; }
.rpa-item__image { position: relative; display: block; flex: 0 0 var(--rpa-img); width: var(--rpa-img); }
.rpa-item__image img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	border-radius: 6px;
	background: #fff;
}
.rpa-item__badge {
	position: absolute;
	top: -4px;
	left: -4px;
	padding: 2px 5px;
	border-radius: 4px;
	background: #e11d48;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1.2;
}
.rpa-item__body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.rpa-item__title {
	display: -webkit-box;
	overflow: hidden;
	color: inherit;
	font-weight: 500;
	line-height: 1.3;
	text-decoration: none;
	-webkit-line-clamp: var(--rpa-title-lines, 2);
	-webkit-box-orient: vertical;
}
.rpa-item__title:hover { color: var(--rpa-accent); }
.rpa-item__cat, .rpa-item__sku, .rpa-item__excerpt { color: var(--rpa-muted); font-size: .82em; line-height: 1.35; }
.rpa-item__rating .star-rating { float: none; margin: 2px 0 0; font-size: .8em; }
.rpa-item__side { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.rpa-item__price { font-weight: 600; white-space: nowrap; }
.rpa-item__price del { margin-right: 4px; font-weight: 400; opacity: .6; }
.rpa-item__price ins { text-decoration: none; }
.rpa-item__stock { font-size: .78em; }
.rpa-item__stock--instock { color: #067647; }
.rpa-item__stock--outofstock { color: #b42318; }
.rpa-item__stock--onbackorder { color: #b54708; }
.rpa-item__cart .button, .rpa-item__cart a.button {
	display: inline-block;
	margin: 0;
	padding: .45em .9em;
	font-size: .8em;
	line-height: 1.2;
	white-space: nowrap;
}
.rpa-item__cart .added_to_cart { display: block; margin-top: 2px; font-size: .75em; }

/* Griglia */
.rpa-products--grid {
	display: grid;
	grid-template-columns: repeat(var(--rpa-cols), minmax(0, 1fr));
	gap: var(--rpa-gap);
	padding: 8px 14px;
}
.rpa-products--grid .rpa-item { flex-direction: column; align-items: stretch; padding: 8px; border-radius: 6px; }
.rpa-products--grid .rpa-item + .rpa-item { border-top: 0; }
.rpa-products--grid .rpa-item__image { flex-basis: auto; width: 100%; }
.rpa-products--grid .rpa-item__side { align-items: flex-start; text-align: left; }

/* Loop Item Elementor */
.rpa-products--loop.rpa-products--list { display: flex; flex-direction: column; gap: var(--rpa-gap); padding: 8px 14px; }
.rpa-product--loop { cursor: pointer; border-radius: 6px; }
.rpa-product--loop.is-active { outline: 2px solid var(--rpa-accent); outline-offset: 2px; }

/* Card WooCommerce/tema */
.rpa-products--woocommerce { padding: 8px 14px; }
.rpa-products--woocommerce ul.products { margin: 0 !important; }
.rpa-products--woocommerce li.product.is-active { outline: 2px solid var(--rpa-accent); outline-offset: 2px; }

/* Messaggi */
.rpa-mark { padding: 0; background: var(--rpa-mark-bg, transparent); color: var(--rpa-mark-color, inherit); font-weight: 700; }
.rpa-suggestion, .rpa-relaxed, .rpa-noresults, .rpa-loading-text, .rpa-error { padding: 10px 14px; color: var(--rpa-muted); font-size: .9em; }
.rpa-suggestion__link { color: var(--rpa-accent); font-weight: 600; text-decoration: underline; }
.rpa-suggestion__link.is-active { background: var(--rpa-hover); }
.rpa-error { color: #b42318; }
.rpa-view-all {
	display: block;
	margin-top: 4px;
	padding: 10px 14px;
	border-top: 1px solid #eaecf0;
	color: var(--rpa-accent);
	font-weight: 600;
	text-align: center;
	text-decoration: none;
}
.rpa-view-all:hover, .rpa-view-all.is-active { background: var(--rpa-hover); }
.rpa-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.rpa-page-suggestion { margin: 0 0 1em; font-size: 1.05em; }
.rpa-page-suggestion a { font-weight: 600; }

@media (max-width: 767px) {
	.rpa-search select.rpa-cat { max-width: 120px; }
}
@media (max-width: 480px) {
	.rpa-products--plugin.rpa-products--list .rpa-item { flex-wrap: wrap; }
	.rpa-products--plugin.rpa-products--list .rpa-item__body { flex: 1 1 0; }
	.rpa-products--plugin.rpa-products--list .rpa-item__side {
		flex: 1 1 100%;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		gap: 4px 12px;
		text-align: left;
	}
	.rpa-products--plugin.rpa-products--list .rpa-item__image ~ .rpa-item__side { padding-left: calc(var(--rpa-img) + 12px); }
}

@keyframes rpa-spin { to { transform: rotate(360deg); } }
@keyframes rpa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rpa-slide-down { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
@keyframes rpa-zoom { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
	.rpa-search *, .rpa-search.is-overlay-open .rpa-panel { animation: none !important; transition: none !important; }
	.rpa-loader { animation: rpa-spin 1.5s linear infinite !important; }
}
