/* ==========================================================================
   CommerceBird Search Modal — Styles
   ========================================================================== */

/* --- Root wrapper (prevents layout interference) --- */
.cb-search-root {
	/* No height/width — only contains the trigger button in flow,
	   plus fixed-position overlay/modal taken out of flow */
}

/* --- Trigger button --- */
.cb-search-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background: #fff;
	color: #374151;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.cb-search-trigger:hover {
	background: #f9fafb;
	border-color: #9ca3af;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.08 );
}

/* --- Overlay --- */
.cb-search-overlay {
	position: fixed;
	inset: 0;
	z-index: 9999999;
	background: rgba( 0, 0, 0, 0.4 );
	backdrop-filter: blur( 4px );
	-webkit-backdrop-filter: blur( 4px );
}

/* Ensure hidden attribute wins over any explicit display value. */
.cb-search-overlay[hidden],
.cb-search-modal[hidden],
.cb-search-loading[hidden],
.cb-search-empty[hidden] {
	display: none !important;
}

/* --- Modal --- */
.cb-search-modal {
	position: absolute;
	inset: 0;
	z-index: 10000000;
	display: flex;
	flex-direction: column;
	background: #fff;
	height: 80vh;
	transition: height 0.3s ease;
	overflow: hidden;
}

.cb-search-modal.cb-has-results {
	height: 100vh;
	height: 100dvh;
}

/* --- Header --- */
.cb-search-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 24px;
	border-bottom: 1px solid #e5e7eb;
	flex-shrink: 0;
}

.cb-search-input-wrapper {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
}

.cb-search-icon {
	position: absolute;
	left: 0;
	width: 24px;
	height: 24px;
	color: #9ca3af;
	pointer-events: none;
}

.cb-search-input {
	width: 100%;
	padding: 12px 48px 12px 36px;
	font-size: 1.125rem;
	line-height: 1.5;
	border: none;
	outline: none;
	background: transparent;
	color: #111827;
}

.cb-search-input::placeholder {
	color: #9ca3af;
}

.cb-search-clear {
	position: absolute;
	right: 8px;
	padding: 4px;
	border: none;
	background: transparent;
	color: #9ca3af;
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.15s, background 0.15s;
}

.cb-search-clear:hover {
	color: #374151;
	background: #f3f4f6;
}

.cb-search-clear svg {
	width: 20px;
	height: 20px;
}

.cb-search-close {
	flex-shrink: 0;
	padding: 8px;
	border: none;
	background: transparent;
	color: #6b7280;
	cursor: pointer;
	border-radius: 8px;
	transition: color 0.15s, background 0.15s;
}

.cb-search-close:hover {
	color: #111827;
	background: #f3f4f6;
}

.cb-search-close svg {
	width: 24px;
	height: 24px;
}

/* --- Body --- */
.cb-search-body {
	display: flex;
	flex: 1;
	overflow: hidden;
}

/* --- Filters sidebar --- */
.cb-search-filters {
	width: 240px;
	flex-shrink: 0;
	border-right: 1px solid #e5e7eb;
	padding: 16px;
	overflow-y: auto;
	display: none;
}

@media ( min-width: 768px ) {
	.cb-search-filters {
		display: block;
	}
}

/* --- Results area --- */
.cb-search-results {
	flex: 1;
	overflow-y: auto;
	padding: 24px;
}

/* --- Loading skeleton --- */
.cb-search-loading {
	display: grid;
	grid-template-columns: repeat( 2, 1fr );
	gap: 16px;
}

@media ( min-width: 768px ) {
	.cb-search-loading {
		grid-template-columns: repeat( 3, 1fr );
	}
}

@media ( min-width: 1024px ) {
	.cb-search-loading {
		grid-template-columns: repeat( 4, 1fr );
	}
}

.cb-search-skeleton {
	padding: 12px;
}

.cb-search-skeleton-img {
	width: 100%;
	aspect-ratio: 1;
	background: #e5e7eb;
	border-radius: 8px;
	animation: cb-skeleton-pulse 1.5s ease-in-out infinite;
}

.cb-search-skeleton-line {
	height: 14px;
	margin-top: 10px;
	background: #e5e7eb;
	border-radius: 4px;
	animation: cb-skeleton-pulse 1.5s ease-in-out infinite;
}

.cb-search-skeleton-line--title {
	width: 80%;
}

.cb-search-skeleton-line--price {
	width: 40%;
}

@keyframes cb-skeleton-pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.4;
	}
}

/* --- Empty state --- */
.cb-search-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 64px 24px;
	color: #6b7280;
	text-align: center;
}

.cb-search-empty-icon {
	width: 64px;
	height: 64px;
	margin-bottom: 16px;
	opacity: 0.4;
}

.cb-search-empty p {
	font-size: 1rem;
	margin: 0;
}

/* --- Results grid --- */
.cb-search-grid {
	display: grid;
	grid-template-columns: repeat( 2, 1fr );
	gap: 16px;
}

@media ( min-width: 768px ) {
	.cb-search-grid {
		grid-template-columns: repeat( 3, 1fr );
	}
}

@media ( min-width: 1024px ) {
	.cb-search-grid {
		grid-template-columns: repeat( 4, 1fr );
	}
}

/* --- Product card --- */
.cb-search-card {
	display: flex;
	flex-direction: column;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	transition: box-shadow 0.2s, border-color 0.2s;
}

.cb-search-card:hover {
	box-shadow: 0 4px 12px rgba( 0, 0, 0, 0.08 );
	border-color: #d1d5db;
}

.cb-search-card-link {
	text-decoration: none;
	color: inherit;
	display: flex;
	flex-direction: column;
}

.cb-search-card-link:hover {
	color: inherit;
}

.cb-search-card-img {
	aspect-ratio: 1;
	overflow: hidden;
	background: #f9fafb;
	position: relative;
}

.cb-search-card-img-fallback {
	position: absolute;
	inset: 0;
	background: #e5e7eb;
}

.cb-search-card-img img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 12px;
	position: relative;
	z-index: 1;
}

.cb-search-card-link:hover {
	color: inherit;
}

.cb-search-card-title {
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.4;
	color: #111827;
	margin: 0;
	padding: 0 12px 12px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cb-search-card-body {
	padding: 0 12px 12px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.cb-search-card-price {
	font-size: 0.9375rem;
	font-weight: 600;
	color: #059669;
}

.cb-search-card-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
}

.cb-qty {
	display: flex;
	align-items: center;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	overflow: hidden;
}

.cb-qty-btn {
	width: 28px;
	height: 28px;
	border: none;
	background: #f9fafb;
	color: #374151;
	font-size: 1rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
}

.cb-qty-btn:hover {
	background: #e5e7eb;
}

.cb-qty-val {
	min-width: 28px;
	text-align: center;
	font-size: 0.8125rem;
	font-weight: 500;
	color: #111827;
}

.cb-add-to-cart {
	flex: 1;
	padding: 6px 10px;
	border: none;
	border-radius: 6px;
	background: #111827;
	color: #fff;
	font-size: 0.8125rem;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s;
}

.cb-add-to-cart:hover {
	background: #1f2937;
}

.cb-add-to-cart:disabled {
	background: #9ca3af;
	cursor: not-allowed;
}
