/**
 * VGDev Virtual Try-On Styles
 * Optimized for performance
 */

:root {
    --vgdev-vto-primary: #000000;
    --vgdev-vto-secondary: #333333;
    --vgdev-vto-accent: #666666;
    --vgdev-vto-light: #f5f5f5;
    --vgdev-vto-white: #ffffff;
    --vgdev-vto-modal-width: 420px;
    --vgdev-vto-radius: 8px;
}

/* Modal Open State */
body.vgdev-vto-modal-open {
    overflow: hidden;
}

/* Main Modal - Full Screen Mobile Style */
.vgdev-vto-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vgdev-vto-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.vgdev-vto-modal-container {
    position: relative;
    width: 100%;
    max-width: var(--vgdev-vto-modal-width);
    height: 100%;
    max-height: 100vh;
    background: var(--vgdev-vto-white);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .vgdev-vto-modal-container {
        max-height: 95vh;
        border-radius: var(--vgdev-vto-radius);
    }
}

/* Header */
.vgdev-vto-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--vgdev-vto-primary);
    color: var(--vgdev-vto-white);
    gap: 8px;
    flex-shrink: 0;
}

.vgdev-vto-header-spacer {
    flex: 1;
}

.vgdev-vto-btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.vgdev-vto-btn-icon:hover {
    opacity: 0.8;
}

.vgdev-vto-btn-icon svg {
    width: 20px;
    height: 20px;
}

/* Content Area */
.vgdev-vto-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Screens */
.vgdev-vto-screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.vgdev-vto-screen.active {
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Start Screen */
.vgdev-vto-start-screen {
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    background: var(--vgdev-vto-light);
}

.vgdev-vto-logo h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px;
    color: var(--vgdev-vto-primary);
}

/* Fixed placeholder - fills entire area */
.vgdev-vto-source-preview {
    width: 180px;
    height: 220px;
    border-radius: var(--vgdev-vto-radius);
    overflow: hidden;
    margin: 15px auto;
    background: #c8c8c8;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.vgdev-vto-source-preview img.vgdev-vto-preview-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
}

.vgdev-vto-preview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #c8c8c8;
    z-index: 1;
}

.vgdev-vto-preview-placeholder svg {
    width: 60px;
    height: 60px;
    color: #888;
}

.vgdev-vto-subtitle {
    font-size: 12px;
    color: #666;
    max-width: 300px;
    margin: 0 auto 15px;
    line-height: 1.4;
}

.vgdev-vto-consent {
    margin-bottom: 20px;
    font-size: 11px;
    color: #666;
}

.vgdev-vto-consent label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
    max-width: 350px;
    cursor: pointer;
    margin: 0 auto;
}

.vgdev-vto-consent input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.vgdev-vto-source-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 280px;
}

/* Buttons */
.vgdev-vto-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--vgdev-vto-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.vgdev-vto-btn svg {
    width: 20px;
    height: 20px;
}

.vgdev-vto-btn-primary {
    background: var(--vgdev-vto-primary);
    color: var(--vgdev-vto-white);
}

.vgdev-vto-btn-secondary {
    background: var(--vgdev-vto-secondary);
    color: var(--vgdev-vto-white);
}

/* Model Selection Screen */
.vgdev-vto-model-screen {
    padding: 20px;
    background: var(--vgdev-vto-primary);
    overflow-y: auto;
}

.vgdev-vto-model-screen h3 {
    color: var(--vgdev-vto-white);
    margin: 0 0 10px;
    font-size: 16px;
    text-align: center;
}

.vgdev-vto-model-screen > p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    text-align: center;
    margin: 0 0 20px;
}

.vgdev-vto-back-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--vgdev-vto-white);
    cursor: pointer;
    padding: 6px;
}

.vgdev-vto-back-btn svg {
    width: 24px;
    height: 24px;
}

.vgdev-vto-models-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding-top: 30px;
}

