/**
 * Grshop BSS Custom Options - Overlay Styling
 * Ported from Grshop_CustomOptions upholstery overlay
 */

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus styles for keyboard navigation */
.bss-overlay *:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.bss-overlay li[role="option"]:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Close button styling (changed from span to button) */
.bss-overlay button.overlay-close {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 8px 12px;
}

.bss-overlay button.overlay-close:hover,
.bss-overlay button.overlay-close:focus {
    background: rgba(0, 0, 0, 0.7);
}

/* Overlay Container (summary widget on PDP) */
.bss-overlay-container {
    margin: 15px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

.bss-overlay-container .overlay-button {
    display: inline-block;
    padding: 5px 0;
    background: #f4f4f4;
    color: #303030;
    cursor: pointer;
    border-radius: 0;
    font-weight: 400;
    border: none;
    text-decoration: none;
}

.bss-overlay-container .overlay-button:hover {
    background: #ededed;
    text-decoration: none;
}

.bss-overlay-container .overlay-button.required::after {
    content: '*';
    color: #e02b27;
    margin-left: 3px;
}

.bss-overlay-container .overlay-image-block {
    margin-top: 10px;
    cursor: pointer;
}

.bss-overlay-container .overlay-info-table {
    width: 100%;
    border-collapse: collapse;
}

.bss-overlay-container .overlay-info-table td {
    vertical-align: middle;
    padding: 8px;
}

.bss-overlay-container .overlay-image-block-selected {
    border: 1px solid #ddd;
    border-radius: 4px;
}

.bss-overlay-container .overlay-current-selection {
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
}

.bss-overlay-container .overlay-current-selection-info {
    font-size: 13px;
    color: #666;
}

/* Overlay Background (modal backdrop) */
.bss-overlay-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

/* Overlay Modal */
.bss-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    background: #fff;
    z-index: 1001;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Override theme's gr-overlay conflicting properties when both classes present */
.bss-overlay.gr-overlay {
    left: 0 !important;
    width: 100% !important;
    text-align: left !important;
    transform: none !important;
}

.bss-overlay .column-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.bss-overlay .overlay-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    color: #666;
}

.bss-overlay .overlay-close:hover {
    color: #000;
}

/* Filters Column (left) */
.option-selector {
    width: 250px;
    min-width: 250px;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
}

.option-selector .sr-header {
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
    font-size: 18px;
}

.option-selector .o-filter {
    margin-bottom: 20px;
}

.option-selector .o-filter h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.option-selector .o-filter h3 .clear-filter {
    font-size: 12px;
    color: #000;
    cursor: pointer;
    font-weight: normal;
}

.option-selector .o-filter h3 .clear-filter:hover {
    text-decoration: underline;
}

.option-selector .filter-head {
    cursor: pointer;
    padding: 8px 8px 8px 25px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 5px;
}

.option-selector .filter-head:hover {
    color: #333;
}

.option-selector .filter-head.expanded::before {
    content: '\25BC';
    margin-right: 8px;
}

.option-selector .filter-head:not(.expanded)::before {
    content: '\25B6';
    margin-right: 8px;
}

.option-selector .filter-body {
    padding: 10px;
}

.option-selector .filter-body label {
    display: flex;
    align-items: center;
    padding: 5px 0;
    cursor: pointer;
    text-indent: 0;
}

.option-selector .filter-body label:hover {
    color: #333;
}

.option-selector .filter-body .checkbox {
    width: 16px;
    height: 16px;
    border: 1px solid #ccc;
    border-radius: 0;
    margin-right: 8px;
    display: inline-block;
}

.option-selector .filter-body .checkbox.checked {
    background: #000;
    border-color: #000;
}

.option-selector .filter-body .checkbox.checked::after {
    content: '\2713';
    color: #fff;
    display: block;
    text-align: center;
    line-height: 14px;
    font-size: 12px;
}

.option-selector .filter-body.child {
    padding-left: 25px;
}

/* Color filters - square swatches like production */
.option-selector .color-filters {
    margin: 10px 0 0 -7px;
}

.option-selector .color-filters .color {
    margin-left: 7px;
    float: left;
    width: 39px;
    height: 39px;
    margin-bottom: 8px;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    border: 1px solid transparent;
}

.option-selector .color-filters .color:hover,
.option-selector .color-filters .color.chosen {
    border: 1px solid #bbb;
}

.option-selector .color-filters .color div {
    width: 31px;
    height: 31px;
    margin: 3px;
    border: 1px solid #ddd;
}

.option-selector .color-filters .color .label {
    display: none;
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 11px;
    background: #333;
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
}

.option-selector .color-filters .color:hover .label {
    display: block;
}

/* Search */
.option-selector .search-form {
    display: flex;
}

.option-selector .search-form .keyword-search {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    outline: none;
}

.option-selector .search-form .keyword-search:focus {
    border-color: #1979c3;
}

.option-selector .search-form .keyword-search-button {
    padding: 8px 12px;
    background: #333;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    min-width: 36px;
}

