/*
 * SearchX – Frontend Styles
 * Version: 1.0.0
 */

/* ------------------------------------------------------------------ */
/* Widget wrapper                                                       */
/* ------------------------------------------------------------------ */

.searchx-widget {
	--sx-radius:    6px;
	--sx-gap:       16px;
	--sx-border:    1px solid #e2e8f0;
	--sx-bg:        #fff;
	--sx-text:      #1a1a2e;
	--sx-muted:     #64748b;
	--sx-accent:    #2563eb;
	--sx-accent-bg: #eff6ff;
	--sx-highlight: #fef9c3;
	font-family: inherit;
	color: var(--sx-text);
	box-sizing: border-box;
}

.searchx-widget *,
.searchx-widget *::before,
.searchx-widget *::after {
	box-sizing: inherit;
}

/* ------------------------------------------------------------------ */
/* Search bar                                                           */
/* ------------------------------------------------------------------ */

.searchx-search-bar {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.searchx-search-input-wrap {
	position: relative;
	flex: 1;
}

.searchx-search-icon {
	position: absolute;
	left: 11px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--sx-muted);
	display: flex;
	align-items: center;
	pointer-events: none;
}

.searchx-search-input {
	width: 100%;
	padding: 9px 36px 9px 36px;
	border: var(--sx-border);
	border-radius: var(--sx-radius);
	font-size: 14px;
	line-height: 1.5;
	color: var(--sx-text);
	background: var(--sx-bg);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	appearance: none;
}

