/**
 * Techlo Smart Search Pro — Front-end styles
 *
 * Design tokens
 * -------------
 * Surface (dark):     #0B0E14   Surface (light): #FFFFFF
 * Panel (dark):        rgba(18, 21, 32, .78) + blur   Panel (light): rgba(255,255,255,.85) + blur
 * Text primary:        #F5F6FA (dark) / #14161C (light)
 * Text muted:          #9AA1B1
 * Accent gradient:     var(--tssp-accent) -> #22D3EE
 * Radius:              controlled by --tssp-radius (admin setting)
 *
 * No web fonts are loaded — system font stack only. This is a deliberate
 * performance choice: a search overlay must never add font-load weight
 * to a page that didn't ask to open it.
 *
 * The one signature motion moment is the voice-search waveform; every
 * other transition is short and quiet. prefers-reduced-motion is respected.
 */

:root {
	--tssp-accent: #6C5CE7;
	--tssp-accent-2: #22D3EE;
	--tssp-radius: 16px;
	--tssp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--tssp-z: 999999;
}

/* ---------- Trigger ---------- */

#tssp-root {
	position: fixed;
	z-index: var( --tssp-z );
	bottom: 0;
	right: 0;
}

#tssp-root[data-position="floating"] .tssp-trigger-btn {
	position: fixed;
	right: 22px;
	bottom: 22px;
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.25 );
}

.tssp-trigger-btn,
.tssp-manual-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: linear-gradient( 135deg, var( --tssp-accent ), var( --tssp-accent-2 ) );
	cursor: pointer;
	border: none;
	color: #fff;
	font-family: var( --tssp-font );
}

.tssp-trigger-btn svg,
.tssp-manual-trigger svg {
	width: 20px;
	height: 20px;
}

.tssp-trigger-btn:hover,
.tssp-manual-trigger:hover {
	filter: brightness( 1.08 );
}

.tssp-inline-bar {
	width: auto;
	min-width: 220px;
	border-radius: var( --tssp-radius );
	padding: 10px 16px;
	justify-content: flex-start;
	gap: 8px;
	background: rgba( 108, 92, 231, 0.08 );
	color: #6c5ce7;
}

/* ---------- Overlay shell ---------- */

.tssp-overlay {
	position: fixed;
	inset: 0;
	z-index: var( --tssp-z );
	display: none;
	font-family: var( --tssp-font );
}

.tssp-overlay.tssp-open {
	display: block;
}

.tssp-backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 8, 10, 16, 0.55 );
	opacity: 0;
	transition: opacity var( --tssp-anim-duration, 180ms ) var( --tssp-anim-curve, ease );
}

.tssp-overlay.tssp-open .tssp-backdrop {
	opacity: 1;
}

.tssp-panel {
	position: relative;
	margin: 6vh auto 0;
	width: min( 640px, 92vw );
	max-height: 82vh;
	display: flex;
	flex-direction: column;
	border-radius: var( --tssp-radius );
	background: #ffffff;
	color: #14161c;
	box-shadow: 0 20px 60px rgba( 0, 0, 0, 0.3 );
	transition: transform var( --tssp-anim-duration, 180ms ) var( --tssp-anim-curve, ease ) var( --tssp-anim-delay, 0ms ),
		opacity var( --tssp-anim-duration, 180ms ) var( --tssp-anim-curve, ease ) var( --tssp-anim-delay, 0ms ),
		filter var( --tssp-anim-duration, 180ms ) var( --tssp-anim-curve, ease ) var( --tssp-anim-delay, 0ms );
	overflow: hidden;
}

/* Animation Builder styles — the closed (initial) state per style.
   The open state simply resets transform/opacity/filter to neutral. */
.tssp-anim-fade .tssp-panel { opacity: 0; }
.tssp-anim-slide .tssp-panel { opacity: 0; transform: translateY( -24px ); }
.tssp-anim-scale .tssp-panel { opacity: 0; transform: scale( 0.94 ); }
.tssp-anim-zoom .tssp-panel { opacity: 0; transform: scale( 0.8 ); }
.tssp-anim-bounce .tssp-panel { opacity: 0; transform: scale( 0.85 ); transition-timing-function: cubic-bezier( 0.34, 1.56, 0.64, 1 ); }
.tssp-anim-elastic .tssp-panel { opacity: 0; transform: scale( 0.7 ); transition-timing-function: cubic-bezier( 0.68, -0.55, 0.27, 1.55 ); }
.tssp-anim-blur .tssp-panel { opacity: 0; filter: blur( 8px ); }
.tssp-anim-glass .tssp-panel { opacity: 0; transform: scale( 0.97 ); filter: blur( 4px ); }
.tssp-anim-none .tssp-panel { transition: none; }