.option-selector .search-form .keyword-search-button:hover {
    background: #555;
}

.option-selector .search-form .keyword-search-button::before {
    content: 'GO';
}

button.keyword-search-button::after {
    display: none;
}

/* Swatches Column (center) */
.image-selector {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.image-selector .sr-header {
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
    font-size: 18px;
}

/* Current filter indicators */
#overlay_current_filter_blocks {
    margin-bottom: 15px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
}

#overlay_current_filter_blocks .current-filter-header {
    font-weight: 600;
    margin-bottom: 8px;
}

#overlay_current_filter_blocks .overlay-current-filters {
    margin-bottom: 8px;
}

#overlay_current_filter_blocks .overlay-current-filters .current-head {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

#overlay_current_filter_blocks .overlay-current-filters .current-filter {
    display: inline-flex;
    align-items: center;
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 0;
    margin-right: 5px;
    margin-bottom: 5px;
}

#overlay_current_filter_blocks .overlay-current-filters .current-filter .remove-filter-btn {
    margin-right: 5px;
    cursor: pointer;
}

#overlay_current_filter_blocks .overlay-current-filters .current-filter .remove-filter-btn::before {
    content: '\2715';
}

/* Swatches grid */
.swatches-list .bss-option-overlay {
    margin-bottom: 20px;
}

