/**
 * ThemeVally Search Widget Stylesheet
 *
 * Premium styles for layouts 1-6, modal, offcanvas, and dropdowns.
 */

/* Core Container Rules */
.tv-search-container {
	position: relative;
	width: 100%;
	font-family: inherit;
	box-sizing: border-box;
}

.tv-search-container * {
	box-sizing: border-box;
}

/* Scroll Lock State */
body.tv-search-lock-scroll {
	overflow: hidden !important;
}

/* Hide triggers for inline layouts */
.tv-search-layout-classic .tv-search-trigger-btn,
.tv-search-layout-modern .tv-search-trigger-btn,
.tv-search-layout-minimal .tv-search-trigger-btn {
	display: none !important;
}

/* Trigger Button Styles */
.tv-search-trigger-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	cursor: pointer;
	color: #333;
	padding: 8px;
	transition: all 0.3s ease;
	outline: none;
}

.tv-search-trigger-btn svg {
	fill: currentColor;
	transition: fill 0.3s ease;
}

/* Common Form Elements */
.tv-search-field-wrapper {
	position: relative;
	width: 100%;
	display: flex;
	align-items: center;
}

.tv-search-input {
	width: 100%;
	padding: 12px 45px 12px 16px;
	font-size: 15px;
	color: #333;
	background-color: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	outline: none;
	transition: all 0.3s ease;
}

.tv-search-input::placeholder {
	color: #aaa;
	transition: color 0.3s ease;
}

.tv-search-btn {
	position: absolute;
	right: 0;
	top: 0;
	bottom: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	cursor: pointer;
	color: #555;
	padding: 0 15px;
	transition: all 0.3s ease;
	outline: none;
}

.tv-search-btn svg {
	fill: currentColor;
}

/* ==========================================
	LAYOUTS
	========================================== */

/* 1. Classic Search Layout */
.tv-search-layout-classic .tv-search-input {
	border: 1px solid #ddd;
	border-radius: 4px;
}

.tv-search-layout-classic .tv-search-btn {
	border-left: 1px solid #ddd;
	background-color: #f7f7f7;
	border-top-right-radius: 4px;
	border-bottom-right-radius: 4px;
}

/* 2. Modern Search Layout */
.tv-search-layout-modern .tv-search-input {
	border: 1px solid #eaeaea;
	border-radius: 30px;
	background-color: #f9f9f9;
	padding-right: 50px;
}

.tv-search-layout-modern .tv-search-input:focus {
	background-color: #fff;
	border-color: #0073aa;
	box-shadow: 0 0 0 1px #0073aa;
}

.tv-search-layout-modern .tv-search-btn {
	right: 5px;
	color: #888;
}

/* 3. Minimal Search Layout */
.tv-search-layout-minimal .tv-search-input {
	border: none;
	border-bottom: 2px solid #ddd;
	border-radius: 0;
	background-color: transparent;
	padding-left: 0;
	padding-right: 35px;
}

.tv-search-layout-minimal .tv-search-input:focus {
	border-bottom-color: #333;
}

.tv-search-layout-minimal .tv-search-btn {
	padding: 0 5px;
}

/* Layout Panels (Overlay, Fullscreen, Offcanvas) Hidden States */
.tv-search-panel-hidden {
	display: none !important;
}

/* 4. Overlay Popover Search Layout */
.tv-search-layout-overlay .tv-search-form-wrapper {
	position: absolute;
	top: 100%;
	right: 0;
	width: 320px;
	background: #fff;
	border: 1px solid #eee;
	border-radius: 6px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
	padding: 15px;
	z-index: 1000;
	margin-top: 10px;
	animation: tvSearchFadeIn 0.2s ease forwards;
}

/* 5. Fullscreen Search Layout */
.tv-search-layout-fullscreen .tv-search-form-wrapper {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tv-search-layout-fullscreen .tv-search-backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(15, 15, 15, 0.9);
	backdrop-filter: blur(8px);
	z-index: 1;
}

.tv-search-layout-fullscreen .tv-search-form-inner {
	position: relative;
	width: 700px;
	max-width: 90%;
	z-index: 2;
	margin: 0 auto;
}

.tv-search-layout-fullscreen .tv-search-input {
	font-size: 28px;
	padding: 20px 60px 20px 0;
	color: #fff;
	border: none;
	border-bottom: 3px solid rgba(255, 255, 255, 0.2);
	border-radius: 0;
	background-color: transparent;
}

