/* =====================================================
   VARIANT SELECTION BOTTOM SHEET - MOBILE OPTIMIZED
   Modern, compact, app-like experience
   ===================================================== */

/* ========== OVERLAY ========== */
.variant-bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), 
                visibility 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.variant-bottom-sheet-overlay.active {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ========== BOTTOM SHEET CONTAINER ========== */
.variant-bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FFFFFF;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    max-height: 92vh;
    max-height: calc(100vh - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px)); /* Dynamic viewport height for mobile Chrome */
    height: 92vh;
    height: calc(100vh - env(safe-area-inset-top, 0px));
    height: calc(100dvh - env(safe-area-inset-top, 0px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.variant-bottom-sheet.active {
    transform: translateY(0);
}

/* Chrome mobile specific fix */
@supports (-webkit-touch-callout: none) {
    .variant-bottom-sheet {
        height: 92vh;
        max-height: 92vh;
    }
}

/* ========== DRAG HANDLE ========== */
.variant-sheet-handle-bar {
    width: 40px;
    height: 4px;
    background: #CBD5E0;
    border-radius: 2px;
    margin: 10px auto 6px;
    cursor: grab;
    touch-action: pan-y;
    flex-shrink: 0;
}

.variant-sheet-handle-bar:active {
    cursor: grabbing;
}

/* ========== HEADER ========== */
.variant-sheet-header {
    padding: 4px 16px 8px;
    border-bottom: 1px solid #E2E8F0;
    flex-shrink: 0;
    min-height: 70px;
}

.variant-sheet-header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.variant-sheet-product-info {
    flex: 1;
    min-width: 0;
}

.variant-sheet-product-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1A202C;
    margin: 0 0 4px 0;
    line-height: 1.25;
    /* Modern line clamping */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Fallback for non-webkit browsers */
    max-height: 2.5em; /* 2 lines * line-height */
}

.variant-sheet-price-block {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.variant-sheet-price {
    font-size: 1.05rem;
    font-weight: 700;
    color: #996633;
}

.variant-sheet-original-price {
    font-size: 0.85rem;
    color: #718096;
    text-decoration: line-through;
}

.variant-sheet-tax-note {
    font-size: 0.7rem;
    color: #718096;
    margin-top: 1px;
}

.variant-sheet-close-btn {
    background: #F7FAFC;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4A5568;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.variant-sheet-close-btn:hover,
.variant-sheet-close-btn:active {
    background: #EDF2F7;
    color: #2D3748;
}

/* ========== CONTENT AREA ========== */
.variant-sheet-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 16px 8px;
    /* Make scrollbar visible on mobile */
    scrollbar-width: thin;
    scrollbar-color: #CBD5E0 transparent;
}

/* Visible scrollbar for webkit browsers */
.variant-sheet-content::-webkit-scrollbar {
    width: 6px;
    display: block;
}

.variant-sheet-content::-webkit-scrollbar-track {
    background: transparent;
}

.variant-sheet-content::-webkit-scrollbar-thumb {
    background-color: #CBD5E0;
    border-radius: 3px;
}

.variant-sheet-content::-webkit-scrollbar-thumb:hover {
    background-color: #A0AEC0;
}

/* ========== IMAGE GALLERY ========== */
.variant-sheet-gallery {
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
    height: 260px;
}

/* Thumbnail scrolling container - VERTICAL on LEFT */
.variant-sheet-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 2px 0 0;
    scroll-snap-type: y proximity;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E0 transparent;
    flex-shrink: 0;
}

.variant-sheet-thumbnails::-webkit-scrollbar {
    width: 3px;
}

.variant-sheet-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.variant-sheet-thumbnails::-webkit-scrollbar-thumb {
    background-color: #CBD5E0;
    border-radius: 2px;
}

.variant-sheet-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #E2E8F0;
    cursor: pointer;
    transition: all 0.2s;
    scroll-snap-align: start;
}

.variant-sheet-thumb:hover,
.variant-sheet-thumb.active {
    border-color: #996633;
    transform: scale(1.05);
}