.swatches-list .bss-option-overlay .option-label {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

.swatches-list .bss-option-overlay .option-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Swatches grid - matching production site style */
.swatches-list .options-list {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    padding: 5px 0;
    list-style: none;
    margin: 0;
}

.swatches-list .options-list li {
    width: 80px;
    height: 80px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 0;
    transition: all 0.2s;
    position: relative;
    box-sizing: border-box;
    background-color: #fff;
}

.swatches-list .options-list li:hover {
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.swatches-list .options-list li:hover .sr-label {
    display: block;
}

.swatches-list .options-list li.selected {
    border-color: #DF280A;
}

/* Swatches without images - show placeholder background */
.swatches-list .options-list li.no-image {
    background: linear-gradient(135deg, #f5f5f5 25%, #e0e0e0 25%, #e0e0e0 50%, #f5f5f5 50%, #f5f5f5 75%, #e0e0e0 75%);
    background-size: 10px 10px;
}

.swatches-list .options-list li.no-image .sr-label {
    display: block;
}

.swatches-list .options-list li img.ox-swatch {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Handle missing/broken images */
.swatches-list .options-list li img.ox-swatch[src=""],
.swatches-list .options-list li img.ox-swatch:not([src]) {
    background: #f0f0f0;
}

.swatches-list .options-list li input[type="radio"] {
    display: none;
}

/* sr-label: tooltip on hover - matches production */
.swatches-list .options-list li .sr-label {
    display: none;
    position: absolute;
    top: 79px;
    left: -1px;
    width: 80px;
    background: #fff;
    border: 1px solid transparent;
    padding: 2px 6px 6px;
    z-index: 10;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.swatches-list .options-list li .sr-label .value-title {
    display: block;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    word-break: break-word;
    margin-bottom: 2px;
}

.swatches-list .options-list li .sr-label .old-option-price {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.swatches-list .options-list li .sr-label .enlarger {
    display: block;
    font-size: 9px;
    color: #333;
    cursor: pointer;
    text-decoration: none;
    margin-bottom: 0;
}

.swatches-list .options-list li .sr-label .enlarger:hover {
    text-decoration: underline;
}

.swatches-list .options-list li .sr-label label,
.swatches-list .options-list li .sr-label .select-btn-block {
    display: none;
}

.image-selector .no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

/* Info Column (right) */
.bss-info {
    width: 280px;
    min-width: 280px;
    border-left: 1px solid #ddd;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.bss-info .bss-info-price {
    margin-bottom: 15px;
}

.bss-info .bss-info-price .price-box {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.bss-info .bss-info-price .price-box .old-price {
    text-decoration: line-through;
    color: #666;
    font-size: 16px;
    font-weight: 500;
    order: 1;
}

.bss-info .bss-info-price .price-box .regular-price .price {
    font-size: 20px;
    font-weight: 600;
    color: #000;
    order: 2;
}

.bss-info .bss-info-price .price-box .special-price .price {
    font-size: 20px;
    font-weight: 600;
    color: #D30B1F;
    order: 2;
}

.bss-info .bss-info-price .price-box small {
    font-size: 12px;
    color: #666;
    order: 3;
}

.bss-info .bss-current-selection {
    flex: 1;
}

.bss-info .bss-current-selection .current-selection-header {
    font-weight: 600;
    margin-bottom: 10px;
}

.bss-info .bss-current-selection .current-selection-header .selected-option {
    color: #c00;
}

.bss-info .bss-current-selection .view-more {
    display: none;
    color: #303030;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 10px;
}

.bss-info .bss-current-selection .view-more:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .bss-info .bss-current-selection .view-more {
        display: block;
    }
}

.bss-info .bss-current-selection .current-selection-body .overlay-info-table {
    width: 100%;
}

.bss-info .bss-current-selection .current-selection-body .overlay-info-table td {
    vertical-align: top;
    padding: 5px;
}

.bss-info .bss-current-selection .current-selection-body .overlay-current-selection-info {
    font-size: 13px;
    color: #666;
}

.bss-info .bss-overlay-done {
    margin-top: auto;
    padding-top: 15px;
}

.bss-info .bss-overlay-done .overlay-done-button {
    width: 100%;
    padding: 12px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.bss-info .bss-overlay-done .overlay-done-button:hover {
    background: #333;
}

/* Mobile Responsive */
@media (max-width: 1100px) {
    .bss-overlay,
    .bss-overlay.gr-overlay {
        width: 100% !important;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
    }

    .bss-overlay .column-wrapper {
        flex-direction: column;
    }

    .option-selector {
        width: 100%;
        min-width: 100%;
        max-height: none;
        min-height: 0;
        overflow: visible;
        margin: 0;
        padding: 0;
        border-right: none;
        border-bottom: none;
    }

    .option-selector > .sr-header {
        display: none;
    }

    .overlay-filters {
        padding: 0 5px;
        border: 1px solid #ddd;
        border-top: none;
    }

    .overlay-filters h3 {
        font-size: 11px;
    }

    /* Let Knockout's visible binding control .o-filter visibility on mobile */
    .image-selector {
        width: 100%;
        flex: 1;
        min-height: 0;
    }

    .bss-info {
        width: 100%;
        min-width: 100%;
        max-height: none;
        min-height: 0;
        overflow: visible;
        margin: 0;
        padding: 0;
        border-left: none;
        border-top: none;
    }

    .bss-info .bss-info-price {
        border: none;
        margin: 0;
    }

    .bss-info .bss-current-selection {
        margin-bottom: 5px;
        position: relative;
    }

    .bss-info .bss-current-selection .current-selection-body {
        display: none;
    }

    .bss-info .bss-current-selection .current-selection-body.mo-show {
        display: block;
    }

    .bss-info .bss-current-selection .view-more {
        display: block;
        font-size: 12px;
        text-align: left;
        margin-left: 10px;
        padding-bottom: 5px;
        cursor: pointer;
        color: #303030;
    }

    .bss-info .bss-current-selection .view-more:before {
        content: "\25BA";
        margin-right: 4px;
    }

    .bss-info .bss-current-selection .view-more.active:before {
        content: "\25BC";
    }

    .bss-info .bss-overlay-done {
        width: 100px;
        position: absolute;
        top: 12px;
        right: 0;
        padding: 0;
        margin: 0;
    }

    .bss-info .bss-overlay-done .overlay-done-button {
        padding: 8px;
        font-size: 14px;
    }

    /* Mobile filter toggles */
    .mobile-overlay-filters {
        display: block;
    }

    .mobile-overlay-filters .mo-filter {
        display: inline-block;
        width: 50%;
        padding: 10px;
        text-align: center;
        background: #000;
        color: #fff;
        cursor: pointer;
        box-sizing: border-box;
    }

    .mobile-overlay-filters .mo-filter.inactive {
        background: #fff;
        color: #000;
        border-bottom: 1px solid #ddd;
    }

    #mobile_search_toggle.inactive {
        border-left: 1px solid #ddd;
    }

    #mobile_filter_toggle.inactive {
        border-right: 1px solid #ddd;
    }

    .mobile-overlay-filters .mo-filter .icon {
        display: inline-block;
        width: 20px;
        height: 20px;
        vertical-align: middle;
        margin-right: 5px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
    }

    .mo-filter .filter-icon {
        background-image: url(/media/icons/filter-icon.png);
    }

    .mo-filter .search-icon::before {
        content: '\1F50D';
        font-size: 16px;
    }

    .mo-show {
        display: block !important;
    }

    .mo-hide {
        display: none !important;
    }
}

@media (min-width: 1101px) {
    .mobile-overlay-filters {
        display: none;
    }

    /* On desktop, always show all filters regardless of mobileToggle */
    .overlay-filters .o-filter {
        display: block !important;
    }

    .bss-info .bss-current-selection .view-more {
        display: none;
    }

    .bss-info .bss-current-selection .current-selection-body {
        display: block;
    }
}

/* Loading state */
.disabled-bss-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.disabled-bss-overlay .wait-load {
    width: 50px;
    height: 50px;
    background: url(/media/icons/gr-loader.gif) center center no-repeat;
}

/* NOTE: Price box in product-options-bottom is now visible
   (removed display:none rule that was hiding product.price.final_2) */

/* Body class when overlay is open */
body.overlay-open {
    overflow: hidden;
}

/* Lazy loading spinner for fabric sections */
.swatches-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    padding: 20px;
}

.swatches-loading .loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spinner-spin 1s linear infinite;
}

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