.tryon-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow-y: auto;
}

.tryon-modal-content {
    background-color: #fefefe;
    margin: 20px auto;
    padding: 24px;
    width: 95%;
    max-width: 1400px;
    position: relative;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.tryon-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.main-content {
    display: flex;
    gap: 24px;
    min-height: 520px;
}

/* Close Button */
.tryon-close {
    position: absolute;
    right: 15px;
    top: 15px;
    width: 30px;
    height: 30px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 1000;
    transition: all 0.3s ease;
    border: none;
    padding: 0;
    line-height: 1;
}

.tryon-close:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Try-On Button on Product Page */
#virtual-tryon-button {
    background-color: #007bff;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    border: none;
    margin: 10px 0;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
}

#virtual-tryon-button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}
.webcam-section {
    flex: 1;
    min-width: 0;
}

.controls-section {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.webcam-container {
    position: relative;
    width: 100%;
    height: calc(100% - 80px);
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e9ecef;
}

#output-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.button {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

#start-camera {
    background: #2563eb !important;
    color: white;
}

#take-screenshot {
    background: #16a34a !important;
    color: white;
}

.button-close {
    background: #6b7280 !important;
    color: white;
}

.button-buy {
    background: #dc2626;
    color: white;
}

.button:hover {
    transform: translateY(-2px);
}

#start-camera:hover {
    background: #1d4ed8;
}

#take-screenshot:hover {
    background: #15803d;
}

.button-close:hover {
    background: #4b5563;
}

.button-buy:hover {
    background: #b91c1c;
}

.button:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
}

.frame-selector,
.adjustment-controls {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.frame-variants {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.frame-variant-option {
    background: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.frame-variant-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.frame-variant-option.active {
    border-color: #2563eb;
}

.color-preview {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.frame-variant-option img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.frame-name {
    font-size: 14px;
    color: #374151;
    text-align: center;
}

.slider-container {
    border-radius: 8px;
    margin-bottom: 12px;
}

.slider-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.value-display {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    color: #374151;
}

.screenshot-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.screenshot-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.screenshot-item:hover {
    transform: translateY(-4px);
}

.screenshot-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.screenshot-actions {
    display: flex;
}

.screenshot-item .download-btn,
.screenshot-item .delete-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
    margin-right: 10px;
}

.screenshot-item .download-btn {
    background: #2563eb;
    color: white;
}

.screenshot-item .delete-btn {
    background: #dc2626;
    color: white;
}

.status-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    z-index: 100;
}

.status-active {
    background: #16a34a;
    color: white;
}

.status-inactive {
    background: #dc2626;
    color: white;
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .controls-section {
        width: 100%;
    }
    
    .frame-variants {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .tryon-container {       
        gap: 15px;
    }
    .tryon-modal-content {
        margin: 0;
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        padding: 12px;
    }

    .main-content {
        flex-direction: column;
        gap: 16px;
        min-height: auto;
    }

    .webcam-section {
        height: 60vh;
    }

    .webcam-container {
        height: calc(100% - 60px);
    }

    .controls-section {
        position: relative;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .frame-selector {
        padding: 12px;
    }

    .frame-variants {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        overflow-x: auto;
        padding: 8px 4px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .frame-variant-option {
        scroll-snap-align: start;
        min-width: 80px;
        padding: 8px;
    }

    .frame-name {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .adjustment-controls {
        padding: 12px;
    }

    .slider-container {
        padding: 2px;
        margin-bottom: 5px;
    }

    .slider-container label {
        font-size: 13px;
    }

    .slider-wrapper {
        gap: 8px;
    }

    input[type="range"] {
        height: 15px; /* Larger touch target */
        padding: 0;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }

    .value-display {
        font-size: 13px;
        min-width: 36px;
    }

    .camera-controls {
        position: fixed;
        bottom: 0;
        left: 70px;
        right: 0;
        padding: 12px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        z-index: 998;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        margin: 0;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
    }

    /*.button {
        flex: 1;
        padding: 10px 12px;
        font-size: 13px;
        min-width: 80px;
        max-width: calc(25% - 6px);
    }*/

    .status-indicator {
        top: 12px;
        right: 12px;
        font-size: 12px;
        padding: 6px 12px;
    }

    .screenshot-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px;
        margin-bottom: env(safe-area-inset-bottom, 20px);
    }

    .screenshot-item {
        border-radius: 12px;
    }

    .screenshot-item img {
        height: 150px;
    }

    .screenshot-actions {
        flex-direction: row;
    }

    .screenshot-item .download-btn,
    .screenshot-item .delete-btn {
        padding: 12px 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .frame-variants {
        grid-template-columns: repeat(3, 1fr);
    }

    .screenshot-gallery {
        grid-template-columns: 1fr;
    }

    .screenshot-item img {
        height: 200px;
    }

    .controls-section {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {
    .tryon-modal-content {
        padding-top: env(safe-area-inset-top, 12px);
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }

    .camera-controls {
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }

    .controls-section {
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 60px);
    }

    input[type="range"] {
        -webkit-appearance: none;
        background: #e5e7eb;
    }
}

/* PWA Display Improvements */
@media all and (display-mode: standalone) {
    .tryon-modal-content {
        padding-top: env(safe-area-inset-top, 40px);
    }

    .camera-controls {
        padding-bottom: env(safe-area-inset-bottom, 24px);
    }
}

/* Mobile Layout Fixes */
@media (max-width: 768px) {
    /* Adjust camera controls to avoid live chat overlap */
    .camera-controls {
        position: fixed;
        bottom: 0;
        left: 70px; /* Add space for live chat icon */
        right: 0;
        padding: 12px 12px 12px 0; /* Reduced left padding */
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        z-index: 998; /* Reduced z-index to stay below live chat */
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        margin: 0;
        display: flex;
        justify-content: flex-end; /* Align buttons to the right */
        gap: 8px; /* Reduced gap between buttons */
    }

    /* Make buttons smaller but still accessible */
    .camera-controls .button {
        flex: 0 1 auto; /* Don't force equal width */
        padding: 12px 16px;
        font-size: 14px;
        min-width: 110px;
    }

    /* Adjust screenshot gallery to avoid button overlap */
    .screenshot-gallery {
        margin-bottom: 80px; /* Add space for fixed buttons */
        padding-bottom: 20px;
    }

    /* Ensure main content has proper spacing */
    .main-content {
        padding-bottom: 15px; /* Add space for fixed buttons */
    }

    /* Adjust safe area insets for iOS */
    @supports (-webkit-touch-callout: none) {
        .camera-controls {
            padding-bottom: calc(env(safe-area-inset-bottom, 12px) + 12px);
            left: calc(70px + env(safe-area-inset-left, 0px));
        }

        .screenshot-gallery {
            margin-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
        }
    }
}

/* Additional adjustments for very small screens */
@media (max-width: 480px) {
    .camera-controls .button {
        padding: 10px 14px;
        font-size: 13px;
        min-width: 100px;
    }
    
    .screenshot-gallery {
        margin-bottom: 90px; /* Slightly more space on smaller screens */
    }
}