.searchx-search-input:focus {
	outline: none;
	border-color: var(--sx-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.searchx-clear-btn {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	cursor: pointer;
	color: var(--sx-muted);
	padding: 4px;
	display: flex;
	align-items: center;
	border-radius: 50%;
	transition: background 0.15s;
}

.searchx-clear-btn:hover {
	background: #f1f5f9;
	color: var(--sx-text);
}

.searchx-search-btn {
	padding: 9px 18px;
	background: var(--sx-accent);
	color: #fff;
	border: none;
	border-radius: var(--sx-radius);
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s;
	white-space: nowrap;
}

.searchx-search-btn:hover {
	background: #1d4ed8;
}

.searchx-search-btn:active {
	transform: scale(0.98);
}

/* ------------------------------------------------------------------ */
/* Filters                                                              */
/* ------------------------------------------------------------------ */

.searchx-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;
	align-items: center;
}

.searchx-filter-wrap {
	flex: 1;
	min-width: 160px;
}

.searchx-filter-select {
	width: 100%;
	padding: 8px 10px;
	border: var(--sx-border);
	border-radius: var(--sx-radius);
	font-size: 14px;
	color: var(--sx-text);
	background: var(--sx-bg);
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	padding-right: 30px;
	transition: border-color 0.15s;
}

.searchx-filter-select:focus {
	outline: none;
	border-color: var(--sx-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.searchx-sort-wrap {
	flex: 0 0 auto;
	min-width: 160px;
}

.searchx-reset-btn {
	background: none;
	border: var(--sx-border);
	border-radius: var(--sx-radius);
	padding: 8px 14px;
	font-size: 13px;
	color: var(--sx-muted);
	cursor: pointer;
	transition: border-color 0.15s, color 0.15s;
	white-space: nowrap;
}

.searchx-reset-btn:hover {
	border-color: var(--sx-accent);
	color: var(--sx-accent);
}

/* ------------------------------------------------------------------ */
/* Results meta                                                         */
/* ------------------------------------------------------------------ */

.searchx-results-meta {
	font-size: 13px;
	color: var(--sx-muted);
	margin-bottom: 14px;
	min-height: 20px;
}

/* ------------------------------------------------------------------ */
/* Loading spinner                                                      */
/* ------------------------------------------------------------------ */

.searchx-loading {
	display: flex;
	justify-content: center;
	padding: 40px 0;
}

.searchx-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid #e2e8f0;
	border-top-color: var(--sx-accent);
	border-radius: 50%;
	animation: searchx-spin 0.7s linear infinite;
}

@keyframes searchx-spin {
	to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/* Post grid                                                            */
/* ------------------------------------------------------------------ */

.searchx-posts-grid {
	display: grid;
	gap: var(--sx-gap);
}

/* Column variants */
.searchx-cols-1 { grid-template-columns: 1fr; }
.searchx-cols-2 { grid-template-columns: repeat(2, 1fr); }
.searchx-cols-3 { grid-template-columns: repeat(3, 1fr); }
.searchx-cols-4 { grid-template-columns: repeat(4, 1fr); }
.searchx-cols-5 { grid-template-columns: repeat(5, 1fr); }
.searchx-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* List layout */
.searchx-layout-list .searchx-post-card {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 16px;
}

.searchx-layout-list .searchx-card-thumb-link {
	flex: 0 0 140px;
}

.searchx-layout-list .searchx-card-thumb-link img {
	height: 100px;
	object-fit: cover;
}

/* Masonry layout */
.searchx-layout-masonry {
	align-items: start;
}

/* ------------------------------------------------------------------ */
/* Post card                                                            */
/* ------------------------------------------------------------------ */

.searchx-post-card {
	background: var(--sx-bg);
	border: var(--sx-border);
	border-radius: var(--sx-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.searchx-post-card:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

.searchx-card-thumb-link {
	display: block;
	overflow: hidden;
}

.searchx-card-thumb-link img,
.searchx-post-card img.searchx-card-thumb {
	width: 100%;
	height: 180px;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.searchx-post-card:hover .searchx-card-thumb-link img {
	transform: scale(1.04);
}

.searchx-card-body {
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.searchx-card-title {
	font-size: 16px;
	font-weight: 600;
	margin: 0 0 8px;
	line-height: 1.35;
}

.searchx-card-title a {
	color: var(--sx-text);
	text-decoration: none;
	transition: color 0.15s;
}

.searchx-card-title a:hover {
	color: var(--sx-accent);
}

.searchx-card-excerpt {
	font-size: 14px;
	color: var(--sx-muted);
	margin: 0 0 10px;
	line-height: 1.6;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.searchx-card-meta {
	margin-top: auto;
	padding-top: 10px;
}

.searchx-card-date {
	font-size: 12px;
	color: var(--sx-muted);
}

.searchx-card-terms {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 8px;
}

.searchx-term-tag {
	display: inline-block;
	font-size: 11px;
	padding: 2px 8px;
	background: var(--sx-accent-bg);
	color: var(--sx-accent);
	border-radius: 20px;
	font-weight: 500;
}

/* ------------------------------------------------------------------ */
/* Keyword highlight                                                    */
/* ------------------------------------------------------------------ */

mark.searchx-highlight {
	background: var(--sx-highlight);
	color: inherit;
	border-radius: 2px;
	padding: 0 2px;
}

/* ------------------------------------------------------------------ */
/* No results                                                           */
/* ------------------------------------------------------------------ */

.searchx-no-results {
	text-align: center;
	padding: 40px 20px;
	color: var(--sx-muted);
}

.searchx-no-results-img {
	max-width: 180px;
	margin: 0 auto 16px;
	display: block;
	opacity: 0.7;
}

.searchx-no-results p {
	font-size: 15px;
	margin: 0;
}

/* ------------------------------------------------------------------ */
/* Pagination                                                           */
/* ------------------------------------------------------------------ */

.searchx-pagination-container {
	margin-top: 28px;
}

.searchx-pagination {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 4px;
	flex-wrap: wrap;
}

.searchx-page-btn {
	min-width: 36px;
	height: 36px;
	padding: 0 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: var(--sx-border);
	border-radius: var(--sx-radius);
	background: var(--sx-bg);
	color: var(--sx-text);
	font-size: 14px;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.searchx-page-btn:hover {
	border-color: var(--sx-accent);
	color: var(--sx-accent);
}

.searchx-page-btn.is-active {
	background: var(--sx-accent);
	border-color: var(--sx-accent);
	color: #fff;
	font-weight: 600;
}

.searchx-page-prev,
.searchx-page-next {
	font-size: 16px;
}

.searchx-page-ellipsis {
	padding: 0 4px;
	color: var(--sx-muted);
}


/* ------------------------------------------------------------------ */
/* Load More button                                                     */
/* ------------------------------------------------------------------ */

.searchx-load-more-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	padding: 20px 0 8px;
}

.searchx-load-more-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 32px;
	background: var(--sx-accent, #2563eb);
	color: #fff;
	border: none;
	border-radius: var(--sx-radius, 6px);
	font-size: 15px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s;
	min-width: 160px;
}

.searchx-load-more-btn:hover {
	background: #1d4ed8;
}

.searchx-load-more-btn:active {
	transform: scale(0.98);
}

.searchx-load-more-btn:disabled {
	opacity: 0.65;
	cursor: not-allowed;
	transform: none;
}

.searchx-load-more-count {
	font-size: 12px;
	color: var(--sx-muted, #64748b);
	margin: 0;
}

.searchx-all-loaded {
	text-align: center;
	font-size: 13px;
	color: var(--sx-muted, #64748b);
	padding: 20px 0 8px;
	margin: 0;
	border-top: 1px solid #e2e8f0;
}

/* ------------------------------------------------------------------ */
/* Error                                                                */
/* ------------------------------------------------------------------ */

.searchx-error {
	color: #dc2626;
	font-size: 14px;
	border: 1px solid #fecaca;
	background: #fef2f2;
	padding: 10px 14px;
	border-radius: var(--sx-radius);
}

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

@media (max-width: 768px) {
	.searchx-cols-3,
	.searchx-cols-4,
	.searchx-cols-5,
	.searchx-cols-6 {
		grid-template-columns: repeat(2, 1fr);
	}

	.searchx-layout-list .searchx-post-card {
		flex-direction: column;
	}

	.searchx-layout-list .searchx-card-thumb-link {
		flex: unset;
		width: 100%;
	}

	.searchx-layout-list .searchx-card-thumb-link img {
		height: 180px;
		width: 100%;
	}

	.searchx-filter-wrap {
		min-width: 100%;
	}
}

@media (max-width: 480px) {
	.searchx-cols-2,
	.searchx-cols-3,
	.searchx-cols-4,
	.searchx-cols-5,
	.searchx-cols-6 {
		grid-template-columns: 1fr;
	}

	.searchx-search-bar {
		flex-direction: column;
	}

	.searchx-search-btn {
		width: 100%;
	}
}

/* ------------------------------------------------------------------ */
/* No results — SVG icon variant (used when no custom image set)       */
/* ------------------------------------------------------------------ */

.searchx-no-results-icon {
	display: flex;
	justify-content: center;
	margin-bottom: 16px;
	color: #cbd5e1;
}

.searchx-no-results-icon svg {
	width: 48px;
	height: 48px;
}

.searchx-no-results-message {
	font-size: 15px;
	margin: 0 0 6px;
}

.searchx-no-results-hint {
	font-size: 13px;
	color: #94a3b8;
	margin: 0;
}

/* ------------------------------------------------------------------ */
/* Thumbnail placeholder (used by searchx_get_thumbnail helper)        */
/* ------------------------------------------------------------------ */

.searchx-card-thumb--placeholder {
	display: block;
	width: 100%;
	height: 180px;
	overflow: hidden;
}

.searchx-card-thumb--placeholder svg {
	width: 100%;
	height: 100%;
}

/* ------------------------------------------------------------------ */
/* List card — term tags inline variant                                 */
/* ------------------------------------------------------------------ */

.searchx-card-terms--inline {
	display: inline;
}

.searchx-card-terms--inline .searchx-term-tag {
	display: inline;
}

.searchx-card-meta-sep {
	margin: 0 4px;
	color: #cbd5e1;
}

/* ------------------------------------------------------------------ */
/* Term tag links                                                       */
/* ------------------------------------------------------------------ */

.searchx-term-tag a {
	color: inherit;
	text-decoration: none;
}

.searchx-term-tag a:hover {
	text-decoration: underline;
}
