/* ── HIDE DOKAN'S NATIVE STORE HEADER ──
	 * The compact card below renders the same logo / name / address / rating,
	 * so Dokan's own profile frame would be a duplicate. The filter area is
	 * Dokan's product search + orderby, replaced by our search modal.
	 * If you keep the orderby dropdown useful, delete that third selector. */
	.dokan-single-store .dokan-profile-frame-wrapper,
	.dokan-single-store .dokan-store-tabs,
	.dokan-single-store .dokan-store-products-filter-area { display:none !important; }

	/* ── SELF-MANAGED STICKY (no Elementor, no :has()) ──
	 * A 1px sentinel sits above the bar. When it leaves the top of the
	 * viewport an IntersectionObserver adds .bammat-bar-stuck to <body>. */
	/* Reclaim theme spacing above the bar. Dokan's own header is hidden,
	 * so the theme's 40px + 20px offsets have nothing left to clear.
	 * This <style> only prints on store pages, so it is already scoped. */
	main.content-layout-wrapper { padding-top:10px !important; }
	.dokan-store-wrap { margin-top:0 !important; }

	.bammat-store-bar-root { position:relative; margin:0; }
	/* Absolutely positioned so its offset does not push the grid down.
	 * JS sets `bottom` to (bar height + gap): the bar has to take over that
	 * many pixels BEFORE the card ends, or there is no room to place the
	 * first product row underneath it. */
	.bammat-sticky-sentinel {
		position:absolute; left:0; bottom:0;
		width:1px; height:1px; margin:0; padding:0;
	}

	.unified-sticky-container {
		display:none; background:white; border:1px solid #e9ecef;
		border-radius:12px; box-shadow:0 4px 16px rgba(0,0,0,0.12);
		margin:0 0 10px 0; overflow:visible; box-sizing:border-box;
	}
	body.bammat-bar-stuck .unified-sticky-container {
		display:block;
		position:fixed;          /* left / width / top are set by JS */
		z-index:100;
	}

	/* Hide the full card once the bar is stuck, or both are on screen at
	 * once. visibility (not display) keeps its space reserved, so the page
	 * does not jump by the card's height at the moment it sticks. */
	body.bammat-bar-stuck .compact-store-info-wrapper { visibility:hidden !important; }

	/* Opaque strip behind the bar so page content doesn't show through
	 * the gap between the site header and the bar. */
	body.bammat-bar-stuck .bammat-sticky-backdrop {
		display:block; position:fixed; left:0; right:0; top:0;
		background:#f9f9f9; z-index:99; pointer-events:none;
	}
	.bammat-sticky-backdrop { display:none; }

	/* ── STORE HEADER ── */
	.unified-store-header { display:flex; align-items:center; padding:12px 20px; gap:12px; background:#fafbfc; border-radius:12px 12px 0 0; }
	.unified-logo { width:40px; height:40px; border-radius:8px; overflow:hidden; flex-shrink:0; box-shadow:0 2px 4px rgba(0,0,0,0.1); background:#f8f9fa; }
	.unified-logo img { width:100%; height:100%; object-fit:cover; }
	.unified-logo .placeholder { width:100%; height:100%; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#667eea,#764ba2); color:white; font-weight:700; font-size:16px; }
	.unified-status-dot { width:12px; height:12px; border-radius:50%; flex-shrink:0; box-shadow:0 0 0 2px white; }
	.unified-status-dot.open  { background:#28a745; animation:pulse-green 2s ease-in-out infinite; }
	.unified-status-dot.closed{ background:#dc3545; animation:pulse-red  2s ease-in-out infinite; }
	/* Магазин ещё открыт, но приём заказов вот-вот закроется — не красный,
	   красный означает «закрыто». */
	.unified-status-dot.warn  { background:#f59e0b; animation:pulse-red  2s ease-in-out infinite; }
	@keyframes pulse-green { 0%,100%{box-shadow:0 0 0 2px white,0 0 0 4px rgba(40,167,69,.3)} 50%{box-shadow:0 0 0 2px white,0 0 0 4px rgba(40,167,69,0)} }
	@keyframes pulse-red   { 0%,100%{box-shadow:0 0 0 2px white,0 0 0 4px rgba(220,53,69,.3)}  50%{box-shadow:0 0 0 2px white,0 0 0 4px rgba(220,53,69,0)} }
	.unified-store-name { font-size:16px; font-weight:700; color:#1a1a1a; flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }

	/* ── SEARCH ICON BUTTON ── */
	.unified-search-icon-btn {
		background:white !important; border:1px solid #e0e0e0 !important;
		width:36px !important; height:36px !important; min-width:36px !important; min-height:36px !important;
		max-width:36px !important; max-height:36px !important;
		border-radius:50% !important; display:flex !important; align-items:center !important;
		justify-content:center !important; cursor:pointer !important; flex-shrink:0 !important;
		transition:all .2s !important; padding:0 !important;
	}
	.unified-search-icon-btn:hover { background:#f5f5f5 !important; border-color:#d0d0d0 !important; }
	.unified-search-icon-btn:active { transform:scale(0.95) !important; }
	.unified-search-icon-btn svg { width:18px !important; height:18px !important; fill:#555 !important; }

	.unified-delivery-time { font-size:13px; font-weight:600; color:var(--bm-blue); background:#e3f2fd; border:1px solid #81d4fa; padding:6px 12px; border-radius:20px; white-space:nowrap; flex-shrink:0; }
	.unified-delivery-time.closed { background:#fff3e0; color:#ef6c00; border-color:#ffcc02; }

	/* ── SEARCH MODAL ── */
	.unified-search-modal-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,.5); z-index:10000; display:none; padding:20px; box-sizing:border-box; }
	.unified-search-modal-overlay.active { display:block; }
	.unified-search-modal {
		background:white; border-radius:16px; width:calc(100% - 40px); max-width:600px;
		max-height:90vh; overflow:hidden; box-shadow:0 20px 60px rgba(0,0,0,.3);
		position:fixed; left:50%; transform:translateX(-50%) translateY(-50%);
		will-change:top; opacity:0; transition:opacity .15s ease; animation:none;
	}
	.unified-search-modal-header { display:flex; align-items:center; justify-content:space-between; padding:24px 24px 16px; border-bottom:1px solid #f0f0f0; }
	.unified-search-modal-title  { font-size:20px; font-weight:700; color:#333; margin:0; }
	.unified-search-modal-close  { background:white; border:1px solid #e0e0e0; font-size:24px; color:#666; cursor:pointer; width:40px; height:40px; display:flex; align-items:center; justify-content:center; border-radius:50%; transition:all .2s; padding:0; }
	.unified-search-modal-close:hover { background:#f5f5f5; }
	.unified-search-modal-content { padding:24px; }
	.unified-search-modal-input { width:100%; padding:16px 20px; border:2px solid var(--bm-blue); border-radius:12px; font-size:18px; outline:none; box-sizing:border-box; }
	.unified-search-modal-btn   { width:100%; padding:16px 20px; background:var(--bm-blue); color:white; border:none; border-radius:12px; font-size:18px; font-weight:600; cursor:pointer; margin-top:16px; transition:background .2s; }
	.unified-search-modal-btn:hover { background:var(--bm-blue-dark); }

	/* ── NAVIGATION SECTION ── */
	.unified-navigation-section { padding:10px 16px; background:white; border-radius:0 0 12px 12px; }

	/* ── CATEGORIES CAROUSEL ── */
	.unified-categories-carousel { display:flex; gap:6px; overflow-x:auto; scroll-behavior:smooth; scrollbar-width:none; -ms-overflow-style:none; -webkit-overflow-scrolling:touch; cursor:grab; user-select:none; margin-bottom:6px; }
	.unified-categories-carousel:active { cursor:grabbing; }
	.unified-categories-carousel::-webkit-scrollbar { display:none; }
	.unified-category-item { flex:0 0 auto; min-width:80px; max-width:80px; }
	.unified-category-link { display:block; text-decoration:none; color:inherit; }
	.unified-category-content { background:#f8f9fa; border:2px solid transparent; border-radius:10px; padding:8px 4px; text-align:center; height:85px; display:flex; flex-direction:column; justify-content:center; align-items:center; transition:all .2s; }
	.unified-category-item:hover .unified-category-content { background:#e9ecef; }
	/* All active states are blue. The carousel tile is always outline-blue
	 * when it (or a descendant) is selected — active / parent-active /
	 * grandparent-active all look identical. */
	.unified-category-item.active .unified-category-content,
	.unified-category-item.parent-active .unified-category-content,
	.unified-category-item.grandparent-active .unified-category-content { border-color:var(--bm-blue); background:#f0f7ff; }
	.unified-category-icon { font-size:24px; margin-bottom:4px; line-height:1; }
	.unified-category-name { font-size:10px; font-weight:500; color:#333; line-height:1.2; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
	.unified-category-item.active .unified-category-name,
	.unified-category-item.parent-active .unified-category-name,
	.unified-category-item.grandparent-active .unified-category-name { color:var(--bm-blue); font-weight:700; }

	/* ── SUBCATEGORY TAGS ── */
	.unified-subcategory-container, .unified-subsubcategory-container { margin-bottom:5px; }
	.unified-subcategory-tags, .unified-subsubcategory-tags {
		display:flex; flex-wrap:nowrap; gap:6px; overflow-x:auto; overflow-y:hidden;
		scrollbar-width:none; -ms-overflow-style:none; -webkit-overflow-scrolling:touch;
		height:32px; align-items:center; cursor:grab;
	}
	.unified-subcategory-tags::-webkit-scrollbar, .unified-subsubcategory-tags::-webkit-scrollbar { display:none; }
	.unified-subcategory-tag, .unified-subsubcategory-tag {
		background:#f8f9fa; color:#666; padding:5px 10px; border-radius:15px;
		font-size:11px; font-weight:500; text-decoration:none; border:1px solid #e9ecef;
		cursor:pointer; display:inline-flex; align-items:center; justify-content:center;
		white-space:nowrap; height:26px; line-height:16px; transition:all .2s;
	}
	.unified-subcategory-tag:hover, .unified-subsubcategory-tag:hover { background:#e9ecef; color:#333; }
	/* Selected subcategory: blue fill, white text.
	 * When a sub-subcategory is active, its parent subcategory should
	 * revert to an outline (blue border, blue text) — the filled style
	 * belongs to the deepest selected level only. */
	.unified-subcategory-tag.active    { background:var(--bm-blue) !important; color:#fff !important; border:2px solid var(--bm-blue) !important; }
	.unified-subsubcategory-tag.active { background:var(--bm-blue) !important; color:#fff !important; border:2px solid var(--bm-blue) !important; font-weight:600; }

	body.bammat-has-subsub .unified-subcategory-tag.active {
		background:#f8f9fa !important; color:var(--bm-blue) !important; border:2px solid var(--bm-blue) !important;
	}

	/* ── PAGINATION ── */
	.dokan-pagination-container { margin:20px 0 !important; padding:0 !important; }
	/* Dokan renders an empty <ul class="pager"> above the pagination;
	 * Woodmart gives it negative margins, which pulls the pagination up
	 * into the last grid row on narrow screens. */
	#nav-below .pager:empty { display:none !important; margin:0 !important; }
	#nav-below { margin:0 !important; padding:0 !important; clear:both !important; }
	.seller-items { margin-bottom:0 !important; }

	@media (max-width:768px) {
		.dokan-pagination-container { margin:18px 0 24px !important; }
	}
	.dokan-pagination { display:flex !important; flex-wrap:wrap !important; gap:6px !important; padding:0 !important; margin:0 !important; list-style:none !important; justify-content:center !important; align-items:center !important; }
	.dokan-pagination li { list-style:none !important; margin:0 !important; padding:0 !important; }
	.dokan-pagination li a { background:#f8f9fa !important; color:#666 !important; padding:6px 12px !important; border-radius:15px !important; font-size:12px !important; font-weight:500 !important; text-decoration:none !important; border:1px solid #e9ecef !important; display:inline-flex !important; align-items:center !important; justify-content:center !important; min-height:28px !important; box-sizing:border-box !important; transition:all .2s !important; }
	.dokan-pagination li a:hover { background:#e9ecef !important; color:#333 !important; }
	.dokan-pagination li.active a  { background:var(--bm-blue) !important; color:white !important; border-color:var(--bm-blue) !important; }
	.dokan-pagination li.disabled a{ background:#f8f9fa !important; color:#ccc !important; cursor:not-allowed !important; opacity:.6 !important; }

	/* ── LOADING SPINNER ── */
	.navigation-loader { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); background:rgba(255,255,255,.95); padding:20px; border-radius:8px; text-align:center; z-index:9999; box-shadow:0 4px 12px rgba(0,0,0,.15); }
	.navigation-loader-text { font-size:14px; color:#666; margin-bottom:10px; }
	.navigation-loader-spinner { width:30px; height:30px; border:3px solid #f3f3f3; border-top:3px solid var(--bm-blue); border-radius:50%; animation:nav-spin 1s linear infinite; margin:0 auto; }
	@keyframes nav-spin { 0%{transform:rotate(0deg)} 100%{transform:rotate(360deg)} }

	/* ── PRODUCT GRID ── */
	.wd-products { display:grid !important; grid-template-columns:repeat(6,1fr) !important; gap:8px !important; margin:0 !important; padding:0 !important; }
	.wd-product  { width:100% !important; margin:0 !important; min-width:0 !important; }

	/* Tall and wide photos both fit inside a square, no cropping. */
	.seller-items .wd-product .wd-product-thumb > a.wd-product-img-link,
	.seller-items .wd-product .wd-product-thumb > a.product-image-link {
		display:block !important; position:relative !important;
		aspect-ratio:1 / 1 !important; overflow:hidden !important;
		background:#fff !important; padding:0 !important;
	}
	.seller-items .wd-product .wd-product-thumb > a > img,
	.seller-items .wd-product .wd-product-thumb img.attachment-woocommerce_thumbnail {
		width:100% !important; height:100% !important; max-height:none !important;
		object-fit:contain !important; object-position:center center !important;
		position:static !important; inset:auto !important;
	}
	@media (max-width:768px) {
		.wd-products { grid-template-columns:repeat(3,1fr) !important; gap:4px !important; }
	}

	/* ── FULL CARD ── */
	.compact-store-info-wrapper { background:#fff; border:1px solid #e9ecef; border-radius:12px; padding:20px; margin:10px 0; box-shadow:0 2px 8px rgba(0,0,0,.08); }
	.compact-store-header { display:flex; gap:16px; align-items:flex-start; margin-bottom:16px; }
	.compact-store-logo { flex-shrink:0; width:80px; height:80px; border-radius:10px; overflow:hidden; border:2px solid #f0f0f0; background:#f8f9fa; }
	.compact-store-logo img { width:100%; height:100%; object-fit:cover; }
	.compact-store-details { flex:1; min-width:0; }
	.compact-store-name-row { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
	.compact-store-name { font-size:22px; font-weight:700; color:#333; margin:0; line-height:1.3; }
	.compact-search-icon-btn { background:white !important; border:1px solid #e0e0e0 !important; width:40px !important; height:40px !important; min-width:40px !important; min-height:40px !important; border-radius:50% !important; display:flex !important; align-items:center !important; justify-content:center !important; cursor:pointer !important; flex-shrink:0 !important; transition:all .2s !important; padding:0 !important; }
	.compact-search-icon-btn:hover { background:#f5f5f5 !important; }
	.compact-search-icon-btn svg  { width:20px !important; height:20px !important; fill:#555 !important; }
	.compact-store-meta { display:flex; flex-direction:column; gap:6px; }
	.compact-store-meta-item { display:flex; align-items:center; gap:8px; font-size:13px; color:#666; line-height:1.4; }
	.compact-store-meta-icon { font-size:14px; color:var(--bm-blue); flex-shrink:0; }
	.compact-store-status { display:inline-flex; align-items:center; gap:4px; font-weight:600; }
	.compact-store-status.open   { color:#28a745; }
	.compact-store-status.closed { color:#dc3545; }
	.compact-store-status.warn   { color:#b45309; }
	.compact-store-status-dot { width:8px; height:8px; border-radius:50%; animation:compact-pulse 2s ease-in-out infinite; }
	.compact-store-status.open   .compact-store-status-dot { background:#28a745; }
	.compact-store-status.closed .compact-store-status-dot { background:#dc3545; }
	.compact-store-status.warn   .compact-store-status-dot { background:#f59e0b; }
	@keyframes compact-pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
	.compact-categories-section { margin-top:16px; padding-top:16px; border-top:1px solid #f0f0f0; }
	.compact-categories-carousel { display:flex; gap:6px; overflow-x:auto; scroll-behavior:smooth; scrollbar-width:none; -ms-overflow-style:none; cursor:grab; padding-bottom:4px; margin-bottom:6px; }
	.compact-categories-carousel::-webkit-scrollbar { display:none; }
	.compact-subcategory-tags, .compact-subsubcategory-tags { display:flex; flex-wrap:nowrap; gap:6px; overflow-x:auto; overflow-y:hidden; scrollbar-width:none; height:32px; align-items:center; cursor:grab; }
	.compact-subcategory-tags::-webkit-scrollbar, .compact-subsubcategory-tags::-webkit-scrollbar { display:none; }
	.compact-delivery-section { background:#f8f9fa; border:1px solid #e9ecef; border-left:4px solid var(--bm-blue); border-radius:8px; padding:12px 14px; margin-top:16px; }
	.compact-delivery-message { font-size:14px; font-weight:600; color:#495057; margin:0; line-height:1.4; }
	.compact-delivery-loading { opacity:.6; animation:compact-delivery-pulse 1.5s ease-in-out infinite; }
	@keyframes compact-delivery-pulse { 0%,100%{opacity:.6} 50%{opacity:1} }

	/* ── MOBILE ── */
	@media (max-width:768px) {
		.compact-store-info-wrapper { padding:16px; }
		.compact-store-header { gap:12px; }
		.compact-store-logo   { width:60px; height:60px; }
		.compact-store-name   { font-size:18px; }
		.compact-search-icon-btn { width:36px !important; height:36px !important; min-width:36px !important; min-height:36px !important; }
		.compact-delivery-message { font-size:11px; }
		.unified-store-header { padding:10px 16px; gap:8px; }
		.unified-logo { width:35px; height:35px; }
		.unified-store-name { font-size:14px; }
		.unified-search-icon-btn { width:32px !important; height:32px !important; min-width:32px !important; min-height:32px !important; }
		.unified-delivery-time { font-size:11px; padding:4px 10px; }
		.unified-navigation-section { padding:8px 12px; }
		.unified-category-item { min-width:70px; max-width:70px; }
		.unified-category-content { height:75px; padding:6px 4px; }
		.unified-category-icon { font-size:20px; }
		.unified-category-name { font-size:9px; }
		.dokan-pagination li a { padding:5px 8px !important; font-size:11px !important; }
		.unified-search-modal-header  { padding:20px 20px 12px; }
		.unified-search-modal-content { padding:20px; }
		.unified-search-modal-input   { font-size:16px; padding:14px 16px; }
		.unified-search-modal-btn     { font-size:16px; padding:14px 16px; }
		.unified-search-modal-title   { font-size:18px; }
	}
