/* ============================================================
   Super Great Search Bar By Tyler Pham — v3.33
   Desktop:       #bgs-wrapper  / #bgs-dropdown  (≥ 850px)
   Mobile+Tablet: #bgsm-wrapper / #bgsm-overlay  (≤ 849px)
   ============================================================ */

/* ── Flatsome show-for-medium column fix ────────────────────────
   Forces the Flatsome header column visible when our plugin
   shortcode is inside it. :has() only fires when element exists.
   ─────────────────────────────────────────────────────────────── */
.header-main .flex-col.show-for-medium:has(#bgs-wrapper),
.header-main .flex-col.show-for-medium.flex-left:has(#bgs-wrapper) {
    display: flex !important;
    visibility: visible !important;
    overflow: visible !important;
}
.header-main .flex-col.show-for-medium:has(#bgsm-wrapper),
.header-main .flex-col.show-for-medium.flex-left:has(#bgsm-wrapper) {
    display: flex !important;
    visibility: visible !important;
    overflow: visible !important;
}
.header-main .mobile-nav:has(#bgs-wrapper),
.header-main li:has(#bgs-wrapper),
.header-main .mobile-nav:has(#bgsm-wrapper),
.header-main li:has(#bgsm-wrapper) {
    display: flex !important;
    visibility: visible !important;
    overflow: visible !important;
    width: 100% !important;
}

/* ── Shared reset ───────────────────────────────────────────────── */
#bgs-wrapper *, #bgs-wrapper *::before, #bgs-wrapper *::after,
#bgs-dropdown *, #bgs-dropdown *::before, #bgs-dropdown *::after,
#bgsm-wrapper *, #bgsm-wrapper *::before, #bgsm-wrapper *::after,
#bgsm-overlay *, #bgsm-overlay *::before, #bgsm-overlay *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#bgs-wrapper input, #bgs-dropdown input,
#bgsm-wrapper input, #bgsm-overlay input {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
}

/* ════════════════════════════════════════════════════════════════
   DESKTOP — [boogor_search] — visible ≥ 850px
   ════════════════════════════════════════════════════════════════ */

#bgs-wrapper {
    position: relative;
    width: 100%;
    max-width: 680px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    z-index: 9999;
}

/* Hide desktop on tablet/mobile */
@media (max-width: 849px) {
    #bgs-wrapper { display: none !important; }
}

#bgs-bar {
    display: flex;
    align-items: center;
    background: #f2f2f2;
    border-radius: 50px;
    padding: 0 16px;
    height: 44px;
    gap: 10px;
    cursor: text;
    transition: background 0.2s, box-shadow 0.2s;
    width: 100%;
}
#bgs-wrapper.bgs-open #bgs-bar {
    background: #fff;
    box-shadow: 0 0 0 2px #222;
}
#bgs-icon { color: #888; flex-shrink: 0; display: flex; align-items: center; }

#bgs-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    font-size: 14px;
    color: #111;
    outline: none !important;
    box-shadow: none !important;
    min-width: 0;
    font-family: inherit;
}
#bgs-input::placeholder { color: #aaa; }

#bgs-clear {
    background: none; border: none; padding: 4px; cursor: pointer;
    color: #888; display: flex; align-items: center; border-radius: 50%;
    transition: color 0.15s; flex-shrink: 0;
}
#bgs-clear:hover { color: #111; }

#bgs-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: transparent;
    z-index: 9000;
}
#bgs-wrapper.bgs-open #bgs-backdrop { display: block; }

#bgs-dropdown {
    display: none;
    position: fixed;
    top: 70px;
    left: 50vw;
    transform: translateX(-50%);
    width: 720px;
    max-width: 96vw;
    max-height: 80vh;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    padding: 24px;
    z-index: 9100;
    overflow-y: auto;
    animation: bgs-slide-down 0.22s cubic-bezier(.22,.68,0,1.2);
}
#bgs-dropdown::-webkit-scrollbar { width: 6px; }
#bgs-dropdown::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
#bgs-wrapper.bgs-open #bgs-dropdown { display: block; }

#bgs-body { width: 100%; }

