/* ==========================================================================
   PL AI Search — Premium Widget Styles
   ========================================================================== */

/* Container */
.pl-ai-search-widget {
	position: relative;
	width: 100%;
	max-width: 700px;
	margin: 0 auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	z-index: 10;
}

/* ==========================================================================
   Search bar
   ========================================================================== */

.pl-ai-search-bar {
	position: relative;
	background: rgba(255, 255, 255, 0.95);
	border-radius: 60px;
	box-shadow:
		0 2px 8px rgba(0, 0, 0, 0.08),
		0 8px 32px rgba(0, 0, 0, 0.12);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	transition:
		box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
		transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	border: 1px solid rgba(255, 255, 255, 0.6);
}

.pl-ai-search-bar:focus-within {
	box-shadow:
		0 4px 12px rgba(0, 0, 0, 0.1),
		0 12px 40px rgba(0, 0, 0, 0.16),
		0 0 0 2px rgba(255, 255, 255, 0.4);
	transform: translateY(-2px);
}

/* Input row */
.pl-ai-search-input-wrap {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 10px 8px 0;
}

/* Left search icon */
.pl-ai-search-icon-left {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 52px;
	color: #999;
	transition: color 0.2s ease;
}

.pl-ai-search-bar:focus-within .pl-ai-search-icon-left {
	color: #555;
}

/* Text input */
.pl-ai-search-input {
	flex: 1;
	border: none;
	outline: none;
	background: transparent;
	font-size: 17px;
	font-weight: 400;
	letter-spacing: -0.01em;
	line-height: 1.5;
	padding: 12px 0;
	color: #1a1a1a;
	min-width: 0;
}

