/* Grshop Custom Option Swatch Grid Layout */

/* Product Options Loader - shows while options initialize to prevent FOUC */
.product-options-loader {
    padding: 40px;
    text-align: center;
}

.product-options-loader .loader-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: loader-spin 1s linear infinite;
}

@keyframes loader-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Hide options while loading - JS removes this class when ready */
.product-options.product-options-loading {
    visibility: hidden;
    height: 0;
    overflow: hidden;
}

/* When options are ready, hide loader */
.product-options:not(.product-options-loading) + .product-options-loader,
.product-options-loader.hidden {
    display: none;
}

/*
 * FIX: BSS DependentCustomOption visibility
 *
 * BSS hides options with: [depend-id].dco-uncommon:not(.dco-enabled) { display: none !important; }
 * BSS JS adds dco-enabled class when parent dependency is selected.
 *
 * We only need to ensure dco-enabled options are visible (don't fight :not(.dco-enabled) rule).
 * If BSS JS isn't adding dco-enabled, that's a JS issue not CSS.
 */
#product-options-wrapper [depend-id].dco-uncommon.dco-enabled,
.product-options [depend-id].dco-uncommon.dco-enabled {
    display: block !important;
}

/* Hide the BSS admin data grid loading spinner that appears on frontend */
.admin__data-grid-outer-wrap,
.admin__data-grid-loading-mask {
    display: none !important;
}

/* CRITICAL: Hide overlay options immediately to prevent layout shift (FOUC)
 * This CSS is in <head>, so options with gr-option-overlay class are hidden
 * BEFORE BSS renders them. They render in the overlay modal instead.
 * Without this, users see ugly BSS options flash before the pretty overlay appears.
 */
.field.gr-option-overlay {
    display: none !important;
}

/* Container: flex grid - matches production ox-grid */
.grshop-swatch-grid {
    display: flex !important;
    flex-wrap: wrap;
    gap: 7px;
    padding: 5px 0;
    list-style: none;
    max-width: 600px;
    margin: 0;
    align-items: flex-start;
}

/* Old OptionExtended li swatches - matches production ox-grid */
/* CRITICAL: overflow must be visible for hover tooltips to show */
#product-options-wrapper .grshop-swatch-grid > li,
.product-options-wrapper .grshop-swatch-grid > li,
body .grshop-swatch-grid > li,
.grshop-swatch-grid > li {
    flex: 0 0 auto;
    width: 80px !important;
    height: 80px !important;
    max-width: 80px !important;
    max-height: 80px !important;
    text-align: center;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 !important;
    border: 2px solid transparent !important;
    border-radius: 0;
    transition: all 0.2s;
    position: relative;
    float: none;
    background-color: #fff;
    overflow: visible !important;
    box-sizing: border-box !important;
}

.grshop-swatch-grid > li:hover {
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
}

/* ALL swatches: thin red border on container when selected */
/* Simplified selector - conflicting wp_custom.less values now fixed */
.grshop-swatch-grid > li.selected {
    border: 1px solid #DF280A !important;
}

/* When there IS an image, remove the img box-shadow (container border is enough) */
.grshop-swatch-grid > li.selected img.ox-swatch {
    box-shadow: none !important;
}

/* Swatch image — fixed 80x80 to match production */
.grshop-swatch-grid > li img.ox-swatch,
.grshop-swatch-grid img.ox-swatch {
    display: block;
    width: 72px !important;
    height: 72px !important;
    margin: 4px;
    object-fit: contain;
    border: none;
    border-radius: 0;
    cursor: pointer;
}

.grshop-swatch-grid > li.selected img.ox-swatch {
    border: none;
}

/* Swatches WITHOUT images - show text label and shadow outline */
.grshop-swatch-grid > li.no-image {
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px !important;
    overflow: visible;
}

.grshop-swatch-grid > li.no-image .sr-label {
    position: static !important;
    display: block !important;
    width: auto !important;
    max-width: 72px;
    box-shadow: none;
    border: none;
    padding: 0;
    background: transparent;
    top: auto !important;
    left: auto !important;
}

.grshop-swatch-grid > li.no-image .sr-label .value-title {
    font-size: 10px;
    line-height: 1.2;
    word-break: break-word;
}

.grshop-swatch-grid > li.no-image .sr-label .enlarger,
.grshop-swatch-grid > li.no-image .sr-label .price-notice,
.grshop-swatch-grid > li.no-image .sr-label .select-btn-block,
.grshop-swatch-grid > li.no-image .sr-label label {
    display: none !important;
}

.grshop-swatch-grid > li.no-image.selected {
    border: 1px solid #DF280A !important;
    box-shadow: 2px 2px 8px rgba(223, 40, 10, 0.3);
}

.grshop-swatch-grid > li.no-image:hover {
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.25);
}

/* Override default field.choice alignment */
fieldset .field.choice,
form .field.choice {
    align-items: flex-start !important;
}

/* BSS-rendered swatches: div.field.choice > div.Bss_image_radio */
.grshop-swatch-grid > .field.choice {
    flex: 0 0 auto;
    width: 80px !important;
    height: 80px !important;
    text-align: center;
    padding: 0;
    margin: 0;
    position: relative;
    border: 1px solid transparent;
    background-color: #fff;
    transition: all 0.2s;
}