.variant-sheet-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.variant-sheet-thumb-video {
    position: relative;
    width: 100%;
    height: 100%;
}

.variant-sheet-thumb-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.variant-sheet-thumb-video::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #996633;
    font-size: 12px;
    pointer-events: none;
}

/* Main image container - takes remaining space on RIGHT */
.variant-sheet-main-image-container {
    position: relative;
    flex: 1;
    height: 100%;
    background: #F7FAFC;
    border-radius: 12px;
    overflow: hidden;
}

.variant-sheet-main-image,
.variant-sheet-main-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.variant-sheet-main-video {
    display: none;
}

/* ========== ATTRIBUTE SECTION ========== */
.variant-sheet-attribute {
    margin-bottom: 12px;
}

.variant-sheet-attribute-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #2D3748;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.variant-sheet-attribute-selected {
    font-weight: 500;
    color: #996633;
}

/* Horizontal scrolling options */
.variant-sheet-options {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 6px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.variant-sheet-options::-webkit-scrollbar {
    display: none;
}

/* ========== COLOR OPTIONS (VISUAL) ========== */
.variant-sheet-option.color-option {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    border: 2px solid #E2E8F0;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    scroll-snap-align: start;
    padding: 5px;
}

.variant-sheet-option.color-option .color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    margin-bottom: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.variant-sheet-option.color-option .color-label {
    font-size: 0.58rem;
    font-weight: 500;
    color: #4A5568;
    text-align: center;
    line-height: 1.05;
    max-width: 100%;
    /* Modern line clamping */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Fallback */
    max-height: 2.1em; /* ~2 lines */
}

.variant-sheet-option.color-option.selected {
    border-color: #996633;
    background: #FFF5ED;
    box-shadow: 0 4px 12px rgba(153, 102, 51, 0.15);
    transform: translateY(-2px);
}

.variant-sheet-option.color-option.selected .color-label {
    color: #996633;
    font-weight: 600;
}

.variant-sheet-option.color-option:active {
    transform: scale(0.95);
}

/* Checkmark for selected color */
.variant-sheet-option.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    background: #996633;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ========== SIZE/TEXT OPTIONS ========== */
.variant-sheet-option.text-option {
    flex-shrink: 0;
    min-width: 56px;
    height: 38px;
    padding: 0 14px;
    border-radius: 19px;
    border: 2px solid #E2E8F0;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
    scroll-snap-align: start;
}

.variant-sheet-option.text-option .option-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2D3748;
    white-space: nowrap;
}

.variant-sheet-option.text-option.selected {
    border-color: #996633;
    background: #996633;
    box-shadow: 0 4px 12px rgba(153, 102, 51, 0.2);
}

.variant-sheet-option.text-option.selected .option-label {
    color: #FFFFFF;
}

.variant-sheet-option.text-option:active {
    transform: scale(0.95);
}

/* ========== DISABLED OPTIONS ========== */
.variant-sheet-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.variant-sheet-option.disabled::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 2px;
    background: #E53E3E;
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* ========== FOOTER / CTA - STICKY AT BOTTOM ========== */
.variant-sheet-footer {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    border-top: 1px solid #E2E8F0;
    background: #FFFFFF;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.variant-sheet-add-to-cart {
    width: 100%;
    height: 44px;
    background: linear-gradient(135deg, #996633 0%, #B87D4C 100%);
    border: none;
    border-radius: 22px;
    color: #FFFFFF;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(153, 102, 51, 0.25);
}

.variant-sheet-add-to-cart:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(153, 102, 51, 0.3);
}

.variant-sheet-add-to-cart:disabled {
    background: #CBD5E0;
    cursor: not-allowed;
    box-shadow: none;
}

.variant-sheet-add-to-cart i {
    font-size: 1rem;
}

/* ========== SCROLL INDICATORS ========== */
.variant-sheet-options::after {
    content: '→';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), transparent);
    padding: 8px 12px;
    color: #996633;
    font-size: 16px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.variant-sheet-options.has-scroll::after {
    opacity: 1;
}

