/**
 * WC Ajax Search
 * Όλα τα χρώματα/μεγέθη είναι CSS variables: κάνε override σε .wcas (ή σε custom class)
 * χωρίς να αγγίξεις το plugin.
 */

.wcas {
	--wcas-accent: #2563eb;
	--wcas-radius: 12px;
	--wcas-bg: #fff;
	--wcas-panel-bg: #fff;
	--wcas-fg: #101828;
	--wcas-muted: #667085;
	--wcas-border: #e4e7ec;
	--wcas-hover: #f4f6fa;
	--wcas-shadow: 0 18px 40px -16px rgba(16, 24, 40, 0.28), 0 2px 6px -2px rgba(16, 24, 40, 0.08);
	--wcas-field-h: 48px;

	position: relative;
	display: block;
	width: 100%;
	color: var(--wcas-fg);
	font-size: 15px;
	line-height: 1.45;
	text-align: left;
}

.wcas *,
.wcas *::before,
.wcas *::after {
	box-sizing: border-box;
}

.wcas--align-center { margin-left: auto; margin-right: auto; }
.wcas--align-right  { margin-left: auto; }

.wcas--dark {
	--wcas-bg: #141a21;
	--wcas-panel-bg: #161d26;
	--wcas-fg: #eaeef4;
	--wcas-muted: #97a3b4;
	--wcas-border: #2a3441;
	--wcas-hover: #1e2733;
	--wcas-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
}

@media (prefers-color-scheme: dark) {
	.wcas--auto {
		--wcas-bg: #141a21;
		--wcas-panel-bg: #161d26;
		--wcas-fg: #eaeef4;
		--wcas-muted: #97a3b4;
		--wcas-border: #2a3441;
		--wcas-hover: #1e2733;
		--wcas-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
	}
}

/* ---------- Πεδίο ---------- */

.wcas .wcas__form {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
}

.wcas .wcas__field {
	position: relative;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	min-width: 0;
}

.wcas .wcas__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.wcas .wcas__icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	width: 18px;
	height: 18px;
	color: var(--wcas-muted);
	pointer-events: none;
}

.wcas .wcas__icon svg { width: 100%; height: 100%; display: block; }

.wcas .wcas__input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	height: var(--wcas-field-h);
	margin: 0;
	padding: 0 44px 0 42px;
	font: inherit;
	font-size: 15px;
	color: var(--wcas-fg);
	background: var(--wcas-bg);
	border: 1px solid var(--wcas-border);
	border-radius: var(--wcas-radius);
	box-shadow: none;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.wcas .wcas__input::placeholder { color: var(--wcas-muted); opacity: 1; }

.wcas .wcas__input::-webkit-search-cancel-button,
.wcas .wcas__input::-webkit-search-decoration { -webkit-appearance: none; }

.wcas .wcas__input:focus,
.wcas .wcas__input:focus-visible {
	border-color: var(--wcas-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wcas-accent) 22%, transparent);
}

.wcas .wcas__clear,
.wcas .wcas__spinner {
	position: absolute;
	top: 50%;
	right: 14px;
	transform: translateY(-50%);
	width: 20px;
	height: 20px;
}

.wcas .wcas__clear {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	color: var(--wcas-muted);
	background: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.wcas .wcas__clear:hover { color: var(--wcas-fg); }
.wcas .wcas__clear svg { width: 14px; height: 14px; }
.wcas .wcas__clear[hidden] { display: none; }

.wcas .wcas__spinner {
	border: 2px solid var(--wcas-border);
	border-top-color: var(--wcas-accent);
	border-radius: 50%;
	animation: wcas-spin 0.7s linear infinite;
}

.wcas .wcas__spinner[hidden] { display: none; }

@keyframes wcas-spin { to { transform: translateY(-50%) rotate(360deg); } }

.wcas .wcas__submit {
	flex: 0 0 auto;
	height: var(--wcas-field-h);
	padding: 0 20px;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	color: #fff;
	background: var(--wcas-accent);
	border: 0;
	border-radius: var(--wcas-radius);
	cursor: pointer;
	transition: filter 0.15s ease;
}

.wcas .wcas__submit:hover { filter: brightness(1.08); }
.wcas .wcas__submit:focus-visible { outline: 2px solid var(--wcas-accent); outline-offset: 2px; }

/* ---------- Panel αποτελεσμάτων ---------- */

.wcas .wcas__panel {
	position: absolute;
	z-index: 9999;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	max-height: min(70vh, 520px);
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--wcas-panel-bg);
	border: 1px solid var(--wcas-border);
	border-radius: var(--wcas-radius);
	box-shadow: var(--wcas-shadow);
	-webkit-overflow-scrolling: touch;
}

