/* =============================================
   GET STARTED BUY BOX — Stylesheet v3.2
   Custom product dropdown with rich items
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --gsbb-radius:      10px;
    --gsbb-shadow:      0 2px 20px rgba(0,0,0,.10);
    --gsbb-border:      #e2e5ea;
    --gsbb-bg:          #ffffff;
    --gsbb-bg2:         #f7f8fa;
    --gsbb-text:        #1c2434;
    --gsbb-muted:       #6b7280;
    --gsbb-label:       #6b7280;
    --gsbb-input-h:     46px;
    --gsbb-highlight:   #f3f4f6;
    --gsbb-transition:  .15s ease;
}

/* =============================================
   WRAPPER
   ============================================= */
.gsbb-wrapper {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--gsbb-bg);
    border-radius: var(--gsbb-radius);
    box-shadow: var(--gsbb-shadow);
    border: 1px solid var(--gsbb-border);
    overflow: visible; /* required for dropdown to escape */
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* =============================================
   OPTIONAL TITLE / SUBTITLE AREA
   ============================================= */
.gsbb-heading {
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--gsbb-border);
    background: var(--gsbb-bg);
    border-radius: var(--gsbb-radius) var(--gsbb-radius) 0 0;
}
.gsbb-heading-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--gsbb-text);
    margin: 0 0 2px;
    line-height: 1.3;
}
.gsbb-heading-sub {
    font-size: .8rem;
    color: var(--gsbb-muted);
    margin: 0;
}

/* =============================================
   MAIN BAR
   ============================================= */
.gsbb-bar {
    display: flex;
    align-items: flex-end;
    gap: 0;
    padding: 16px 20px 14px;
    flex-wrap: nowrap;
    background: var(--gsbb-bg);
    border-radius: var(--gsbb-radius);
    position: relative;
}

/* =============================================
   FIELD GROUPS
   ============================================= */
.gsbb-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

/* Product field — widest */
.gsbb-field--product {
    flex: 2 1 220px;
}

/* Size field — moderate */
.gsbb-field--size {
    flex: 0 0 180px;
    min-width: 140px;
    max-width: 220px;
    border-left: 1px solid var(--gsbb-border);
    padding-left: 18px;
    margin-left: 18px;
}

/* Quantity field — compact stepper */
.gsbb-field--qty {
    flex: 0 0 150px;
    min-width: 130px;
    max-width: 170px;
    border-left: 1px solid var(--gsbb-border);
    padding-left: 18px;
    margin-left: 18px;
}

.gsbb-qty-stepper {
    display: flex;
    align-items: stretch;
    height: var(--gsbb-input-h);
    border: 1.5px solid var(--gsbb-border);
    border-radius: 7px;
    overflow: hidden;
    background: var(--gsbb-bg);
    transition: border-color var(--gsbb-transition), box-shadow var(--gsbb-transition);
}
.gsbb-qty-stepper:focus-within {
    border-color: var(--gsbb-btn, #22c55e);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gsbb-btn, #22c55e) 15%, transparent);
}

.gsbb-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    border: none;
    background: var(--gsbb-bg2);
    color: var(--gsbb-text);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background var(--gsbb-transition);
    line-height: 1;
    padding: 0;
    font-family: inherit;
}
.gsbb-qty-btn:hover { background: #e5e7eb; }
.gsbb-qty-btn:active { background: #d1d5db; }

.gsbb-qty-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    width: 100%;
    min-width: 0;
    flex: 1;
    height: 100%;
    padding: 0 2px;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    color: var(--gsbb-text);
    background: var(--gsbb-bg);
    border: none;
    border-left: 1px solid var(--gsbb-border);
    border-right: 1px solid var(--gsbb-border);
    text-align: center;
    line-height: var(--gsbb-input-h);
    box-sizing: border-box;
    outline: none;
}
.gsbb-qty-input::-webkit-inner-spin-button,
.gsbb-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.gsbb-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--gsbb-label);
    white-space: nowrap;
    line-height: 1;
}