.bgs-section { margin-bottom: 22px; }
.bgs-section:last-child { margin-bottom: 0; }
.bgs-label { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: #999; text-transform: uppercase; margin-bottom: 11px; }

#bgs-rv-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
#bgs-rv-row::-webkit-scrollbar { display: none; }
.bgs-rv-item { flex-shrink: 0; width: 72px; text-decoration: none; display: flex; flex-direction: column; align-items: center; transition: transform 0.15s; }
.bgs-rv-item:hover { transform: translateY(-2px); }
.bgs-rv-item img { width: 72px; height: 52px; object-fit: contain; background: #fff; border: 1px solid #f0f0f0; border-radius: 10px; padding: 4px; }

.bgs-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bgs-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #f2f2f2; border: 1px solid #e8e8e8; border-radius: 20px;
    padding: 5px 14px !important; font-size: 12.5px; color: #222;
    cursor: pointer; white-space: nowrap; font-weight: 500; font-family: inherit;
    transition: background 0.15s; line-height: 1.4; -webkit-tap-highlight-color: transparent;
}
.bgs-chip:hover, .bgs-chip:active { background: #e8e8e8; }
.bgs-chip-searched { background: #fff; border-color: #ddd; }
.bgs-chip-remove { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #ccc; color: #fff; font-size: 10px; cursor: pointer; line-height: 1; flex-shrink: 0; }
.bgs-chip-remove:hover { background: #999; }

.bgs-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.bgs-grid.bgs-loading { display: flex; align-items: center; justify-content: center; min-height: 110px; }
.bgs-grid-item { text-decoration: none; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #f0f0f0; border-radius: 10px; aspect-ratio: 1; overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; -webkit-tap-highlight-color: transparent; }
.bgs-grid-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.09); }
.bgs-grid-item img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }

.bgs-list { display: flex; flex-direction: column; gap: 3px; }
.bgs-list-item { display: flex; align-items: center; gap: 13px; padding: 8px 10px; border-radius: 12px; text-decoration: none; color: inherit; transition: background 0.13s; -webkit-tap-highlight-color: transparent; }
.bgs-list-item:hover, .bgs-list-item:active { background: #f5f5f5; }
.bgs-list-item img { width: 64px; height: 48px; object-fit: contain; background: #fff; border: 1px solid #f0f0f0; border-radius: 8px; padding: 3px; flex-shrink: 0; }
.bgs-list-info { flex: 1; min-width: 0; }
.bgs-list-brand { font-size: 10.5px; color: #999; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.bgs-list-name  { font-size: 13px; color: #111; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 1px; }
.bgs-list-sku   { font-size: 11px; color: #bbb; }
.bgs-list-price { font-size: 13px; font-weight: 600; color: #111; flex-shrink: 0; text-align: right; }
.bgs-list-price del { display: block; font-size: 10.5px; font-weight: 400; color: #bbb; }

#bgs-view-all-wrap { text-align: center; padding: 14px 0 2px; }
#bgs-view-all { display: inline-block; background: #111; color: #fff; border-radius: 30px; padding: 10px 28px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-decoration: none; transition: background 0.15s; }
#bgs-view-all:hover { background: #333; }

.bgs-spinner { width: 26px; height: 26px; border: 3px solid #eee; border-top-color: #111; border-radius: 50%; animation: bgs-spin 0.7s linear infinite; }
.bgs-no-results { text-align: center; padding: 24px 0; color: #bbb; font-size: 14px; }
.bgs-no-results strong { display: block; font-size: 15px; color: #555; margin-bottom: 4px; }

@keyframes bgs-slide-down { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes bgs-spin { to { transform: rotate(360deg); } }

@media (min-width: 850px) and (max-width: 1100px) {
    #bgs-dropdown { width: 580px; }
    .bgs-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ════════════════════════════════════════════════════════════════
   MOBILE + TABLET — [boogor_search_mobile] — visible ≤ 849px
   ════════════════════════════════════════════════════════════════ */

/* Hide mobile on desktop */
@media (min-width: 850px) {
    #bgsm-wrapper { display: none !important; }
    #bgsm-overlay { display: none !important; }
}

#bgsm-wrapper {
    display: block;
    width: 100%;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    position: relative;
    z-index: 1;
    min-width: 160px;
}

#bgsm-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 30px;
    padding: 0 14px;
    height: 38px;
    cursor: pointer;
    width: 100%;
    min-width: 160px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
    flex-shrink: 0;
}
#bgsm-bar:active { background: rgba(255,255,255,0.25); }
#bgsm-bar-icon { color: rgba(255,255,255,0.85); display: flex; align-items: center; flex-shrink: 0; }
#bgsm-bar-placeholder { font-size: 13px; color: rgba(255,255,255,0.75); font-weight: 400; flex: 1; white-space: nowrap; overflow: visible; }

#bgsm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 9999999;
    flex-direction: column;
    overflow: hidden;
}
#bgsm-overlay.bgsm-visible {
    display: flex;
    animation: bgsm-slide-up 0.22s cubic-bezier(.22,.68,0,1.1);
}

#bgsm-top-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}
#bgsm-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f2f2f2;
    border-radius: 30px;
    padding: 0 12px;
    height: 40px;
    gap: 8px;
    min-width: 0;
}
.bgsm-input-icon { color: #888; display: flex; align-items: center; flex-shrink: 0; }
#bgsm-input {
    flex: 1; border: none !important; background: transparent !important;
    font-size: 14.5px; color: #111; outline: none !important;
    box-shadow: none !important; min-width: 0; font-family: inherit; -webkit-appearance: none;
}
#bgsm-input::placeholder { color: #aaa; }
#bgsm-input-clear { background: none; border: none; padding: 3px; cursor: pointer; color: #aaa; display: flex; align-items: center; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
#bgsm-cancel { background: none; border: none; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: #444; cursor: pointer; padding: 8px 2px; white-space: nowrap; flex-shrink: 0; -webkit-tap-highlight-color: transparent; font-family: inherit; }

#bgsm-content { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 16px 16px 48px; }
#bgsm-content::-webkit-scrollbar { display: none; }

.bgsm-section { margin-bottom: 22px; }
.bgsm-section:last-child { margin-bottom: 0; }
.bgsm-section-label { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: #999; text-transform: uppercase; margin-bottom: 11px; }

#bgsm-rv-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#bgsm-rv-row::-webkit-scrollbar { display: none; }
.bgsm-rv-item { flex-shrink: 0; width: 68px; text-decoration: none; display: flex; flex-direction: column; align-items: center; }
.bgsm-rv-item img { width: 68px; height: 52px; object-fit: contain; background: #fff; border-radius: 10px; border: 1px solid #f0f0f0; padding: 4px; }

.bgsm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bgsm-chip { display: inline-flex; align-items: center; gap: 6px; background: #f2f2f2; border: 1px solid #e8e8e8; border-radius: 20px; padding: 6px 14px; font-size: 13px; color: #222; cursor: pointer; white-space: nowrap; font-weight: 500; font-family: inherit; -webkit-tap-highlight-color: transparent; transition: background 0.12s; line-height: 1.3; }
.bgsm-chip:active { background: #e0e0e0; }
.bgsm-chip-searched { background: #fff; border-color: #ddd; }
.bgsm-chip-remove { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #ccc; color: #fff; font-size: 11px; cursor: pointer; line-height: 1; flex-shrink: 0; }

.bgsm-popular-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bgsm-popular-grid.bgsm-loading { display: flex; align-items: center; justify-content: center; min-height: 110px; }
.bgsm-grid-item { text-decoration: none; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #f0f0f0; border-radius: 10px; aspect-ratio: 1; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.bgsm-grid-item:active { opacity: 0.75; }
.bgsm-grid-item img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }

.bgsm-list { display: flex; flex-direction: column; gap: 2px; }
.bgsm-list-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: inherit; -webkit-tap-highlight-color: transparent; transition: background 0.12s; }
.bgsm-list-item:active { background: #f5f5f5; }
.bgsm-list-item img { width: 58px; height: 44px; object-fit: contain; background: #fff; border: 1px solid #f0f0f0; border-radius: 8px; padding: 3px; flex-shrink: 0; }
.bgsm-list-info { flex: 1; min-width: 0; }
.bgsm-list-brand { font-size: 10.5px; color: #999; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.bgsm-list-name  { font-size: 13px; color: #111; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 1px; }
.bgsm-list-sku   { font-size: 11px; color: #bbb; }
.bgsm-list-price { font-size: 13px; font-weight: 600; color: #111; flex-shrink: 0; text-align: right; }
.bgsm-list-price del { display: block; font-size: 10.5px; font-weight: 400; color: #bbb; }

#bgsm-view-all-wrap { text-align: center; padding: 16px 0 4px; }
#bgsm-view-all { display: inline-block; background: #111; color: #fff; border-radius: 30px; padding: 11px 32px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-decoration: none; -webkit-tap-highlight-color: transparent; }
#bgsm-view-all:active { background: #333; }

.bgsm-spinner { width: 26px; height: 26px; border: 3px solid #eee; border-top-color: #111; border-radius: 50%; animation: bgsm-spin 0.7s linear infinite; }
.bgsm-no-results { text-align: center; padding: 28px 0; color: #bbb; font-size: 14px; }
.bgsm-no-results strong { display: block; font-size: 15px; color: #666; margin-bottom: 4px; }

@keyframes bgsm-slide-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bgsm-spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
    .bgsm-popular-grid { grid-template-columns: repeat(3, 1fr); }
}