.vgdev-vto-model-item {
    cursor: pointer;
    border-radius: var(--vgdev-vto-radius);
    overflow: hidden;
    background: #222;
}

.vgdev-vto-model-item img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    display: block;
}

.vgdev-vto-model-item span {
    display: block;
    padding: 8px;
    color: var(--vgdev-vto-white);
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Camera Screen */
.vgdev-vto-camera-screen {
    position: relative;
    background: #000;
    align-items: center;
    justify-content: center;
}

#vgdev-vto-video {
    width: 100%;
    height: calc(100% - 80px);
    object-fit: cover;
    transform: scaleX(-1);
}

.vgdev-vto-camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 80px);
    pointer-events: none;
}

/* Hide face guide circle */
.vgdev-vto-face-guide {
    display: none;
}

.vgdev-vto-camera-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.9);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.vgdev-vto-camera-controls .vgdev-vto-btn-icon {
    color: var(--vgdev-vto-white);
}

.vgdev-vto-capture {
    width: 60px;
    height: 60px;
    background: var(--vgdev-vto-white);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.vgdev-vto-capture svg {
    width: 100%;
    height: 100%;
}

/* Try-On Screen - LARGER IMAGE like Maybelline */
.vgdev-vto-tryon-screen {
    position: relative;
    background: var(--vgdev-vto-light);
}

.vgdev-vto-canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    position: relative;
    background: var(--vgdev-vto-light);
}

#vgdev-vto-canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: calc(100vh - 280px);
    object-fit: contain;
}

@media (max-width: 480px) {
    #vgdev-vto-canvas {
        max-height: calc(100vh - 320px);
    }
}

/* Loading Overlay */
.vgdev-vto-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 10;
}

.vgdev-vto-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--vgdev-vto-light);
    border-top-color: var(--vgdev-vto-primary);
    border-radius: 50%;
    animation: vgdev-spin 0.8s linear infinite;
}

@keyframes vgdev-spin {
    to { transform: rotate(360deg); }
}

