/**
 * Atadecor Search — self-contained styles.
 *
 * The theme's Tailwind build only scans template-parts/, inc/ and woocommerce/
 * PHP files, so utilities generated at runtime from JS would not exist in the
 * compiled assets/css/style.css. Layout lives here; brand colours still come
 * from the theme palette classes used in the markup (bg-primary, text-dark,
 * bg-natural-alpha, rounded-secondary, ...).
 */

.atadecor-search {
	position: relative;
	width: 100%;
}

.atadecor-search-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	width: 100%;
}

.atadecor-search-icon {
	flex-shrink: 0;
	font-size: 18px;
}

.atadecor-search-input {
	flex: 1 1 auto;
	border: 0;
	outline: 0;
	background: transparent;
	min-width: 0;
	padding: 4px 0;
}

.atadecor-search-input::-webkit-search-cancel-button {
	display: none;
}

.atadecor-search-clear {
	display: none;
	flex-shrink: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	padding: 4px;
	line-height: 1;
	color: #7c786e;
}

.atadecor-search.is-open .atadecor-search-clear {
	display: inline-flex;
}

.atadecor-search-spinner,
.atadecor-search-spinner-lg {
	display: none;
	border-radius: 50%;
	border: 2px solid #e5e1d7;
	border-top-color: #69705a;
	animation: atadecor-search-spin 0.6s linear infinite;
}

.atadecor-search-spinner {
	width: 16px;
	height: 16px;
}

.atadecor-search-spinner-lg {
	display: block;
	width: 28px;
	height: 28px;
	margin: 0 auto 8px;
}

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

/* Dropdown ---------------------------------------------------------------- */

.atadecor-search-results {
	position: absolute;
	inset-inline: 0;
	top: calc(100% + 6px);
	z-index: 50;
	max-height: 70vh;
	overflow-y: auto;
	padding: 12px;
}

.atadecor-search-results[hidden] {
	display: none;
}

.atadecor-search-loading {
	padding: 24px 0;
	text-align: center;
	color: #7c786e;
}

.atadecor-search-section-title {
	display: block;
	margin-bottom: 8px;
	color: #7c786e;
}

.atadecor-search-view-all {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 12px;
	padding: 6px 10px;
	color: #fff;
	text-decoration: none;
	transition: opacity 0.2s ease;
}

.atadecor-search-view-all:hover {
	opacity: 0.9;
	color: #fff;
}

/* Result rows ------------------------------------------------------------- */

.atadecor-search-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.atadecor-search-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px;
	border-radius: 0.75rem;
	transition: background-color 0.2s ease;
}

.atadecor-search-item:hover {
	background-color: #f5f2eb;
}

.atadecor-search-item-image {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	overflow: hidden;
}

.atadecor-search-item-image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.atadecor-search-item-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.atadecor-search-item-title {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.6;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.atadecor-search-item-title a {
	text-decoration: none;
	color: inherit;
}

.atadecor-search-item-title a:hover {
	color: #69705a;
}

.atadecor-search-price .price {
	font-size: 14px;
}

.atadecor-search-price del {
	opacity: 0.6;
	margin-inline-end: 4px;
}

.atadecor-search-empty {
	display: block;
	padding: 20px 0;
	text-align: center;
}

/* History chips ----------------------------------------------------------- */

.atadecor-search-history {
	margin-bottom: 14px;
}

.atadecor-search-history-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.atadecor-search-history-clear {
	border: 0;
	background: transparent;
	color: #7c786e;
	cursor: pointer;
	padding: 0;
}

.atadecor-search-history-clear:hover {
	color: #cc0000;
}

.atadecor-search-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.atadecor-search-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.2s ease;
	max-width: 100%;
}

.atadecor-search-chip:hover {
	background-color: #e5e1d7;
}

.atadecor-search-chip-text {
	max-width: 150px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.atadecor-search-chip-remove {
	cursor: pointer;
	opacity: 0.6;
}

.atadecor-search-chip-remove:hover {
	opacity: 1;
	color: #cc0000;
}

/* Categories -------------------------------------------------------------- */

.atadecor-search-categories {
	margin-top: 4px;
}

.atadecor-search-category-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px 8px;
}

.atadecor-search-category {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	text-align: center;
	text-decoration: none;
}

.atadecor-search-category-thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	overflow: hidden;
	transition: transform 0.2s ease;
}

.atadecor-search-category:hover .atadecor-search-category-thumb {
	transform: scale(1.05);
}

.atadecor-search-category-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.atadecor-search-category-blank {
	width: 100%;
	height: 100%;
	background-color: #e5e1d7;
}

.atadecor-search-category-name {
	line-height: 1.4;
}

/* Terms ------------------------------------------------------------------- */

.atadecor-search-terms {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 4px;
}

.atadecor-search-term {
	padding: 4px 10px;
	text-decoration: none;
}

.atadecor-search-term:hover {
	background-color: #e5e1d7;
}

@media (max-width: 767px) {
	.atadecor-search-results {
		max-height: 80vh;
	}

	.atadecor-search-category-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/*
 * وقتی پنل نتایج باز است، ظرفی که آن را می‌بُرد آزاد می‌شود.
 *
 * پنل position:absolute با z-index است، ولی overflow:hidden روی هر والد،
 * فرزند absolute را می‌بُرد و z-index در این حالت بی‌اثر است. هدر چنین ظرفی
 * دارد و برای همین پنل جست‌وجو پشت بخش هیرو ناپدید می‌شد.
 *
 * کلاس را جاوااسکریپت روی همان ظرف می‌گذارد؛ اینجا isolation هم می‌دهیم تا
 * ظرف یک لایه‌ی مستقل بسازد و پنل روی بخش‌های بعدی صفحه بیاید.
 */
.atadecor-search-unclip {
	overflow: visible !important;
	position: relative;
	z-index: 60;
}

/* پشتیبانی مرورگرهایی که کلاس جاوااسکریپتی به آن‌ها نرسیده باشد. */
.overflow-hidden:has(.atadecor-search.is-open) {
	overflow: visible;
	position: relative;
	z-index: 60;
}