.tssp-overlay.tssp-open .tssp-panel {
	opacity: 1;
	transform: none;
	filter: none;
}

@media ( prefers-color-scheme: dark ) {
	.tssp-panel {
		background: rgba( 18, 21, 32, 0.92 );
		color: #f5f6fa;
	}
}

.tssp-theme-dark .tssp-panel {
	background: rgba( 18, 21, 32, 0.92 );
	color: #f5f6fa;
}

.tssp-theme-light .tssp-panel {
	background: #ffffff;
	color: #14161c;
}

.tssp-glass .tssp-panel {
	backdrop-filter: blur( 18px ) saturate( 140% );
	-webkit-backdrop-filter: blur( 18px ) saturate( 140% );
}

/* Layout variants */

.tssp-layout-popup .tssp-panel {
	margin-top: 10vh;
}

.tssp-layout-bottomsheet .tssp-panel {
	margin: auto 0 0;
	width: 100%;
	max-height: 88vh;
	border-radius: var( --tssp-radius ) var( --tssp-radius ) 0 0;
}

.tssp-layout-fullscreen .tssp-panel {
	margin: 0;
	width: 100%;
	height: 100%;
	max-height: none;
	border-radius: 0;
}

.tssp-layout-dropdown .tssp-panel {
	margin: 64px 24px 0 auto;
	width: min( 420px, 92vw );
	max-height: 70vh;
}

.tssp-layout-slidedown .tssp-panel {
	margin: 0 auto;
	width: 100%;
	max-height: 60vh;
	border-radius: 0 0 var( --tssp-radius ) var( --tssp-radius );
}

.tssp-layout-sidebar .tssp-panel {
	margin: 0 0 0 auto;
	width: min( 420px, 100vw );
	height: 100%;
	max-height: none;
	border-radius: 0;
}

.tssp-layout-compact .tssp-panel {
	margin: 8vh auto 0;
	width: min( 420px, 90vw );
	max-height: 50vh;
}

/* ---------- Search input row ---------- */

.tssp-input-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 16px 18px;
	border-bottom: 1px solid rgba( 128, 128, 128, 0.18 );
}

.tssp-input-row .tssp-icon {
	flex: 0 0 auto;
	opacity: 0.6;
	width: 18px;
	height: 18px;
}

.tssp-search-input {
	flex: 1 1 auto;
	border: none;
	outline: none;
	background: transparent;
	font-size: 16px;
	color: inherit;
	font-family: var( --tssp-font );
}

.tssp-search-input::placeholder {
	color: #9aa1b1;
}

.tssp-mic-btn,
.tssp-close-btn {
	flex: 0 0 auto;
	border: none;
	background: transparent;
	cursor: pointer;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: inherit;
	opacity: 0.65;
}

.tssp-mic-btn:hover,
.tssp-close-btn:hover {
	opacity: 1;
	background: rgba( 128, 128, 128, 0.12 );
}

.tssp-mic-btn.tssp-listening {
	color: var( --tssp-accent );
	opacity: 1;
}

/* Signature motion moment: voice waveform, shown only while listening */
.tssp-mic-btn.tssp-listening::after {
	content: "";
	position: absolute;
}

.tssp-waveform {
	display: none;
	align-items: center;
	gap: 3px;
	height: 18px;
	padding: 0 4px;
}

.tssp-waveform.tssp-active {
	display: flex;
}

.tssp-waveform span {
	width: 3px;
	border-radius: 2px;
	background: linear-gradient( var( --tssp-accent ), var( --tssp-accent-2 ) );
	animation: tssp-wave 0.9s ease-in-out infinite;
}

.tssp-waveform span:nth-child( 1 ) { height: 6px; animation-delay: 0s; }
.tssp-waveform span:nth-child( 2 ) { height: 14px; animation-delay: 0.12s; }
.tssp-waveform span:nth-child( 3 ) { height: 18px; animation-delay: 0.24s; }
.tssp-waveform span:nth-child( 4 ) { height: 10px; animation-delay: 0.36s; }
.tssp-waveform span:nth-child( 5 ) { height: 15px; animation-delay: 0.48s; }

@keyframes tssp-wave {
	0%, 100% { transform: scaleY( 0.5 ); }
	50% { transform: scaleY( 1 ); }
}

@media ( prefers-reduced-motion: reduce ) {
	.tssp-waveform span {
		animation: none;
	}
	.tssp-panel,
	.tssp-backdrop {
		transition: none;
	}
}

/* ---------- Filter tabs ---------- */