/* Product Popup */
.vgdev-vto-product-popup {
    position: absolute;
    bottom: 180px;
    left: 10px;
    right: 10px;
    background: var(--vgdev-vto-white);
    border-radius: var(--vgdev-vto-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    align-items: center;
    padding: 10px;
    gap: 10px;
    z-index: 5;
}

.vgdev-vto-product-popup-image {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.vgdev-vto-product-popup-info {
    flex: 1;
    min-width: 0;
}

.vgdev-vto-product-popup-name {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vgdev-vto-product-popup-variant {
    font-size: 11px;
    color: var(--vgdev-vto-accent);
    margin: 2px 0 0;
}

.vgdev-vto-product-popup-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.vgdev-vto-product-popup-actions .vgdev-vto-btn-icon {
    width: 32px;
    height: 32px;
    background: var(--vgdev-vto-light);
    border-radius: 4px;
    color: var(--vgdev-vto-primary);
}

.vgdev-vto-btn-buy {
    padding: 8px 16px;
    background: var(--vgdev-vto-primary);
    color: var(--vgdev-vto-white);
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

/* Bottom Panel - Maybelline Style */
.vgdev-vto-bottom-panel {
    background: var(--vgdev-vto-primary);
    flex-shrink: 0;
}

/* Categories Icons - Scrollable horizontal */
.vgdev-vto-categories-icons {
    display: flex;
    padding: 12px 5px;
    background: var(--vgdev-vto-primary);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.vgdev-vto-categories-icons::-webkit-scrollbar {
    display: none;
}

.vgdev-vto-categories-row2 {
    border-bottom: none;
}

.vgdev-vto-cat-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--vgdev-vto-white);
    cursor: pointer;
    padding: 5px 8px;
    min-width: 55px;
    flex-shrink: 0;
}

.vgdev-vto-cat-icon svg {
    width: 28px;
    height: 28px;
    opacity: 0.85;
}

.vgdev-vto-cat-icon span {
    font-size: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
    opacity: 0.85;
}

.vgdev-vto-cat-icon:hover,
.vgdev-vto-cat-icon.active {
    opacity: 1;
}

.vgdev-vto-cat-icon:hover svg,
.vgdev-vto-cat-icon:hover span,
.vgdev-vto-cat-icon.active svg,
.vgdev-vto-cat-icon.active span {
    opacity: 1;
}

/* Products Row - Category on Left, Products on Right */
.vgdev-vto-products-row {
    display: flex;
    align-items: stretch;
    background: var(--vgdev-vto-white);
    min-height: 95px;
}

.vgdev-vto-products-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    background: transparent;
    border: none;
    color: var(--vgdev-vto-accent);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.vgdev-vto-products-back svg {
    width: 18px;
    height: 18px;
}

.vgdev-vto-active-category {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    min-width: 65px;
    background: var(--vgdev-vto-light);
    border-right: 1px solid #e0e0e0;
}

.vgdev-vto-active-cat-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.vgdev-vto-active-cat-icon svg {
    width: 28px;
    height: 28px;
    color: var(--vgdev-vto-primary);
}

.vgdev-vto-active-cat-label {
    font-size: 7px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--vgdev-vto-primary);
    text-align: center;
    line-height: 1.2;
    max-width: 55px;
    word-wrap: break-word;
}

.vgdev-vto-products-scroll {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.vgdev-vto-products-scroll::-webkit-scrollbar {
    display: none;
}

.vgdev-vto-products-list {
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    min-width: max-content;
}

.vgdev-vto-product-item {
    flex-shrink: 0;
    width: 65px;
    cursor: pointer;
    text-align: center;
}

.vgdev-vto-product-item img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
    background: #fff;
    display: block;
    margin: 0 auto;
    border: 2px solid transparent;
    transition: border-color 0.15s ease;
}

.vgdev-vto-product-item.active img {
    border-color: var(--vgdev-vto-primary);
}

.vgdev-vto-product-name {
    display: block;
    margin-top: 4px;
    font-size: 8px;
    color: var(--vgdev-vto-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65px;
}

.vgdev-vto-no-products {
    color: var(--vgdev-vto-accent);
    font-size: 11px;
    padding: 15px;
    margin: 0;
}

/* Products Bar styles moved to products-row above */

/* Shades Bar */
.vgdev-vto-shades-bar {
    display: none;
    padding: 12px;
    background: var(--vgdev-vto-white);
    border-top: 1px solid #eee;
}

.vgdev-vto-shades-bar.active {
    display: block;
}

.vgdev-vto-shades-list {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.vgdev-vto-shade-item {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease;
}

.vgdev-vto-shade-item:hover {
    transform: scale(1.1);
}

.vgdev-vto-shade-item.active {
    border-color: var(--vgdev-vto-primary);
    transform: scale(1.15);
}

/* Action Buttons Bar */
.vgdev-vto-actions-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 12px 10px;
    background: var(--vgdev-vto-secondary);
}

.vgdev-vto-btn-shades,
.vgdev-vto-btn-compare {
    padding: 10px 30px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
}

.vgdev-vto-btn-shades {
    background: var(--vgdev-vto-white);
    color: var(--vgdev-vto-primary);
    border: none;
}

.vgdev-vto-btn-compare {
    background: transparent;
    color: var(--vgdev-vto-white);
    border: 1px solid var(--vgdev-vto-white);
}

/* Compare Overlay */
.vgdev-vto-compare-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.vgdev-vto-compare-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 100%;
    max-height: 80vh;
}

.vgdev-vto-compare-item {
    text-align: center;
}

.vgdev-vto-compare-item h4 {
    color: var(--vgdev-vto-white);
    margin: 0 0 10px;
    font-size: 14px;
}

#vgdev-vto-canvas-before,
#vgdev-vto-canvas-after {
    max-width: 180px;
    max-height: 60vh;
    border-radius: var(--vgdev-vto-radius);
}

.vgdev-vto-close-compare {
    margin-top: 20px;
    padding: 12px 40px;
    background: var(--vgdev-vto-white);
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* Help Modal */
#vgdev-vto-help-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000001;
    align-items: center;
    justify-content: center;
}

.vgdev-vto-help-content {
    background: var(--vgdev-vto-white);
    padding: 30px;
    border-radius: var(--vgdev-vto-radius);
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    margin: 20px;
}

.vgdev-vto-help-content h3 {
    margin: 0 0 20px;
}

.vgdev-vto-help-content ol {
    padding-left: 20px;
    margin: 0;
}

.vgdev-vto-help-content li {
    margin-bottom: 10px;
}

.vgdev-vto-help-close {
    margin-top: 20px;
    padding: 12px 30px;
    background: var(--vgdev-vto-primary);
    color: var(--vgdev-vto-white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .vgdev-vto-modal-container {
        max-width: 100%;
    }
    
    .vgdev-vto-canvas-container {
        min-height: 350px;
    }
    
    .vgdev-vto-models-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .vgdev-vto-product-popup {
        bottom: 200px;
    }
    
    .vgdev-vto-compare-container {
        flex-direction: column;
        gap: 15px;
    }
    
    #vgdev-vto-canvas-before,
    #vgdev-vto-canvas-after {
        max-width: 140px;
    }
}

/* Bottom Actions Bar */
.vgdev-vto-bottom-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 15px;
    background: var(--vgdev-vto-white);
    border-top: 1px solid #eee;
}