.tv-search-layout-fullscreen .tv-search-input:focus {
	border-bottom-color: #fff;
}

.tv-search-layout-fullscreen .tv-search-btn {
	color: #fff;
	font-size: 24px;
	padding: 0 10px;
}

.tv-search-layout-fullscreen .tv-search-btn svg {
	width: 28px;
	height: 28px;
}

.tv-search-layout-fullscreen .tv-search-close-btn {
	position: absolute;
	top: -70px;
	right: 0;
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 8px;
	outline: none;
	transition: transform 0.3s ease;
}

.tv-search-layout-fullscreen .tv-search-close-btn:hover {
	transform: rotate(90deg);
}

/* 6. Offcanvas Panel Search Layout */
.tv-search-layout-offcanvas .tv-search-form-wrapper {
	position: fixed;
	top: 0;
	right: 0;
	width: 420px;
	max-width: 100%;
	height: 100vh;
	z-index: 99999;
	background: #fff;
	box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	animation: tvSearchSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tv-search-layout-offcanvas .tv-search-backdrop {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(3px);
	z-index: -1;
}

.tv-search-layout-offcanvas .tv-search-form-inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 30px;
}

.tv-search-layout-offcanvas .tv-search-close-btn {
	align-self: flex-end;
	background: transparent;
	border: none;
	color: #333;
	cursor: pointer;
	padding: 8px 0;
	margin-bottom: 20px;
	outline: none;
}

.tv-search-layout-offcanvas .tv-search-form {
	margin-bottom: 25px;
}

.tv-search-layout-offcanvas .tv-search-results-container {
	position: static;
	box-shadow: none;
	border: none;
	width: 100%;
	flex-grow: 1;
	overflow-y: auto;
	padding: 0;
	background: transparent;
}

/* ==========================================
	RESULTS DROPDOWN & PANEL
	========================================== */

.tv-search-results-container {
	position: absolute;
	top: 100%;
	left: 0;
	width: 100%;
	background-color: #fff;
	border: 1px solid #eee;
	border-radius: 4px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
	z-index: 999;
	margin-top: 5px;
	max-height: 400px;
	overflow-y: auto;
	display: none;
}

.tv-search-results-container.tv-has-results {
	display: block;
}

/* Custom Scrollbar for results dropdown */
.tv-search-results-container::-webkit-scrollbar {
	width: 6px;
}
.tv-search-results-container::-webkit-scrollbar-track {
	background: #f1f1f1;
}
.tv-search-results-container::-webkit-scrollbar-thumb {
	background: #ccc;
	border-radius: 3px;
}
.tv-search-results-container::-webkit-scrollbar-thumb:hover {
	background: #aaa;
}

/* Search results list */
.tv-search-results-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tv-search-result-item {
	border-bottom: 1px solid #f9f9f9;
	transition: background-color 0.2s ease;
}

.tv-search-result-item:last-child {
	border-bottom: none;
}

.tv-search-result-link {
	display: flex;
	align-items: flex-start;
	padding: 12px 16px;
	text-decoration: none !important;
	color: inherit;
	gap: 12px;
}

.tv-search-result-image {
	flex-shrink: 0;
	width: 50px;
	height: 50px;
	border-radius: 4px;
	overflow: hidden;
	background-color: #f0f0f0;
}

.tv-search-result-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tv-search-result-content {
	flex-grow: 1;
	min-width: 0;
}

.tv-search-result-category {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	color: #0073aa;
	margin-bottom: 2px;
	letter-spacing: 0.5px;
}

.tv-search-result-title {
	margin: 0 0 4px 0;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	color: #222;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tv-search-result-excerpt {
	margin: 0 0 4px 0;
	font-size: 12px;
	color: #666;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tv-search-result-meta {
	font-size: 11px;
	color: #999;
}

/* Selected/Hover States */
.tv-search-result-item:hover,
.tv-search-result-item.tv-selected {
	background-color: #f7f9fc;
}

.tv-search-result-item:hover .tv-search-result-title,
.tv-search-result-item.tv-selected .tv-search-result-title {
	color: #0073aa;
}