.tssp-filters {
	display: flex;
	gap: 6px;
	padding: 10px 18px;
	overflow-x: auto;
	border-bottom: 1px solid rgba( 128, 128, 128, 0.12 );
}

.tssp-filter-chip {
	flex: 0 0 auto;
	padding: 6px 14px;
	border-radius: 999px;
	font-size: 13px;
	border: 1px solid rgba( 128, 128, 128, 0.25 );
	background: transparent;
	color: inherit;
	cursor: pointer;
	white-space: nowrap;
}

.tssp-filter-chip.tssp-active {
	background: linear-gradient( 135deg, var( --tssp-accent ), var( --tssp-accent-2 ) );
	border-color: transparent;
	color: #fff;
}

/* ---------- Body / results ---------- */

.tssp-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 8px 10px 20px;
}

.tssp-section-label {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #9aa1b1;
	padding: 12px 10px 6px;
}

.tssp-chip-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 10px 8px;
}

.tssp-chip {
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba( 128, 128, 128, 0.1 );
	font-size: 13px;
	cursor: pointer;
	border: none;
	color: inherit;
}

.tssp-chip:hover {
	background: rgba( 108, 92, 231, 0.16 );
}

.tssp-clear-history {
	background: none;
	border: none;
	color: var( --tssp-accent );
	font-size: 12px;
	cursor: pointer;
	padding: 0 10px;
}

.tssp-result-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px;
	border-radius: 10px;
	cursor: pointer;
	text-decoration: none;
	color: inherit;
}

.tssp-result-item:hover,
.tssp-result-item.tssp-highlighted {
	background: rgba( 108, 92, 231, 0.1 );
}

.tssp-result-thumb {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border-radius: 8px;
	object-fit: cover;
	background: rgba( 128, 128, 128, 0.15 );
}

.tssp-result-text {
	flex: 1 1 auto;
	min-width: 0;
}

.tssp-result-title {
	font-size: 14px;
	font-weight: 600;
	margin: 0 0 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tssp-result-excerpt {
	font-size: 12px;
	color: #9aa1b1;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tssp-result-price {
	flex: 0 0 auto;
	font-size: 13px;
	font-weight: 600;
	color: var( --tssp-accent );
}

.tssp-result-type-badge {
	display: inline-block;
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 2px 6px;
	border-radius: 4px;
	background: rgba( 34, 211, 238, 0.15 );
	color: #0891b2;
	margin-inline-start: 6px;
}

.tssp-empty-state {
	text-align: center;
	padding: 40px 20px;
	color: #9aa1b1;
	font-size: 14px;
}

.tssp-view-all {
	display: block;
	text-align: center;
	padding: 12px;
	margin: 6px 10px 0;
	border-radius: 10px;
	background: rgba( 108, 92, 231, 0.08 );
	color: var( --tssp-accent );
	font-weight: 600;
	font-size: 13px;
	text-decoration: none;
	cursor: pointer;
	border: none;
}

/* ---------- RTL support (Urdu / Arabic) ---------- */

.tssp-rtl {
	direction: rtl;
	text-align: right;
}

.tssp-rtl .tssp-result-item {
	flex-direction: row-reverse;
}

/* ---------- Responsive ---------- */

@media ( max-width: 782px ) {
	.tssp-panel {
		width: 100%;
		margin: 0;
		height: 100%;
		max-height: none;
		border-radius: 0;
	}
	.tssp-search-input {
		font-size: 16px; /* prevents iOS zoom-on-focus */
	}
}

/* ---------- Accessibility ---------- */

.tssp-search-input:focus-visible,
.tssp-filter-chip:focus-visible,
.tssp-result-item:focus-visible,
.tssp-mic-btn:focus-visible,
.tssp-close-btn:focus-visible {
	outline: 2px solid var( --tssp-accent-2 );
	outline-offset: 2px;
}

.tssp-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	white-space: nowrap;
}

.tssp-hidden {
	display: none !important;
}

/* ---------------- Clear button ---------------- */

.tssp-clear-btn {
	flex: 0 0 auto;
	border: none;
	background: transparent;
	cursor: pointer;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: inherit;
	opacity: 0.5;
}

.tssp-clear-btn:hover {
	opacity: 1;
	background: rgba( 128, 128, 128, 0.12 );
}

/* ---------------- Section header row (history label + clear) ---------------- */

.tssp-section-label-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-inline-end: 10px;
}

/* ---------------- Did You Mean (Part 4 typo correction) ---------------- */

.tssp-did-you-mean {
	padding: 8px 14px;
	font-size: 12px;
	color: #9aa1b1;
}