.vgdev-vto-bottom-actions .vgdev-vto-btn {
    min-width: 110px;
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 600;
}

.vgdev-vto-bottom-actions .vgdev-vto-btn-shades {
    background: var(--vgdev-vto-primary);
    color: var(--vgdev-vto-white);
    border: none;
}

.vgdev-vto-bottom-actions .vgdev-vto-btn-compare {
    background: transparent;
    color: var(--vgdev-vto-primary);
    border: 1px solid var(--vgdev-vto-primary);
}

/* Ensure shades bar is properly hidden when empty */
.vgdev-vto-shades-bar:empty,
.vgdev-vto-shades-list:empty {
    display: none !important;
}

/* Hide any elements that should not be visible */
.vgdev-vto-compare-slider,
.vgdev-vto-compare-overlay {
    display: none !important;
}

.vgdev-vto-compare-overlay.active {
    display: flex !important;
}

/* Compare Overlay when active */
.vgdev-vto-compare-overlay.active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000001;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.vgdev-vto-compare-content {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    max-width: 100%;
}

.vgdev-vto-compare-side {
    text-align: center;
}

.vgdev-vto-compare-side canvas {
    max-width: 180px;
    max-height: 60vh;
    border-radius: var(--vgdev-vto-radius);
}

.vgdev-vto-compare-label {
    display: block;
    margin-top: 10px;
    color: var(--vgdev-vto-white);
    font-size: 12px;
    font-weight: 600;
}

.vgdev-vto-compare-divider {
    width: 2px;
    height: 200px;
    background: rgba(255, 255, 255, 0.3);
}

.vgdev-vto-compare-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.vgdev-vto-compare-mode .vgdev-vto-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--vgdev-vto-white);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.vgdev-vto-close-compare {
    background: var(--vgdev-vto-white) !important;
    color: var(--vgdev-vto-primary) !important;
}

/* Performance: GPU acceleration for animations */
.vgdev-vto-modal,
.vgdev-vto-screen,
.vgdev-vto-canvas-container,
#vgdev-vto-canvas {
    transform: translateZ(0);
    will-change: transform;
}

/* Smooth transitions */
.vgdev-vto-screen {
    transition: opacity 0.15s ease;
}

.vgdev-vto-product-item,
.vgdev-vto-category-btn,
.vgdev-vto-btn {
    transition: all 0.15s ease;
}

/* Category styles in bottom panel already defined above */
