/**
 * Bee1 Search For WooCommerce — front-end styles.
 * Scoped under .bee1-search / .bee1-results to avoid theme collisions.
 *
 * @package Bee1_Search
 */

:root {
	--bee1-accent: #1e73be;
	--bee1-hover: #f7f7f7;
	--bee1-border: #e2e2e2;
	--bee1-text: #2b2b2b;
	--bee1-muted: #767676;
	--bee1-bg: #ffffff;
	--bee1-radius: 6px;
	--bee1-shadow: 0 8px 30px rgba( 0, 0, 0, 0.12 );
}

/* ------------------------------------------------------------------ *
 *  Form
 * ------------------------------------------------------------------ */
.bee1-search {
	position: relative;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	font-size: 15px;
	line-height: 1.4;
}

.bee1-search *,
.bee1-results * {
	box-sizing: border-box;
}

.bee1-search__field {
	position: relative;
	display: flex;
	align-items: stretch;
}

input.bee1-search__input {
	flex: 1 1 auto;
	width: 100%;
	min-height: 44px;
	padding: 8px 44px 8px 14px;
	border: 1px solid var(--bee1-border);
	border-radius: var(--bee1-radius);
	background: var(--bee1-bg);
	color: var(--bee1-text);
	font-size: inherit;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input.bee1-search__input:focus,
input.bee1-search__input:focus-visible {
	border-color: var(--bee1-accent);
	outline: none;
	box-shadow: 0 0 0 3px rgba( 30, 115, 190, 0.15 );
	box-shadow: 0 0 0 3px color-mix( in srgb, var(--bee1-accent) 18%, transparent );
}

.bee1-search__submit {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	width: 44px;
	border: 0;
	background: transparent;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--bee1-muted);
}

.bee1-search__submit:hover .bee1-search__submit-icon,
.bee1-search__submit:focus .bee1-search__submit-icon {
	border-color: var(--bee1-accent);
}

/* Inline-SVG magnifier (1.1.5): immune to third-party width/border overrides. */
svg.bee1-search__submit-icon {
	display: block;
	width: 18px !important;
	height: 18px !important;
	border: 0 !important;
	border-radius: 0 !important;
}
.bee1-search__submit-icon {
	position: relative;
}

.bee1-search__submit-icon::after {
	content: "";
	position: absolute;
	right: -6px;
	bottom: -4px;
	width: 8px;
	height: 2px;
	background: currentColor;
	transform: rotate( 45deg );
}

/* RTL: flip icon/submit to the left. */
[dir="rtl"] input.bee1-search__input {
	padding: 8px 14px 8px 44px;
}

[dir="rtl"] .bee1-search__submit {
	right: auto;
	left: 0;
}

/* RTL: dropdown and details panel mirror. */
[dir="rtl"] .bee1-results {
	left: auto;
	right: 0;
	text-align: right;
}

[dir="rtl"] .bee1-details-panel {
	border-left: 0;
	border-right: 1px solid var(--bee1-border);
}

[dir="rtl"] .bee1-overlay__close {
	right: auto;
	left: 10px;
}

/* ------------------------------------------------------------------ *
 *  Results dropdown
 * ------------------------------------------------------------------ */
.bee1-results {
	position: absolute;
	z-index: 99999;
	top: calc( 100% + 6px );
	left: 0;
	width: 100%;
	max-height: 70vh;
	/* The list and the details panel scroll separately (1.2.2). When the whole box scrolled,
	   a long list dragged the details panel with it and its button ended up at, or past, the
	   bottom edge of the box. */
	overflow: hidden;
	background: var(--bee1-bg);
	border: 1px solid var(--bee1-border);
	border-radius: var(--bee1-radius);
	box-shadow: var(--bee1-shadow);
	display: flex;
}

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

.bee1-results__list {
	flex: 1 1 auto;
	min-width: 0;
	max-height: inherit;
	overflow-y: auto;
}

.bee1-results__heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px 4px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--bee1-muted);
}

.bee1-results__noresults {
	padding: 18px 14px;
	color: var(--bee1-muted);
	text-align: center;
}

.bee1-history__clear {
	border: 0;
	background: none;
	color: var(--bee1-accent);
	cursor: pointer;
	font-size: 11px;
	text-transform: none;
	letter-spacing: 0;
}

/* ------------------------------------------------------------------ *
 *  Suggestion rows
 * ------------------------------------------------------------------ */