.grshop-swatch-grid > .field.choice:hover {
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
}

.grshop-swatch-grid > .field.choice.selected {
    border: 1px solid #DF280A;
}

/* When there IS an image in BSS, remove img box-shadow (container border is enough) */
.grshop-swatch-grid > .field.choice.selected .Bss_image_radio img {
    box-shadow: none !important;
}

/* .Bss_image_radio wrapper */
.grshop-swatch-grid .Bss_image_radio {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer !important;
    float: none !important;
    background: transparent !important;
}

.grshop-swatch-grid .Bss_image_radio:hover {
    border-color: transparent !important;
    background: transparent !important;
}

/* Image - 72x72 with 4px margin to fit 80x80 container */
.grshop-swatch-grid .Bss_image_radio img {
    display: block !important;
    width: 72px !important;
    height: 72px !important;
    margin: 4px !important;
    object-fit: contain;
    border: none !important;
    border-radius: 0;
    float: none !important;
    position: static !important;
    cursor: pointer;
}

.grshop-swatch-grid .Bss_image_radio.grshop-selected img {
    border: none !important;
}

.grshop-swatch-grid .Bss_image_radio label {
    display: none !important;
}

.grshop-swatch-grid .Bss_image_radio input {
    position: absolute !important;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Hide native radio/checkbox inputs */
.grshop-swatch-grid input.product-custom-option {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* sr-label: tooltip on hover - matches production */
/* Base state: hidden */
.grshop-swatch-grid .sr-label,
.grshop-swatch-grid > li .sr-label,
ul.options-list.grshop-swatch-grid li .sr-label,
#product-options-wrapper .grshop-swatch-grid .sr-label {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -1px !important;
    top: 78px !important;
    min-width: 120px !important;
    width: auto !important;
    max-width: 200px;
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    text-align: left;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

/* Hover state: show tooltip */
.grshop-swatch-grid > li:hover > .sr-label,
.grshop-swatch-grid .field.choice:hover > .sr-label,
ul.options-list.grshop-swatch-grid li:hover > .sr-label,
#product-options-wrapper .grshop-swatch-grid li:hover > .sr-label,
body .grshop-swatch-grid li:hover > .sr-label {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto;
}

.grshop-swatch-grid .sr-label .value-title {
    display: inline;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.grshop-swatch-grid .sr-label .old-option-price,
.grshop-swatch-grid .sr-label .price-notice {
    display: inline;
    font-size: 12px;
    color: #333;
    margin-left: 4px;
}

.grshop-swatch-grid .sr-label .enlarger {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 6px;
    cursor: pointer;
    text-decoration: none;
}

.grshop-swatch-grid .sr-label .enlarger:hover {
    text-decoration: underline;
}

.grshop-swatch-grid .sr-label label,
.grshop-swatch-grid .sr-label .select-btn-block {
    display: none;
}

/* Handle existing OptionExtended sr-label structure */
.grshop-swatch-grid .sr-label .sr-label-text {
    display: block;
}

.grshop-swatch-grid .sr-label .sr-label-text .enlarger {
    display: block;
    font-size: 9px;
    color: #333;
    margin-top: 3px;
    cursor: pointer;
    text-decoration: none;
}

.grshop-swatch-grid .sr-label .sr-label-text .enlarger:hover {
    text-decoration: underline;
}

.grshop-swatch-grid .sr-label .sr-label-text .enlarger i.fa-search {
    display: inline;
    margin-right: 3px;
    font-size: 10px;
}

/* Show value-title and price from label element */
.grshop-swatch-grid .sr-label label {
    display: block !important;
}

.grshop-swatch-grid .sr-label label .value-title {
    display: block;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 2px;
}

.grshop-swatch-grid .sr-label label .price-notice {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 1px;
}

/* Reorder: title first, then enlarge */
.grshop-swatch-grid .sr-label {
    display: none;
    flex-direction: column;
}

.grshop-swatch-grid .sr-label label {
    order: 1;
}

.grshop-swatch-grid .sr-label .sr-label-text {
    order: 2;
}

/* Selected indicator in gridexpand-label - shows "▶ [img] Title +price" when selected */
.gridexpand-label .indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.gridexpand-label .indicator img {
    height: 16px;
    width: auto;
    cursor: pointer;
    vertical-align: middle;
}

.gridexpand-label .indicator .price-notice {
    color: #333;
}

/* Hide old-option-price in indicator (strikethrough handled elsewhere) */
.gridexpand-label .indicator .old-option-price {
    display: none;
}

/* Lightbox positioning override - ensure modal display */
.lightboxOverlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 99999 !important;
}

.lightbox {
    position: fixed !important;
    top: 50px !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 100000 !important;
}

/* Responsive */
@media (max-width: 600px) {
    .grshop-swatch-grid {
        gap: 5px;
    }

    .grshop-swatch-grid > li,
    .grshop-swatch-grid > .field.choice {
        width: 70px !important;
        height: 70px !important;
    }

    .grshop-swatch-grid > li img.ox-swatch,
    .grshop-swatch-grid .Bss_image_radio img {
        width: 62px !important;
        height: 62px !important;
    }

    .grshop-swatch-grid .sr-label {
        top: 69px;
        width: 70px;
    }
}
