/*
 * MeiliWoo Search Drawer — SearchTap-style FULL-SCREEN search experience. A dark
 * backdrop plus a white panel that slides in from the top: its own search input,
 * an empty-state "Popular products" grid, a live results meta line + speed pill,
 * a horizontally-scrollable row of category chips (toggle to filter), a 2-column
 * product grid, and a Load-more button.
 *
 * The grid holds Flatsome's NATIVE product markup (`.products.row` >
 * `.product-small.col`), so the block near the bottom FORCES a compact 2 / 3
 * column count that overrides Flatsome's own widths — otherwise the theme would
 * show up to 6 cards across in this panel.
 *
 * Accent color follows the same settings-backed variables as overlay.css /
 * instant.css (--meiliwoo-primary / --meiliwoo-secondary), with safe fallbacks.
 */

/* ------------------------------------------------------------------ *
 * Backdrop (dark scrim behind the panel)
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-backdrop {
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: rgba(0, 0, 0, .45);
	opacity: 0;
	transition: opacity .18s ease;
}

.meiliwoo-drawer-backdrop.is-open {
	opacity: 1;
}

.meiliwoo-drawer-backdrop[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Panel
 * ------------------------------------------------------------------ */

.meiliwoo-drawer {
	position: fixed;
	z-index: 99999;
	top: 0;
	height: 100vh;
	height: 100dvh;
	background: #fff;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .22);

	/* Slide-in: start slightly up + transparent; .is-open settles into place. */
	opacity: 0;
	transform: translateY(-8px);
	transition: opacity .18s ease, transform .18s ease;
}

.meiliwoo-drawer.is-open {
	opacity: 1;
	transform: translateY(0);
}

.meiliwoo-drawer *,
.meiliwoo-drawer *::before,
.meiliwoo-drawer *::after {
	box-sizing: border-box;
}

.meiliwoo-drawer[hidden] {
	display: none;
}

/* Mobile (<700px): full-width sheet. */
@media (max-width: 699px) {
	.meiliwoo-drawer {
		left: 0;
		right: 0;
		width: 100%;
	}
}

/* Desktop (≥700px): a proper CENTERED floating modal — not a full-height strip.
 * Anchored a little below the top and growing only as tall as its content (up to
 * 90vh), with all four corners rounded, so on a big monitor it reads as a clean
 * floating box instead of a tall column. Mobile stays full-screen (above). */
@media (min-width: 700px) {
	.meiliwoo-drawer {
		top: 5vh;
		left: 50%;
		transform: translateX(-50%) translateY(-8px);
		width: min(720px, 96vw);
		height: auto;
		max-height: 90vh;
		border-radius: 14px;
		overflow: hidden; /* clip the grid to the rounded corners; body scrolls inside */
	}

	.meiliwoo-drawer.is-open {
		transform: translateX(-50%) translateY(0);
	}
}

/* ------------------------------------------------------------------ *
 * Head: title + close
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 16px 2px;
}

.meiliwoo-drawer-title {
	margin: 0;
	font-weight: 700;
	font-size: 16px;
	line-height: 1.2;
	color: #111;
}

.meiliwoo-drawer-close {
	flex-shrink: 0;
	/* Fixed 42px box matching the input height + flex-centered icon, so the ✕ lines
	 * up vertically with the search field. !important beats the theme, which forces
	 * `display: contents` on buttons — that removes the button's box entirely and
	 * dropped the ✕ out of alignment. */
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 34px !important;
	height: 42px !important;
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: transparent;
	color: #777;
	cursor: pointer;
	padding: 0 !important;
	margin: 0 !important;
}

.meiliwoo-drawer-close:hover {
	color: #111;
}

/* ------------------------------------------------------------------ *
 * Searchbar: icon + input + clear-✕
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-searchbar {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
}

/* The input field wrapper holds the icon + input + clear-✕; the close button
 * sits after it at the end of the row (no separate title/close header). */
.meiliwoo-drawer-searchbar-field {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
}

.meiliwoo-drawer-input {
	width: 100%;
	/* Force the box model — the theme (Flatsome/WooCommerce) otherwise adds a
	 * margin-bottom + taller min-height to form inputs, which blew the searchbar
	 * up to ~107px and pushed the absolute search icon below the text. */
	height: 42px !important;
	min-height: 0 !important;
	margin: 0 !important;
	border: 2px solid #e3e3e3;
	border-radius: 999px;
	/* !important: the theme overrides input padding too, which shoved the text
	 * left onto the search icon. Force clearance for the icon (left) + clear-✕. */
	padding: 0 42px !important;
	font-size: 16px;
	line-height: normal;
	color: #111;
	background: #fff;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
}