.bee1-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 14px;
	text-decoration: none;
	color: var(--bee1-text);
	border-top: 1px solid rgba( 0, 0, 0, 0.04 );
}

.bee1-item:first-child {
	border-top: 0;
}

.bee1-item:hover,
.bee1-item.is-active,
.bee1-results__seeall:hover,
.bee1-results__seeall.is-active {
	background: var(--bee1-hover);
}

.bee1-item__thumb {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border-radius: 4px;
	background: #fafafa;
}

.bee1-item__thumb img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	display: block;
}

.bee1-item__body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.bee1-item__title {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bee1-item--term .bee1-item__title {
	font-weight: 500;
}

.bee1-item__sku,
.bee1-item__desc {
	font-size: 12px;
	color: var(--bee1-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bee1-item__count {
	flex: 0 0 auto;
	font-size: 12px;
	color: var(--bee1-muted);
	background: rgba( 0, 0, 0, 0.05 );
	border-radius: 10px;
	padding: 1px 8px;
}

.bee1-item__price {
	flex: 0 0 auto;
	font-weight: 700;
	color: var(--bee1-text);
	white-space: nowrap;
}

.bee1-item__price del {
	color: var(--bee1-muted);
	font-weight: 400;
	margin-right: 4px;
}

.bee1-results__seeall {
	display: block;
	padding: 11px 14px;
	text-align: center;
	font-weight: 600;
	color: var(--bee1-accent);
	text-decoration: none;
	border-top: 1px solid var(--bee1-border);
	position: sticky;
	bottom: 0;
	background: var(--bee1-bg);
}

/* ------------------------------------------------------------------ *
 *  Details panel
 * ------------------------------------------------------------------ */
.bee1-details-panel {
	flex: 0 0 300px;
	order: 2;
	border-left: 1px solid var(--bee1-border);
	padding: 16px;
	max-height: inherit;
	overflow-y: auto;
}

.bee1-details-panel[hidden] {
	display: none;
}

.bee1-details__media {
	text-align: center;
	margin-bottom: 12px;
}

.bee1-details__media img {
	max-width: 100%;
	/* Portrait product photos (e.g. 364x1024) used to render ~750px tall and push the price and
	   add-to-cart out of the panel; cap the height and keep the proportions. */
	max-height: 260px;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
}

.bee1-details__title {
	display: block;
	font-weight: 700;
	font-size: 16px;
	color: var(--bee1-text);
	text-decoration: none;
	margin-bottom: 6px;
}

.bee1-details__price {
	font-weight: 700;
	margin-bottom: 8px;
}

.bee1-details__desc {
	font-size: 13px;
	color: var(--bee1-muted);
	margin-bottom: 12px;
	/* Keep the add-to-cart inside the panel: the excerpt is a teaser, the product page has the rest. */
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* "Use the product list's add-to-cart": the site's own markup, so only layout here -
   colours, size and shape stay whatever the shop grid uses. */
.bee1-details__cart--loop {
	display: block;
	width: 100%;
}

.bee1-details__cart--loop > * {
	max-width: 100%;
}

.bee1-details__cart {
	display: flex;
	gap: 8px;
	align-items: center;
}

.bee1-details__qty {
	width: 60px;
	min-height: 38px;
	padding: 6px 8px;
	border: 1px solid var(--bee1-border);
	border-radius: 4px;
}

.bee1-details__add,
.bee1-details__select {
	flex: 1 1 auto;
	min-height: 38px;
	border: 0;
	border-radius: 4px;
	background: var(--bee1-accent);
	color: #fff;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 6px 12px;
}

.bee1-details__add.loading {
	opacity: 0.7;
	cursor: default;
}

.bee1-details__add.added {
	background: #46b450;
}

/* ------------------------------------------------------------------ *
 *  Preloader
 * ------------------------------------------------------------------ */
.bee1-is-loading .bee1-search__submit-icon {
	animation: bee1-spin 0.7s linear infinite;
	border-right-color: transparent;
}

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

/* ------------------------------------------------------------------ *
 *  Mobile overlay
 * ------------------------------------------------------------------ */
html.bee1-overlay-open {
	overflow: hidden;
}

.bee1-search.bee1-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: var(--bee1-bg);
	padding: 14px;
	max-width: none;
}

.bee1-search.bee1-overlay .bee1-results {
	position: static;
	box-shadow: none;
	border: 0;
	margin-top: 12px;
	max-height: calc( 100vh - 80px );
}

/* Stack the details panel below the list inside the mobile overlay. */
.bee1-search.bee1-overlay .bee1-results {
	flex-direction: column;
	width: 100% !important;
	max-width: 100% !important;
	overflow-y: auto;
}

/* `order: 2` keeps the panel BELOW the list (1.2.2). It was `order: 0`, which left it in
   DOM order - above the list - so on a phone a large product card covered the results. */
.bee1-search.bee1-overlay .bee1-details-panel {
	flex-basis: auto;
	order: 2;
	border-left: 0;
	border-top: 1px solid var(--bee1-border);
}

/* Stacked, the box scrolls as one again: the list and panel no longer scroll separately. */
.bee1-search.bee1-overlay .bee1-results__list,
.bee1-search.bee1-overlay .bee1-details-panel {
	max-height: none;
	overflow: visible;
}

/* Stack the details panel below the list and force full-width on mobile screens. */
@media ( max-width: 768px ) {
	.bee1-results {
		flex-direction: column;
		width: 100% !important;
		max-width: 100% !important;
		overflow-y: auto;
	}

	.bee1-details-panel {
		flex-basis: auto;
		order: 2;
		border-left: 0;
		border-top: 1px solid var(--bee1-border);
	}

	.bee1-results__list,
	.bee1-details-panel {
		max-height: none;
		overflow: visible;
	}

	[dir="rtl"] .bee1-details-panel {
		border-right: 0;
	}
}

.bee1-overlay__close {
	position: absolute;
	top: 8px;
	right: 10px;
	width: 40px;
	height: 40px;
	border: 0;
	background: none;
	font-size: 30px;
	line-height: 1;
	color: var(--bee1-muted);
	cursor: pointer;
}

.bee1-overlay__close[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ *
 *  Dark scheme (only if the theme opts in via prefers-color-scheme)
 * ------------------------------------------------------------------ */
@media ( prefers-color-scheme: dark ) {
	.bee1-search--dark {
		--bee1-bg: #1e1e1e;
		--bee1-text: #f0f0f0;
		--bee1-muted: #a5a5a5;
		--bee1-border: #3a3a3a;
		--bee1-hover: #2a2a2a;
	}
}

/* Accessibility helper (matches WP core). */
.bee1-search .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* Theme resets (Hello: `input[type=search]`, `input:focus-visible`) are (0,1,1); `input.bee1-search__input` ties them and the
   plugin sheet prints later, so the bar keeps its own padding, border, radius and focus ring (1.2.4). */
/* ===== XPASS: enlarge search dropdown fonts for readability (claude) ===== */
.bee1-results__heading { font-size: 14px !important; }
.bee1-item__title { font-size: 17px !important; }
.bee1-item__price { font-size: 16px !important; }
.bee1-item__sku, .bee1-item__count { font-size: 14px !important; }
.bee1-details__title { font-size: 20px !important; line-height: 1.35 !important; }
.bee1-details__price { font-size: 18px !important; }
.bee1-details__desc { font-size: 15px !important; line-height: 1.6 !important; }
.bee1-search__input { font-size: 16px !important; }
.bee1-item__meta, .bee1-results a, .bee1-panel a { font-size: 15px !important; }

/* ------------------------------------------------------------------ *
 *  Icon layout
 *
 *  Opt-in via the `layout="icon"` argument (Elementor widget or the
 *  shortcode). The bar collapses behind a magnifier button and opens in a
 *  floating panel, for headers that only have room for an icon.
 * ------------------------------------------------------------------ */
.bee1-search--icon {
	display: inline-flex;
	width: auto;
	align-items: center;
}

.bee1-search__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var( --bee1-icon-size, 40px );
	height: var( --bee1-icon-size, 40px );
	padding: 0;
	background: none;
	border: 0;
	border-radius: 50%;
	color: inherit;
	cursor: pointer;
	line-height: 0;
}

.bee1-search__toggle:hover,
.bee1-search__toggle:focus {
	background: var( --bee1-hover );
}

.bee1-search__toggle-icon {
	width: var( --bee1-icon-glyph, 20px );
	height: var( --bee1-icon-glyph, 20px );
	display: block;
}

/*
 * The panel is the positioning context for the results dropdown, which the
 * script hosts inside it so the two stay aligned under the field.
 */
.bee1-search--icon .bee1-search__panel {
	position: absolute;
	top: calc( 100% + 10px );
	inset-inline-end: 0;
	z-index: 999;
	width: var( --bee1-panel-width, 340px );
	max-width: calc( 100vw - 32px );
	padding: 10px;
	background: var( --bee1-bg );
	border: 1px solid var( --bee1-border );
	border-radius: var( --bee1-radius );
	box-shadow: var( --bee1-shadow );
}

.bee1-search--icon .bee1-search__panel[hidden] {
	display: none;
}

/* Dropdown hangs directly beneath the field inside the panel. */
.bee1-search--icon .bee1-search__panel .bee1-results {
	top: calc( 100% + 8px );
	inset-inline-start: 0;
	inset-inline-end: 0;
}

/*
 * The mobile overlay takes over the whole viewport, so the panel must not
 * keep its floating-box treatment while that is active.
 */
.bee1-search--icon.bee1-overlay .bee1-search__panel {
	position: static;
	width: 100%;
	max-width: none;
	padding: 0;
	background: none;
	border: 0;
	box-shadow: none;
}

.bee1-search--icon.bee1-overlay .bee1-search__toggle {
	display: none;
}

.bee1-search.bee1-overlay .bee1-details-panel {
	border-right: 0;
}

/* ------------------------------------------------------------------ *
 *  Theme-proofing (1.2.2)
 *
 *  Themes and page builders style every bare `a`, `button` and `a.button`
 *  on the page (e.g. `a.button { background: #060606 }` together with
 *  `.elementor-kit-N a { color: pink }`). Those beat the single-class rules
 *  above, so the search's own controls came out black-on-pink, pink squares
 *  with theme padding, or links in the theme's link colour. These rules win
 *  on specificity alone - no !important - and only restate what the plugin
 *  already means: text in --bee1-text, actions in --bee1-accent. Shape
 *  (border-radius, font) is left to the site.
 * ------------------------------------------------------------------ */
.bee1-search .bee1-search__field button.bee1-search__submit,
.bee1-search .bee1-search__field button.bee1-search__submit:hover,
.bee1-search .bee1-search__field button.bee1-search__submit:focus {
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: var(--bee1-muted);
}

.bee1-search .bee1-search__field button.bee1-search__submit:hover,
.bee1-search .bee1-search__field button.bee1-search__submit:focus {
	color: var(--bee1-accent);
}

.bee1-search button.bee1-search__toggle,
.bee1-search button.bee1-overlay__close,
.bee1-results button.bee1-history__clear {
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
}

.bee1-search button.bee1-search__toggle {
	color: inherit;
}

.bee1-search button.bee1-search__toggle:hover,
.bee1-search button.bee1-search__toggle:focus {
	background: var(--bee1-hover);
}

.bee1-search button.bee1-overlay__close {
	color: var(--bee1-muted);
}

.bee1-results button.bee1-history__clear {
	color: var(--bee1-accent);
}

.bee1-results a.bee1-item,
.bee1-results a.bee1-item:hover,
.bee1-results a.bee1-details__title,
.bee1-results a.bee1-details__title:hover {
	color: var(--bee1-text);
}

.bee1-results a.bee1-results__seeall,
.bee1-results a.bee1-results__seeall:hover {
	color: var(--bee1-accent);
}

.bee1-results .bee1-details-panel a.bee1-details__select,
.bee1-results .bee1-details-panel button.bee1-details__add {
	width: 100%;
	border: 0;
	background: var(--bee1-accent);
	color: #fff;
	box-shadow: none;
	transition: filter 0.15s ease;
}

.bee1-results .bee1-details-panel a.bee1-details__select:hover,
.bee1-results .bee1-details-panel a.bee1-details__select:focus,
.bee1-results .bee1-details-panel button.bee1-details__add:hover,
.bee1-results .bee1-details-panel button.bee1-details__add:focus {
	background: var(--bee1-accent);
	color: #fff;
	filter: brightness( 0.92 );
}

.bee1-results .bee1-details-panel button.bee1-details__add.added {
	background: #46b450;
}

/* The browser's own clear (x) on type="search" is painted blue by Chrome; match the muted magnifier. */
.bee1-search .bee1-search__input::-webkit-search-cancel-button {
	filter: grayscale( 1 );
	opacity: 0.55;
	cursor: pointer;
}