.pl-ai-search-input::placeholder {
	color: #999;
	opacity: 1;
	font-weight: 400;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.pl-ai-search-mic,
.pl-ai-search-submit {
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	cursor: pointer;
	flex-shrink: 0;
	padding: 0;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
}

/* Mic button */
.pl-ai-search-mic {
	width: 42px;
	height: 42px;
	background: transparent;
	color: #888;
	border-radius: 50%;
}

.pl-ai-search-mic:hover {
	color: #333;
	background: rgba(0, 0, 0, 0.04);
}

/* Mic recording ring */
.pl-ai-search-mic-ring {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid transparent;
	pointer-events: none;
	transition: border-color 0.2s ease;
}

.pl-ai-search-mic.recording {
	color: #e53935;
}

.pl-ai-search-mic.recording .pl-ai-search-mic-ring {
	border-color: rgba(229, 57, 53, 0.35);
	animation: pl-ai-mic-ring 1.8s ease-in-out infinite;
}

@keyframes pl-ai-mic-ring {
	0%, 100% {
		transform: scale(1);
		opacity: 1;
	}
	50% {
		transform: scale(1.15);
		opacity: 0.5;
	}
}

/* Submit button — minimal transparent */
.pl-ai-search-submit {
	width: 40px;
	height: 40px;
	background: transparent;
	color: #999;
	border-radius: 50%;
	overflow: hidden;
}

.pl-ai-search-submit:hover {
	color: #333;
	background: rgba(0, 0, 0, 0.04);
	transform: scale(1.05);
}

.pl-ai-search-submit:active {
	transform: scale(0.95);
	background: rgba(0, 0, 0, 0.06);
}

.pl-ai-search-submit-arrow,
.pl-ai-search-submit-spinner {
	display: block;
}

.pl-ai-search-submit-spinner {
	display: none;
}

/* Searching state — swap arrow for spinner */
.pl-ai-search-submit.searching {
	pointer-events: none;
	color: #888;
}

.pl-ai-search-submit.searching .pl-ai-search-submit-arrow {
	display: none;
}

.pl-ai-search-submit.searching .pl-ai-search-submit-spinner {
	display: block;
	animation: pl-ai-spin 0.8s linear infinite;
}

@keyframes pl-ai-spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* ==========================================================================
   Typeahead dropdown
   ========================================================================== */

.pl-ai-search-typeahead {
	position: absolute;
	top: calc(100% + 6px);
	left: 8px;
	right: 8px;
	background: #fff;
	border-radius: 20px;
	box-shadow:
		0 4px 12px rgba(0, 0, 0, 0.08),
		0 12px 40px rgba(0, 0, 0, 0.12);
	overflow: hidden;
	z-index: 100;
	animation: pl-ai-typeahead-in 0.15s ease-out;
}

@keyframes pl-ai-typeahead-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.pl-ai-search-typeahead-item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 22px;
	cursor: pointer;
	transition: background-color 0.12s ease;
	font-size: 15px;
	font-weight: 400;
	color: #1a1a1a;
	text-decoration: none;
	border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.pl-ai-search-typeahead-item:last-child {
	border-bottom: none;
}

.pl-ai-search-typeahead-item:first-child {
	padding-top: 16px;
}

.pl-ai-search-typeahead-item:last-child {
	padding-bottom: 16px;
}

.pl-ai-search-typeahead-item:hover,
.pl-ai-search-typeahead-item.active {
	background: #f7f7f7;
}

.pl-ai-search-typeahead-item .pl-ai-search-typeahead-icon {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	color: #bbb;
	transition: color 0.1s ease;
}

.pl-ai-search-typeahead-item:hover .pl-ai-search-typeahead-icon,
.pl-ai-search-typeahead-item.active .pl-ai-search-typeahead-icon {
	color: #888;
}

.pl-ai-search-typeahead-item .pl-ai-search-typeahead-label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Highlight matched text */
.pl-ai-search-typeahead-item mark {
	background: transparent;
	font-weight: 600;
	color: inherit;
}

/* Navigate arrow hint on hover */
.pl-ai-search-typeahead-item::after {
	content: '';
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ccc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E") center / contain no-repeat;
	opacity: 0;
	transition: opacity 0.1s ease;
}

.pl-ai-search-typeahead-item:hover::after,
.pl-ai-search-typeahead-item.active::after {
	opacity: 1;
}

/* ==========================================================================
   Loading state — light frosted pill
   ========================================================================== */

.pl-ai-search-loading {
	display: flex;
	justify-content: center;
	padding-top: 10px;
}

.pl-ai-search-loading-inner {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 8px 20px 8px 16px;
	background: rgba(255, 255, 255, 0.85);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	border-radius: 40px;
	box-shadow:
		0 2px 8px rgba(0, 0, 0, 0.08),
		0 0 0 1px rgba(0, 0, 0, 0.06);
	animation: pl-ai-loading-in 0.2s ease-out;
}

@keyframes pl-ai-loading-in {
	from {
		opacity: 0;
		transform: translateY(-4px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Pulsing dots */
.pl-ai-search-loading-dot {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: #999;
	animation: pl-ai-dot-pulse 1.2s ease-in-out infinite;
}

.pl-ai-search-loading-dot:nth-child(2) {
	animation-delay: 0.15s;
}

.pl-ai-search-loading-dot:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes pl-ai-dot-pulse {
	0%, 80%, 100% {
		opacity: 0.2;
		transform: scale(0.8);
	}
	40% {
		opacity: 1;
		transform: scale(1);
	}
}

.pl-ai-search-loading-text {
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.02em;
	color: #666;
	margin-left: 3px;
	white-space: nowrap;
}

/* ==========================================================================
   Message (no results / error)
   ========================================================================== */

.pl-ai-search-message {
	text-align: center;
	padding: 12px 22px;
	margin-top: 10px;
	font-size: 13px;
	line-height: 1.6;
	color: #555;
	background: rgba(255, 255, 255, 0.85);
	border-radius: 16px;
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	box-shadow:
		0 2px 8px rgba(0, 0, 0, 0.08),
		0 0 0 1px rgba(0, 0, 0, 0.06);
	animation: pl-ai-message-in 0.2s ease-out;
}

@keyframes pl-ai-message-in {
	from { opacity: 0; transform: translateY(-4px); }
	to   { opacity: 1; transform: translateY(0); }
}

.pl-ai-search-message a {
	color: #333;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.pl-ai-search-message a:hover {
	color: #111;
}

.pl-ai-search-message em {
	font-style: italic;
	color: #777;
}

/* ==========================================================================
   "AI-powered" label
   ========================================================================== */

.pl-ai-search-powered {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	padding-top: 10px;
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.55);
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.elementor-widget-pl-ai-search .pl-ai-search-powered {
	color: rgba(0, 0, 0, 0.3);
	text-shadow: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
	.pl-ai-search-widget {
		max-width: 100%;
		padding: 0 16px;
		box-sizing: border-box;
	}

	.pl-ai-search-bar {
		border-radius: 20px;
	}

	.pl-ai-search-input-wrap {
		padding: 6px 8px 6px 0;
	}

	.pl-ai-search-icon-left {
		width: 44px;
	}

	.pl-ai-search-input {
		font-size: 16px;
		padding: 10px 0;
	}

	.pl-ai-search-mic {
		width: 38px;
		height: 38px;
	}

	.pl-ai-search-submit {
		width: 38px;
		height: 38px;
	}

	.pl-ai-search-submit svg {
		width: 16px;
		height: 16px;
	}

	.pl-ai-search-typeahead {
		left: 4px;
		right: 4px;
		border-radius: 16px;
	}

	.pl-ai-search-typeahead-item {
		padding: 12px 16px;
		font-size: 14px;
		gap: 12px;
	}
}

@media (min-width: 768px) and (max-width: 1024px) {
	.pl-ai-search-widget {
		max-width: 600px;
	}
}

/* ==========================================================================
   Elementor editor preview
   ========================================================================== */

.elementor-editor-active .pl-ai-search-widget {
	pointer-events: auto;
}

.elementor-editor-active .pl-ai-search-input {
	cursor: default;
}

/* ==========================================================================
   Dark mode support (prefers-color-scheme)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
	.elementor-widget-pl-ai-search .pl-ai-search-bar {
		background: rgba(40, 40, 40, 0.9);
		border-color: rgba(255, 255, 255, 0.08);
	}

	.elementor-widget-pl-ai-search .pl-ai-search-input {
		color: #f0f0f0;
	}

	.elementor-widget-pl-ai-search .pl-ai-search-input::placeholder {
		color: #888;
	}

	.elementor-widget-pl-ai-search .pl-ai-search-icon-left {
		color: #777;
	}

	.elementor-widget-pl-ai-search .pl-ai-search-submit {
		background: #fff;
		color: #1a1a1a;
	}

	.elementor-widget-pl-ai-search .pl-ai-search-typeahead {
		background: #2a2a2a;
	}

	.elementor-widget-pl-ai-search .pl-ai-search-typeahead-item {
		color: #eee;
		border-bottom-color: rgba(255, 255, 255, 0.06);
	}

	.elementor-widget-pl-ai-search .pl-ai-search-typeahead-item:hover,
	.elementor-widget-pl-ai-search .pl-ai-search-typeahead-item.active {
		background: rgba(255, 255, 255, 0.06);
	}
}