/* Loading & No Results Layouts */
.tv-search-loading {
	padding: 25px;
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tv-search-no-results,
.tv-search-error {
	padding: 20px 16px;
	text-align: center;
	font-size: 13px;
	color: #666;
}

.tv-search-error {
	color: #d9534f;
}

/* Loading Spinner */
.tv-search-spinner {
	display: inline-block;
	width: 24px;
	height: 24px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-radius: 50%;
	border-top-color: #0073aa;
	animation: tvSearchSpin 0.8s linear infinite;
}

/* Screen reader text helper */
.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* ==========================================
	ANIMATIONS
	========================================== */

@keyframes tvSearchSpin {
	to { transform: rotate(360deg); }
}

@keyframes tvSearchFadeIn {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes tvSearchSlideIn {
	from { transform: translateX(100%); }
	to { transform: translateX(0); }
}

/* Fullscreen special results spacing */
.tv-search-layout-fullscreen .tv-search-results-container {
	position: static;
	background: transparent;
	box-shadow: none;
	border: none;
	width: 100%;
	margin-top: 30px;
	max-height: 50vh;
}

.tv-search-layout-fullscreen .tv-search-result-item {
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tv-search-layout-fullscreen .tv-search-result-item:hover,
.tv-search-layout-fullscreen .tv-search-result-item.tv-selected {
	background-color: rgba(255, 255, 255, 0.05);
}

.tv-search-layout-fullscreen .tv-search-result-title {
	color: #fff;
}

.tv-search-layout-fullscreen .tv-search-result-excerpt {
	color: #ccc;
}

.tv-search-layout-fullscreen .tv-search-result-meta {
	color: #888;
}

.tv-search-layout-fullscreen .tv-search-no-results {
	color: #aaa;
}

.tv-search-layout-fullscreen .tv-search-spinner {
	border-top-color: #fff;
}

/* Responsive Adjustments */
@media (max-width: 767px) {
	.tv-search-layout-offcanvas .tv-search-form-wrapper {
		width: 100% !important;
	}
	.tv-search-layout-fullscreen .tv-search-form-inner {
		width: 100% !important;
		padding: 0 15px;
	}
	.tv-search-layout-fullscreen .tv-search-input {
		font-size: 20px;
	}
}

/* ==========================================
	PREMIUM RESULT GRID LAYOUTS
	========================================== */
.tv-results-layout-grid-2 {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 15px;
	padding: 15px;
}
.tv-results-layout-grid-3 {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 15px;
	padding: 15px;
}
.tv-results-layout-grid-4 {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 15px;
	padding: 15px;
}

.tv-results-layout-grid-2 .tv-search-result-item,
.tv-results-layout-grid-3 .tv-search-result-item,
.tv-results-layout-grid-4 .tv-search-result-item {
	border-bottom: none;
	background-color: #fff;
	border: 1px solid #f0f0f0;
	border-radius: 6px;
	transition: all 0.3s ease;
}

/* Responsive Grid Resets */
@media (max-width: 991px) {
	.tv-results-layout-grid-3 {
		grid-template-columns: repeat(2, 1fr);
	}
	.tv-results-layout-grid-4 {
		grid-template-columns: repeat(2, 1fr);
	}
}
@media (max-width: 575px) {
	.tv-results-layout-grid-2,
	.tv-results-layout-grid-3,
	.tv-results-layout-grid-4 {
		grid-template-columns: 1fr;
		padding: 10px;
	}
}

/* ==========================================
	SKELETON SHIMMER LOADERS
	========================================== */
.tv-search-skeleton-wrapper {
	display: flex;
	flex-direction: column;
	width: 100%;
}
.tv-search-skeleton-item {
	display: flex;
	align-items: flex-start;
	padding: 12px 16px;
	gap: 12px;
	border-bottom: 1px solid #f9f9f9;
}
.tv-search-skeleton-thumbnail {
	width: 50px;
	height: 50px;
	background-color: #eee;
	border-radius: 4px;
	flex-shrink: 0;
}
.tv-search-skeleton-content {
	flex-grow: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.tv-search-skeleton-title {
	width: 60%;
	height: 14px;
	background-color: #eee;
	border-radius: 2px;
	margin-bottom: 4px;
}
.tv-search-skeleton-excerpt {
	width: 90%;
	height: 10px;
	background-color: #f5f5f5;
	border-radius: 2px;
}
.tv-search-skeleton-excerpt.short {
	width: 40%;
}

/* Shimmer Animation Effect */
.tv-search-skeleton-thumbnail,
.tv-search-skeleton-title,
.tv-search-skeleton-excerpt {
	background: linear-gradient(90deg, #f3f3f3 25%, #e6e6e6 50%, #f3f3f3 75%);
	background-size: 200% 100%;
	animation: tvSearchShimmerPulse 1.5s infinite;
}

@keyframes tvSearchShimmerPulse {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}