.tssp-did-you-mean-term {
	background: none;
	border: none;
	padding: 0;
	color: var( --tssp-accent );
	font-weight: 600;
	cursor: pointer;
	text-decoration: underline;
}

/* ---------------- Grouped suggestion headers ---------------- */

.tssp-group-header {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 10px 10px 4px;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var( --tssp-accent );
	font-weight: 600;
}

/* ---------------- Highlighted match ---------------- */

mark.tssp-highlight {
	background: rgba( 34, 211, 238, 0.35 );
	color: inherit;
	border-radius: 2px;
	padding: 0 1px;
}

/* ---------------- Badges ---------------- */

.tssp-badge {
	display: inline-block;
	font-size: 9px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 2px 6px;
	border-radius: 4px;
	margin-inline-start: 4px;
	font-weight: 700;
}

.tssp-badge-new {
	background: rgba( 52, 211, 153, 0.18 );
	color: #059669;
}

.tssp-badge-featured {
	background: linear-gradient( 135deg, var( --tssp-accent ), var( --tssp-accent-2 ) );
	color: #fff;
}

.tssp-result-meta-row {
	display: flex;
	gap: 10px;
	margin-top: 2px;
}

.tssp-result-meta {
	font-size: 11px;
	color: #9aa1b1;
}

.tssp-result-rating {
	color: #f5a623;
	letter-spacing: 1px;
}

/* ---------------- Discover cards (Featured / Recently Added / Related) ---------------- */

.tssp-discover-row {
	display: flex;
	gap: 10px;
	overflow-x: auto;
	padding: 4px 10px 12px;
}

.tssp-discover-card {
	flex: 0 0 auto;
	width: 120px;
	text-decoration: none;
	color: inherit;
}

.tssp-discover-thumb {
	display: block;
	width: 120px;
	height: 72px;
	border-radius: 10px;
	object-fit: cover;
	background: rgba( 128, 128, 128, 0.15 );
	margin-bottom: 6px;
}

.tssp-discover-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.3;
}

/* ---------------- Skeleton loader (GPU-friendly shimmer, no spinner) ---------------- */

.tssp-skeleton-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px;
}

.tssp-skeleton-thumb,
.tssp-skeleton-line {
	background: linear-gradient( 90deg, rgba( 128, 128, 128, 0.12 ) 25%, rgba( 128, 128, 128, 0.22 ) 37%, rgba( 128, 128, 128, 0.12 ) 63% );
	background-size: 400% 100%;
	animation: tssp-shimmer 1.4s ease infinite;
	border-radius: 8px;
}

.tssp-skeleton-thumb {
	width: 44px;
	height: 44px;
	flex: 0 0 auto;
}

.tssp-skeleton-lines {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.tssp-skeleton-line {
	height: 10px;
	border-radius: 4px;
}

.tssp-skeleton-line-title {
	width: 60%;
}

.tssp-skeleton-line-sub {
	width: 90%;
}

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

/* ---------------- No Results screen ---------------- */

.tssp-no-results {
	text-align: center;
	padding: 30px 20px 10px;
}

.tssp-no-results-illustration {
	width: 100px;
	height: 76px;
	color: var( --tssp-accent );
	margin: 0 auto 10px;
}

.tssp-no-results-title {
	font-size: 14px;
	font-weight: 600;
	margin: 0 0 10px;
}

.tssp-no-results-tips {
	list-style: none;
	margin: 0 0 14px;
	padding: 0;
	font-size: 12px;
	color: #9aa1b1;
	display: inline-flex;
	flex-direction: column;
	gap: 4px;
}

.tssp-no-results-tips li::before {
	content: "— ";
}

/* ---------------- Footer ---------------- */

.tssp-footer {
	display: flex;
	justify-content: center;
	gap: 20px;
	padding: 10px;
	border-top: 1px solid rgba( 128, 128, 128, 0.15 );
	font-size: 12px;
}

.tssp-footer a {
	color: inherit;
	opacity: 0.75;
	text-decoration: none;
}

.tssp-footer a:hover {
	opacity: 1;
	color: var( --tssp-accent );
}

/* ---------------- High contrast mode ---------------- */

.tssp-high-contrast .tssp-panel {
	border: 2px solid currentColor;
}

.tssp-high-contrast .tssp-result-item:hover,
.tssp-high-contrast .tssp-result-item.tssp-highlighted {
	outline: 2px solid var( --tssp-accent-2 );
}

.tssp-high-contrast .tssp-result-excerpt,
.tssp-high-contrast .tssp-result-meta {
	color: inherit;
	opacity: 0.9;
}

@media ( prefers-contrast: more ) {
	.tssp-panel {
		border: 2px solid currentColor;
	}
}