.meiliwoo-drawer-input:focus {
	border-color: var(--meiliwoo-primary, #2563eb);
}

/* Kill the native search-input clear (we render our own). */
.meiliwoo-drawer-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.meiliwoo-drawer-searchicon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	color: #999;
	pointer-events: none;
}

.meiliwoo-drawer-inputclear {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: #888;
	cursor: pointer;
	padding: 2px 6px;
}

.meiliwoo-drawer-inputclear:hover {
	color: #111;
}

.meiliwoo-drawer-inputclear[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Meta line: count + speed pill
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 4px 16px;
	font-size: 13px;
	color: #444;
	border-top: 1px solid #f0f0f0;
}

.meiliwoo-drawer-meta[hidden] {
	display: none;
}

.meiliwoo-drawer-count {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.meiliwoo-drawer-speed {
	flex-shrink: 0;
	background: #e8f6ec;
	border-radius: 999px;
	padding: 3px 9px;
	color: #1a7f37;
	font-weight: 600;
	white-space: nowrap;
}

.meiliwoo-drawer-speed[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Toolbar: right-aligned Filter button that opens the bottom sheet
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 16px;
}

/* Sort button (left of the toolbar) — text + chevron, opens the sheet. */
.meiliwoo-drawer-sortbtn {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	border: 0;
	background: transparent;
	padding: 7px 4px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	color: #222;
	cursor: pointer;
}

.meiliwoo-drawer-sortbtn-chevron {
	display: inline-flex;
	align-items: center;
	color: #888;
}

/* Minimal (borderless) — matches the Sort button; primary-coloured like the
 * mockup's blue "Filter ⇄". */
.meiliwoo-drawer-filterbtn {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 0;
	background: transparent;
	padding: 7px 4px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	color: var(--meiliwoo-primary, #2563eb);
	cursor: pointer;
}

.meiliwoo-drawer-filterbtn:hover {
	opacity: .8;
}

.meiliwoo-drawer-filterbtn-icon {
	display: inline-flex;
	align-items: center;
	color: var(--meiliwoo-primary, #2563eb);
}

/* Active state keeps the same minimal frame — the count badge is the signal. */
.meiliwoo-drawer-filterbtn.is-active,
.meiliwoo-drawer-filterbtn.is-active .meiliwoo-drawer-filterbtn-icon {
	color: var(--meiliwoo-primary, #2563eb);
}

/* Count badge (shrinks to a plain dot when only a sort is active). */
.meiliwoo-drawer-filterbtn-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 999px;
	background: var(--meiliwoo-primary, #2563eb);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.meiliwoo-drawer-filterbtn-badge.is-dot {
	min-width: 8px;
	width: 8px;
	height: 8px;
	padding: 0;
}

.meiliwoo-drawer-filterbtn-badge[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Chips — shared by the sheet's Sort / Categories / Attribute rows
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-chips {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding: 0 16px 4px;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.meiliwoo-drawer-chips::-webkit-scrollbar {
	display: none;
}

.meiliwoo-drawer-chip {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 1px solid #e0e0e0;
	border-radius: 999px;
	background: #fff;
	padding: 6px 12px;
	font-size: 13px;
	white-space: nowrap;
	cursor: pointer;
	color: #222;
}

.meiliwoo-drawer-chip-count {
	font-size: 11px;
	color: #888;
	background: #f2f2f2;
	border-radius: 999px;
	padding: 1px 7px;
}

/* Active chip: primary outline + tint (plain #fff fallback for old browsers). */
.meiliwoo-drawer-chip.is-active {
	border-color: var(--meiliwoo-primary, #2563eb);
	color: var(--meiliwoo-primary, #2563eb);
	background: #fff;
	background: color-mix(in srgb, var(--meiliwoo-primary, #2563eb) 8%, #fff);
}

.meiliwoo-drawer-chip.is-active .meiliwoo-drawer-chip-count {
	color: var(--meiliwoo-primary, #2563eb);
	border: 1px solid var(--meiliwoo-primary, #2563eb);
	background: #fff;
	background: color-mix(in srgb, var(--meiliwoo-primary, #2563eb) 12%, #fff);
}

/* ------------------------------------------------------------------ *
 * Bottom sheet — filters + sort, opens OVER the drawer panel
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-sheet-backdrop {
	position: fixed;
	inset: 0;
	z-index: 100001;
	background: rgba(0, 0, 0, .45);
	opacity: 0;
	transition: opacity .18s ease;
}

.meiliwoo-drawer-sheet-backdrop.is-open {
	opacity: 1;
}

.meiliwoo-drawer-sheet-backdrop[hidden] {
	display: none;
}

.meiliwoo-drawer-sheet {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100002;
	background: #fff;
	border-radius: 16px 16px 0 0;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	box-shadow: 0 -12px 40px rgba(0, 0, 0, .22);

	/* Slide up from the bottom; .is-open settles into place. */
	transform: translateY(100%);
	transition: transform .24s ease;
}

.meiliwoo-drawer-sheet.is-open {
	transform: translateY(0);
}

.meiliwoo-drawer-sheet *,
.meiliwoo-drawer-sheet *::before,
.meiliwoo-drawer-sheet *::after {
	box-sizing: border-box;
}

.meiliwoo-drawer-sheet[hidden] {
	display: none;
}

/* Desktop (≥700px): centered card capped at 560px wide. */
@media (min-width: 700px) {
	.meiliwoo-drawer-sheet {
		left: 50%;
		right: auto;
		transform: translateX(-50%) translateY(100%);
		width: 560px;
		max-width: 96vw;
	}

	.meiliwoo-drawer-sheet.is-open {
		transform: translateX(-50%) translateY(0);
	}
}

/* Drag-handle pill (tap to close). */
.meiliwoo-drawer-sheet-handle {
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: transparent;
	display: block;
	width: 100%;
	padding: 10px 0 6px;
	cursor: pointer;
}

.meiliwoo-drawer-sheet-handle::before {
	content: "";
	display: block;
	width: 40px;
	height: 4px;
	margin: 0 auto;
	border-radius: 999px;
	background: #d5d5d5;
}

/* Scrollable content area. */
.meiliwoo-drawer-sheet-body {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 4px 0 8px;
}

.meiliwoo-drawer-sheet-section {
	padding: 6px 0;
}

.meiliwoo-drawer-sheet-section[hidden] {
	display: none;
}

.meiliwoo-drawer-sheet-title {
	margin: 8px 16px;
	font-size: 16px;
	font-weight: 700;
	color: #111;
}

/* Sticky footer — Reset (outline) + Apply (filled primary). */
.meiliwoo-drawer-sheet-footer {
	position: sticky;
	bottom: 0;
	display: flex;
	gap: 10px;
	padding: 12px 16px;
	border-top: 1px solid #eee;
	background: #fff;
}

.meiliwoo-drawer-sheet-reset,
.meiliwoo-drawer-sheet-apply {
	appearance: none;
	-webkit-appearance: none;
	flex: 1;
	height: 48px;
	border-radius: 10px;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
}

.meiliwoo-drawer-sheet-reset {
	flex: 0 0 40%;
	border: 1px solid #d0d0d0;
	background: #fff;
	color: #222;
}

.meiliwoo-drawer-sheet-reset:hover {
	border-color: #b0b0b0;
}

.meiliwoo-drawer-sheet-apply {
	border: 0;
	background: var(--meiliwoo-primary, #2563eb);
	color: #fff;
}

.meiliwoo-drawer-sheet-apply:hover {
	filter: brightness(.96);
}

/* ------------------------------------------------------------------ *
 * Desktop typography guard — keep the drawer + sheet COMPACT & MINIMAL
 * ------------------------------------------------------------------ *
 * The theme (Flatsome) scales headings UP and forces uppercase +
 * letter-spacing + bigger padding on <button> at desktop widths, which
 * blew the sheet's fonts up. Pin our own small, clean sizes (same as the
 * phone view) with !important, and drop the shouty uppercase for readable,
 * minimal chips. */
.meiliwoo-drawer-title {
	font-size: 16px !important;
	letter-spacing: normal !important;
}

.meiliwoo-drawer-count,
.meiliwoo-drawer-speed,
.meiliwoo-drawer-sortbtn,
.meiliwoo-drawer-filterbtn {
	font-size: 13px !important;
	letter-spacing: normal !important;
	text-transform: none !important;
}

.meiliwoo-drawer-sheet-title {
	font-size: 14px !important;
	line-height: 1.3 !important;
	font-weight: 700 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	margin: 10px 16px 4px !important;
}

.meiliwoo-drawer-chip {
	font-size: 12.5px !important;
	line-height: 1 !important;
	font-weight: 500 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	padding: 7px 12px !important;
}

.meiliwoo-drawer-chip-count {
	font-size: 11px !important;
	padding: 1px 7px !important;
	letter-spacing: normal !important;
}

.meiliwoo-drawer-sheet-reset,
.meiliwoo-drawer-sheet-apply {
	font-size: 14px !important;
	height: 44px !important;
	font-weight: 700 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
}

/* ------------------------------------------------------------------ *
 * Body: the injected product grid + load-more
 * ------------------------------------------------------------------ */

.meiliwoo-drawer-body {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 2px 10px 20px;
	border-top: 1px solid #f0f0f0;
}

.meiliwoo-drawer.is-loading .meiliwoo-drawer-body {
	opacity: .55;
	transition: opacity .15s ease;
}

.meiliwoo-drawer-empty {
	padding: 40px 16px;
	text-align: center;
	color: #666;
}

.meiliwoo-drawer-empty[hidden] {
	display: none;
}

.meiliwoo-drawer-more {
	display: block;
	margin: 14px auto;
	padding: 10px 22px;
	border: 1px solid #ddd;
	border-radius: 8px;
	background: #fff;
	font-weight: 600;
	cursor: pointer;
	color: #222;
}

.meiliwoo-drawer-more:hover {
	border-color: #bbb;
}

.meiliwoo-drawer-more[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Injected native product grid — FORCE compact responsive columns
 * ------------------------------------------------------------------ *
 * The body holds Flatsome's own `.products.row` > `.product-small.col` markup,
 * whose default widths can show up to 6 across. Inside this drawer we clamp to
 * 2 / 3 columns via high-specificity + !important. */

/* Base: 2 columns — what the user specifically wants on phones. */
.meiliwoo-drawer .products .product-small.col {
	width: 50% !important;
	padding-left: 6px !important;
	padding-right: 6px !important;
	margin-bottom: 2px !important;
}

/* Wider drawers: 3 columns. */
@media (min-width: 560px) {
	.meiliwoo-drawer .products .product-small.col {
		width: 33.3333% !important;
	}
}

/* Flatsome fades/transforms cards in on load — neutralize so they show at once. */
.meiliwoo-drawer .product-small.col {
	opacity: 1 !important;
	transform: none !important;
}

/* Never let the native row's negative margins overflow the panel. */
.meiliwoo-drawer .products.row {
	margin-left: 0;
	margin-right: 0;
}

/* --- COMPACT the native card ---------------------------------------------- *
 * The theme's catalog card is tall (big image + add-to-cart). A search preview
 * wants DENSE results, so we cap the image height, tighten the text, and drop
 * the add-to-cart button + rating/category meta (tapping a card opens the
 * product). This is what makes the drawer feel compact like the competitor. */

.meiliwoo-drawer .product-small .box-image {
	margin-bottom: 6px !important;
}
.meiliwoo-drawer .product-small .box-image img {
	max-height: 140px !important;
	width: auto !important;
	height: auto !important;
	margin: 0 auto !important;
	display: block !important;
	object-fit: contain !important;
}

.meiliwoo-drawer .product-small .box-text {
	padding: 0 2px 2px !important;
	text-align: left !important;
}
.meiliwoo-drawer .product-small .title-wrapper {
	margin: 0 !important;
}
.meiliwoo-drawer .product-small .name,
.meiliwoo-drawer .product-small .product-title {
	font-size: 12px !important;
	line-height: 1.3 !important;
	margin: 0 0 2px !important;
	font-weight: 500 !important;
}
.meiliwoo-drawer .product-small .price,
.meiliwoo-drawer .product-small .price ins,
.meiliwoo-drawer .product-small .price del {
	font-size: 12.5px !important;
	line-height: 1.25 !important;
}

/* Drop add-to-cart + rating/category meta for a clean, compact preview. */
.meiliwoo-drawer .product-small .button,
.meiliwoo-drawer .product-small .add_to_cart_button,
.meiliwoo-drawer .product-small .add-to-cart-grid,
.meiliwoo-drawer .product-small .star-rating,
.meiliwoo-drawer .product-small .category {
	display: none !important;
}

/* ------------------------------------------------------------------ *
 * Scroll lock while the drawer is open
 * ------------------------------------------------------------------ */

html.meiliwoo-drawer-open,
body.meiliwoo-drawer-open {
	overflow: hidden;
}