/* Vertical scroll indicator for thumbnails */
.variant-sheet-thumbnails::after {
    content: '↓';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(to top, rgba(255, 255, 255, 0.95), transparent);
    padding: 6px 8px;
    color: #996633;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.variant-sheet-thumbnails.has-scroll::after {
    opacity: 1;
}

/* ========== MOBILE OPTIMIZATION ========== */
@media (max-width: 767px) {
    .variant-bottom-sheet {
        max-height: 92vh;
        height: 92vh;
    }
    
    .variant-sheet-gallery {
        height: 240px;
    }
    
    .variant-sheet-thumb {
        width: 56px;
        height: 56px;
    }
    
    .variant-sheet-option.color-option {
        width: 54px;
        height: 54px;
    }
    
    .variant-sheet-option.color-option .color-swatch {
        width: 28px;
        height: 28px;
    }
    
    .variant-sheet-option.text-option {
        min-width: 52px;
        height: 36px;
    }

    .variant-sheet-add-to-cart {
        height: 42px;
        font-size: 0.88rem;
    }

    .variant-sheet-content {
        padding: 8px 16px 6px;
    }

    .variant-sheet-attribute {
        margin-bottom: 10px;
    }
}

@media (max-width: 374px) {
    .variant-sheet-gallery {
        height: 200px;
    }
    
    .variant-sheet-thumb {
        width: 52px;
        height: 52px;
    }
    
    .variant-sheet-option.color-option {
        width: 52px;
        height: 52px;
    }
    
    .variant-sheet-option.color-option .color-swatch {
        width: 26px;
        height: 26px;
    }
    
    .variant-sheet-option.text-option {
        min-width: 50px;
        height: 34px;
        padding: 0 12px;
        font-size: 0.8rem;
    }

    .variant-sheet-add-to-cart {
        height: 40px;
        font-size: 0.85rem;
    }
}

/* ========== DESKTOP: HIDE BOTTOM SHEET ========== */
@media (min-width: 992px) {
    .variant-bottom-sheet-overlay,
    .variant-bottom-sheet {
        display: none !important;
    }
}

/* ========== ANIMATIONS ========== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-shimmer {
    background: linear-gradient(
        90deg,
        #F7FAFC 0%,
        #EDF2F7 50%,
        #F7FAFC 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ========== ACCESSIBILITY ========== */
.variant-sheet-option:focus-visible {
    outline: 3px solid #996633;
    outline-offset: 2px;
}

.variant-sheet-close-btn:focus-visible {
    outline: 2px solid #996633;
    outline-offset: 2px;
}

/* ========== SMOOTH SCROLLING ========== */
.variant-sheet-options,
.variant-sheet-thumbnails {
    scroll-behavior: smooth;
}

/* ========== SCROLL INDICATOR ========== */
.variant-sheet-scroll-indicator {
    position: absolute;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(153, 102, 51, 0.9);
    color: white;
    padding: 5px 14px;
    border-radius: 18px;
    font-size: 0.7rem;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 5px;
    z-index: 9;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: bounce 2s infinite;
}

.variant-sheet-scroll-indicator.show {
    display: flex;
}

.variant-sheet-scroll-indicator i {
    font-size: 0.9rem;
    animation: bounce-arrow 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-8px); }
}

@keyframes bounce-arrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* ========== SAFE AREAS FOR NOTCHED DEVICES ========== */
@supports (padding: max(0px)) {
    .variant-bottom-sheet {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        padding-bottom: max(0px, constant(safe-area-inset-bottom)); /* iOS 11.0-11.2 */
    }
    
    .variant-sheet-footer {
        padding-bottom: max(8px, calc(8px + env(safe-area-inset-bottom)));
        padding-bottom: max(8px, calc(8px + constant(safe-area-inset-bottom)));
    }
}

/* Additional viewport height fixes for Chrome mobile */
@media screen and (max-width: 991px) {
    .variant-bottom-sheet {
        /* Use dynamic viewport height which accounts for browser chrome */
        height: 90dvh;
        max-height: 90dvh;
    }
}