.wcas .wcas__panel[hidden] { display: none; }

.wcas .wcas__item {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	color: inherit;
	text-decoration: none;
	border-bottom: 1px solid var(--wcas-border);
	box-shadow: inset 2px 0 0 transparent;
	transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.wcas .wcas__item:last-of-type { border-bottom: 0; }

.wcas .wcas__item--noimg { grid-template-columns: 1fr auto; }

.wcas .wcas__item:hover,
.wcas .wcas__item.is-active {
	background: var(--wcas-hover);
	box-shadow: inset 2px 0 0 var(--wcas-accent);
	text-decoration: none;
}

.wcas .wcas__thumb {
	display: block;
	width: 44px;
	height: 44px;
	flex: 0 0 auto;
	object-fit: cover;
	background: var(--wcas-hover);
	border: 1px solid var(--wcas-border);
	border-radius: calc(var(--wcas-radius) / 2);
}

.wcas .wcas__body { min-width: 0; }

.wcas .wcas__title {
	display: block;
	overflow: hidden;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.wcas .wcas__title mark {
	padding: 0 1px;
	color: inherit;
	background: rgba(37, 99, 235, 0.16);
	background: color-mix(in srgb, var(--wcas-accent) 18%, transparent);
	border-radius: 3px;
}

.wcas .wcas__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	margin-top: 2px;
	font-size: 12.5px;
	color: var(--wcas-muted);
}

.wcas .wcas__meta span { white-space: nowrap; }
.wcas .wcas__meta .is-out { color: #b42318; }
.wcas .wcas__meta .is-backorder { color: #b54708; }

.wcas .wcas__price {
	flex: 0 0 auto;
	font-weight: 600;
	font-size: 14px;
	text-align: right;
	white-space: nowrap;
}

.wcas .wcas__price del { font-weight: 400; opacity: 0.6; }
.wcas .wcas__price ins { text-decoration: none; }
.wcas .wcas__price .woocommerce-Price-currencySymbol { font-weight: inherit; }

.wcas .wcas__more {
	display: block;
	padding: 11px 14px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--wcas-accent);
	text-align: center;
	text-decoration: none;
	background: var(--wcas-hover);
	border-top: 1px solid var(--wcas-border);
}

.wcas .wcas__more:hover,
.wcas .wcas__more.is-active { text-decoration: underline; }

.wcas .wcas__message {
	padding: 18px 16px;
	font-size: 14px;
	color: var(--wcas-muted);
	text-align: center;
}

.wcas .wcas__message strong { color: var(--wcas-fg); }

/* ---------- Skeleton ---------- */

.wcas .wcas__skeleton {
	display: grid;
	grid-template-columns: 44px 1fr;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--wcas-border);
}

.wcas .wcas__skeleton:last-child { border-bottom: 0; }

.wcas .wcas__sk-box,
.wcas .wcas__sk-line {
	background: linear-gradient(90deg, var(--wcas-hover) 25%, var(--wcas-border) 50%, var(--wcas-hover) 75%);
	background-size: 400% 100%;
	border-radius: 6px;
	animation: wcas-shimmer 1.4s ease infinite;
}

.wcas .wcas__sk-box { width: 44px; height: 44px; }
.wcas .wcas__sk-line { height: 10px; }
.wcas .wcas__sk-line + .wcas__sk-line { width: 45%; margin-top: 8px; }

@keyframes wcas-shimmer {
	0% { background-position: 100% 0; }
	100% { background-position: 0 0; }
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
	.wcas { --wcas-field-h: 44px; }
	.wcas .wcas__submit { padding: 0 14px; font-size: 14px; }
	.wcas .wcas__panel { max-height: 60vh; }
	.wcas .wcas__price { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
	.wcas .wcas__spinner,
	.wcas .wcas__sk-box,
	.wcas .wcas__sk-line { animation-duration: 0.01ms; animation-iteration-count: 1; }
	.wcas .wcas__item { transition: none; }
}