/* =============================================
   CUSTOM PRODUCT DROPDOWN
   ============================================= */
.gsbb-custom-dropdown {
    position: relative;
}

/* Trigger button */
.gsbb-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--gsbb-input-h);
    padding: 0 10px 0 12px;
    border: 1.5px solid var(--gsbb-border);
    border-radius: 7px;
    cursor: pointer;
    background: var(--gsbb-bg);
    transition: border-color var(--gsbb-transition), box-shadow var(--gsbb-transition);
    gap: 8px;
    user-select: none;
    -webkit-user-select: none;
}
.gsbb-dropdown-trigger:hover {
    border-color: #b0b7c3;
}
.gsbb-dropdown-trigger.is-open {
    border-color: var(--gsbb-btn, #22c55e);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gsbb-btn, #22c55e) 15%, transparent);
}

/* Trigger inner: thumb + name */
.gsbb-dropdown-preview {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.gsbb-dp-thumb {
    width: 34px;
    height: 26px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: #eee;
    display: none; /* shown once product selected */
}
.gsbb-dp-thumb.is-visible { display: block; }
.gsbb-dp-name {
    font-size: .88rem;
    font-weight: 500;
    color: var(--gsbb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gsbb-dp-placeholder {
    font-size: .88rem;
    color: var(--gsbb-muted);
    font-weight: 400;
}
.gsbb-dp-arrow {
    flex-shrink: 0;
    color: var(--gsbb-muted);
    font-size: .65rem;
    transition: transform var(--gsbb-transition);
    line-height: 1;
}
.gsbb-dropdown-trigger.is-open .gsbb-dp-arrow { transform: rotate(180deg); }

/* ---- Dropdown panel ---- */
.gsbb-dropdown-panel {
    /* Base styles — JS overrides position/top/left/width/max-width when
       portaled to <body> using setProperty(..., 'important') so it beats
       every CSS rule including theme !important rules. The values here
       are fallbacks only, used for the brief moment before the first
       repositionPanel() runs. */
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    min-width: 0;
    max-height: 380px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    background: #fff;
    border: 1.5px solid var(--gsbb-border);
    border-radius: 10px;
    box-shadow: 0 10px 36px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
    /* z-index set to max int via JS after portal; keep high here as fallback */
    z-index: 2147483647;
    display: none;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
.gsbb-dropdown-panel::-webkit-scrollbar { width: 5px; }
.gsbb-dropdown-panel::-webkit-scrollbar-track { background: transparent; }
.gsbb-dropdown-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 5px; }

.gsbb-dropdown-panel.is-open {
    display: block;
    animation: gsbb-panel-in .14s ease both;
}
@keyframes gsbb-panel-in {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Search box (sticky to top of panel) ----
   Uses a background-image SVG icon baked into the input itself instead
   of a separate <span>. This eliminates ALL absolute-positioning math —
   the icon is part of the input's background, and padding-left simply
   reserves space for it. Every property is !important to defeat host
   theme rules like Divi's `input[type=text] { padding: 2px; }` which
   would otherwise blow away our padding-left and slam the text against
   the icon. */
.gsbb-dropdown-panel .gsbb-search-wrap {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
    background: #fff !important;
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--gsbb-border) !important;
    margin: 0 !important;
}
.gsbb-dropdown-panel input.gsbb-search-input,
.gsbb-dropdown-panel input.gsbb-search-input[type="text"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    line-height: 38px !important;
    margin: 0 !important;
    padding: 0 12px 0 38px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    color: var(--gsbb-text, #1f2937) !important;
    background-color: #f7f8fa !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%239aa3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='9' cy='9' r='6'/><line x1='14' y1='14' x2='18' y2='18'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: 12px center !important;
    background-size: 16px 16px !important;
    border: 1.5px solid var(--gsbb-border, #e5e7eb) !important;
    border-radius: 8px !important;
    outline: none !important;
    text-transform: none !important;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease !important;
}
.gsbb-dropdown-panel input.gsbb-search-input::placeholder {
    color: #9aa3af !important;
    opacity: 1 !important;
}
.gsbb-dropdown-panel input.gsbb-search-input:focus {
    background-color: #fff !important;
    border-color: var(--gsbb-btn, #22c55e) !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .12) !important;
}
.gsbb-dropdown-panel .gsbb-search-empty {
    padding: 24px 16px !important;
    text-align: center !important;
    font-size: 13px !important;
    color: var(--gsbb-muted, #6b7280) !important;
}
.gsbb-items-list { /* no styling needed; just a structural wrapper */ }

/* ---- Panel item ---- */
.gsbb-dpi {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background var(--gsbb-transition);
    border-bottom: 1px solid var(--gsbb-border);
    position: relative;
}
.gsbb-dpi:last-child { border-bottom: none; }

.gsbb-dpi:hover    { background: var(--gsbb-highlight, #f3f4f6); }
.gsbb-dpi.is-selected { background: var(--gsbb-highlight, #f3f4f6); }

/* Selected left-bar accent */
.gsbb-dpi.is-selected::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--gsbb-btn, #22c55e);
    border-radius: 0 2px 2px 0;
}

.gsbb-dpi-thumb {
    width: 58px;
    height: 46px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #eee;
}

.gsbb-dpi-content { flex: 1; min-width: 0; }

.gsbb-dpi-name {
    font-size: .85rem;
    font-weight: 700;
    color: var(--gsbb-text);
    margin-bottom: 4px;
    line-height: 1.3;
}

.gsbb-dpi-desc {
    font-size: .76rem;
    color: var(--gsbb-muted);
    line-height: 1.45;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gsbb-dpi-link {
    font-size: .73rem;
    font-weight: 600;
    color: var(--gsbb-btn, #22c55e);
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.gsbb-dpi-link:hover { opacity: .75; }

/* Loading state inside panel */
.gsbb-panel-loading {
    padding: 24px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gsbb-muted);
    font-size: .85rem;
}

/* =============================================
   NATIVE SIZE SELECT
   ============================================= */
.gsbb-select-wrap {
    position: relative;
}
.gsbb-select-wrap::after {
    content: '';
    pointer-events: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--gsbb-muted);
}

.gsbb-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: var(--gsbb-input-h);
    padding: 0 28px 0 11px;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 500;
    color: var(--gsbb-text);
    background: var(--gsbb-bg);
    border: 1.5px solid var(--gsbb-border);
    border-radius: 7px;
    cursor: pointer;
    transition: border-color var(--gsbb-transition), box-shadow var(--gsbb-transition);
    line-height: var(--gsbb-input-h);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gsbb-select:focus {
    outline: none;
    border-color: var(--gsbb-btn, #22c55e);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gsbb-btn, #22c55e) 15%, transparent);
}
.gsbb-select:disabled {
    opacity: .5;
    cursor: not-allowed;
    background: var(--gsbb-bg2);
}
.gsbb-select--loading {
    background: linear-gradient(90deg,#f0f0f0 25%,#e5e5e5 50%,#f0f0f0 75%);
    background-size: 200% 100%;
    animation: gsbb-shimmer 1.2s infinite;
    pointer-events: none;
}
@keyframes gsbb-shimmer { 0%{background-position:200% center} 100%{background-position:-200% center} }



/* =============================================
   PRICE DISPLAY
   ============================================= */
.gsbb-price-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    min-width: 96px;
    padding-left: 24px;
    margin-left: 6px;
    border-left: 1px solid var(--gsbb-border);
}
.gsbb-price-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--gsbb-label);
    display: flex;
    align-items: center;
    gap: 5px;
}
.gsbb-price-label::before { content: '🏷'; font-size: .75rem; text-transform: none; letter-spacing: 0; }
.gsbb-price-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--gsbb-text);
    line-height: 1;
    min-height: var(--gsbb-input-h);
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.gsbb-price-value--empty { font-size: 1rem; color: var(--gsbb-muted); font-weight: 400; }
.gsbb-price-value--loading {
    position: relative;
    opacity: .55;
    transition: opacity .15s ease;
}
.gsbb-price-value--loading::after {
    content: '';
    position: absolute;
    right: -16px;
    top: 50%;
    width: 11px;
    height: 11px;
    margin-top: -5px;
    border: 2px solid #e4e7ec;
    border-top-color: var(--gsbb-btn, #22c55e);
    border-radius: 50%;
    animation: gsbb-spin .7s linear infinite;
}
.gsbb-price-from { font-size: .68rem; color: var(--gsbb-muted); font-weight: 400; margin-left: 3px; }

/* =============================================
   CTA BUTTON
   ============================================= */
.gsbb-cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--gsbb-btn, #22c55e);
    color: var(--gsbb-btn-text, #fff) !important;
    text-decoration: none !important;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    height: var(--gsbb-input-h);
    padding: 0 26px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    letter-spacing: .01em;
    white-space: nowrap;
    flex-shrink: 0;
    transition: filter var(--gsbb-transition), transform var(--gsbb-transition), box-shadow var(--gsbb-transition);
    box-shadow: 0 2px 14px rgba(0,0,0,.15);
    margin-left: 20px;
    align-self: flex-end;
    position: relative;
}
.gsbb-cta-btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 5px 20px rgba(0,0,0,.2); }
.gsbb-cta-btn:active { transform: none; }
.gsbb-cta-btn--disabled { opacity: .45; pointer-events: none; }
.gsbb-cta-arrow { display: inline-block; font-size: 1rem; transition: transform var(--gsbb-transition); }
.gsbb-cta-btn:hover .gsbb-cta-arrow { transform: translateX(4px); }

/* =============================================
   FOOTER
   ============================================= */
.gsbb-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 12px;
    flex-wrap: wrap;
}
.gsbb-loading-inline {
    display: none;
    align-items: center;
    gap: 7px;
    font-size: .78rem;
    color: var(--gsbb-muted);
}
.gsbb-loading-inline.is-active { display: flex; }
.gsbb-spinner {
    width: 13px; height: 13px;
    border: 2px solid #e4e7ec;
    border-top-color: var(--gsbb-btn, #22c55e);
    border-radius: 50%;
    animation: gsbb-spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes gsbb-spin { to { transform: rotate(360deg); } }
.gsbb-footer-msg { font-size: .77rem; color: var(--gsbb-muted); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 860px) {
    .gsbb-bar { flex-wrap: wrap; gap: 14px; }
    .gsbb-field--product { flex: 1 1 100%; }
    .gsbb-field--size { border-left: none; padding-left: 0; margin-left: 0; flex: 1; }
    .gsbb-field--qty  { border-left: none; padding-left: 0; margin-left: 0; flex: 0 0 80px; }
    .gsbb-price-block   { border-left: none; padding-left: 0; margin-left: 0; }
    .gsbb-cta-btn       { margin-left: 0; width: 100%; flex: 1 1 100%; }
    /* NOTE: do NOT set min-width/max-width on .gsbb-dropdown-panel here.
       The panel is portaled to <body>, so 100% would mean "full viewport"
       and overflow on small screens. Width is fully controlled by JS via
       setProperty('width', ..., 'important'). */
}
@media (max-width: 480px) {
    .gsbb-bar { padding: 12px 14px 10px; }
    .gsbb-footer { padding: 0 14px 10px; }
    .gsbb-heading { padding: 12px 14px 10px; }
    .gsbb-price-value { font-size: 1.25rem; }
}
