/**
 * Animated Product Search for Elementor — structural styles.
 *
 * Colours, typography, borders, spacing and shadows are driven by the widget's
 * editor controls (Elementor injects per-element CSS). The rules here provide
 * structure, positioning, the open/close animation and sensible defaults so the
 * widget looks correct before any control is touched.
 *
 * Two CSS custom properties are set from controls on `.ccps`:
 *   --ccps-input-width    width the field expands to
 *   --ccps-anim-duration  open/close transition duration
 */

.ccps {
	--ccps-input-width: 240px;
	--ccps-anim-duration: 300ms;
	position: relative;
	display: inline-flex;
	align-items: center;
	line-height: 0;
}

/* Predictable sizing for every part of the widget, regardless of theme. */
.ccps,
.ccps *,
.ccps *::before,
.ccps *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ Toggle */
.ccps__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 6px;
	border: 0;
	background: transparent;
	color: #2c2c2c;
	font-size: 22px;
	line-height: 0;
	cursor: pointer;
	border-radius: 4px;
	-webkit-appearance: none;
	appearance: none;
}

.ccps__toggle svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
	display: block;
}

.ccps__toggle i {
	font-size: inherit;
	line-height: 1;
}

.ccps__toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ------------------------------------------------------------- Panel layout */
.ccps__panel {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	z-index: 9999;
	line-height: normal;
	text-align: left;
}

/* Anchor the panel relative to the icon by chosen direction. */
.ccps--dir-right .ccps__panel {
	left: calc(100% + 8px);
}

.ccps--dir-left .ccps__panel {
	right: calc(100% + 8px);
}

.ccps--dir-center .ccps__panel {
	top: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
}

.ccps--dir-full .ccps__panel {
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	transform: none;
}

/* --------------------------------------------------------------- Form / field */
.ccps__form {
	display: flex;
	align-items: center;
	width: var(--ccps-input-width);
	min-height: var(--ccps-input-height, auto);
	margin: 0;
	overflow: hidden;
	background: #ffffff;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
}

.ccps__input {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
	margin: 0;
	border: 0;
	outline: 0;
	background: transparent;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.3;
	color: #2c2c2c;
	-webkit-appearance: none;
	appearance: none;
}

/*
 * Defensive resets. Themes commonly style `input[type="search"]` (specificity
 * 0,1,1), which would otherwise beat the base `.ccps__input` rule (0,1,0) and
 * force their own height, border, background, shadow or rounding. Scoping to
 * `.ccps__form .ccps__input` (0,2,0) reliably wins, and `!important` covers the
 * more aggressive themes. Only neutral *structural* properties live here —
 * colour, padding and typography stay on the base rule so Elementor's Input
 * style controls keep overriding them.
 */
.ccps__form .ccps__input {
	height: auto !important;
	min-height: 0 !important;
	max-width: none !important;
	margin: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
}

.ccps__input::placeholder {
	color: #9a9a9a;
	opacity: 1;
}

/* Hide the native clear/cancel button for a consistent look. */
.ccps__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.ccps__close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 6px 10px;
	border: 0;
	background: transparent;
	color: #8a8a8a;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}

.ccps__close:hover {
	color: #2c2c2c;
}

/* --------------------------------------------------------------- Results box */
.ccps__results {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	margin-top: 6px;
	max-height: 360px;
	overflow-y: auto;
	background: #ffffff;
	border: 1px solid #ececec;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.ccps--dir-full .ccps__results {
	width: 100%;
}

.ccps__results[hidden] {
	display: none;
}

.ccps__result {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	color: #2c2c2c;
	text-decoration: none;
	border-bottom: 1px solid #f3f3f3;
}

.ccps__result:last-child {
	border-bottom: 0;
}

.ccps__result:hover,
.ccps__result.is-active {
	background: #f5f5f5;
	color: #000000;
	text-decoration: none;
}

.ccps__result-img {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	object-fit: cover;
	border-radius: 4px;
	background: #f0f0f0;
}

.ccps__result-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ccps__result-title {
	font-size: 14px;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ccps__result-price {
	font-size: 12px;
	line-height: 1.3;
	color: #777777;
}

/* Footer "view all results" link — inherits .ccps__result hover/active states. */
.ccps__view-all {
	justify-content: center;
	font-size: 13px;
	font-weight: 600;
	border-top: 1px solid #ececec;
	border-bottom: 0;
}

.ccps__status {
	padding: 12px;
	font-size: 13px;
	color: #777777;
	text-align: center;
}

/* =================================================================== Animations
 * The field is collapsed when closed and revealed when `.ccps.is-open` is set
 * by the script. The dropdown itself is shown/hidden via the [hidden] attribute.
 * ========================================================================== */

/* Width expand (default). */
.ccps--anim-width .ccps__form {
	max-width: 0;
	opacity: 0;
	visibility: hidden;
	transition:
		max-width var(--ccps-anim-duration) ease,
		opacity var(--ccps-anim-duration) ease,
		visibility var(--ccps-anim-duration) ease;
}

.ccps--anim-width.is-open .ccps__form {
	max-width: var(--ccps-input-width);
	opacity: 1;
	visibility: visible;
}

/* Fade in. */
.ccps--anim-fade .ccps__form {
	opacity: 0;
	visibility: hidden;
	transition:
		opacity var(--ccps-anim-duration) ease,
		visibility var(--ccps-anim-duration) ease;
}

.ccps--anim-fade.is-open .ccps__form {
	opacity: 1;
	visibility: visible;
}

/* Slide. */
.ccps--anim-slide .ccps__form {
	opacity: 0;
	visibility: hidden;
	transform: translateX(8px);
	transition:
		opacity var(--ccps-anim-duration) ease,
		transform var(--ccps-anim-duration) ease,
		visibility var(--ccps-anim-duration) ease;
}

.ccps--anim-slide.ccps--dir-left .ccps__form {
	transform: translateX(-8px);
}

.ccps--anim-slide.is-open .ccps__form {
	opacity: 1;
	visibility: visible;
	transform: translateX(0);
}

/* Full-width field should always fill its row regardless of animation. */
.ccps--dir-full .ccps__form,
.ccps--dir-full.is-open .ccps__form {
	max-width: 100%;
	width: 100%;
}

.ccps--dir-full .ccps__input {
	width: 100%;
}

@media ( prefers-reduced-motion: reduce ) {
	.ccps__form {
		transition: opacity var(--ccps-anim-duration) ease, visibility var(--ccps-anim-duration) ease !important;
		transform: none !important;
	}
}
