/**
 * =============================================================================
 * Project:      Studio4209
 * Component:    Product Actions
 * Revision:     1.4.15
 * Purpose:      Unified product action row and product image preview modals.
 *
 * Dependencies: WordPress, WooCommerce, Elementor shortcode widget
 *
 * Notes:
 *   - Uses Elementor global color variables when available.
 *   - Falls back to white primary and a dark secondary treatment.
 * =============================================================================
 */


/* ------------------------------------------------------------------------- */
/* Single-product image                                                       */
/* ------------------------------------------------------------------------- */

/*
 * Product Actions owns the single-product image so WooLentor does not need to
 * render an interactive gallery/zoom widget here. The image is intentionally
 * static; Zoom+ remains the only product-image enlargement control.
 */
.studio4209-product-page {
    width: 100%;
    margin: 0;
}

.studio4209-product-image {
    width: 100%;
    margin: 0 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.studio4209-product-image img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 72vh;
    margin: 0;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    cursor: default;
}

.studio4209-product-actions {
    --studio4209-action-primary: var(--e-global-color-primary, #ffffff);
    --studio4209-action-secondary: var(--e-global-color-secondary, #1b6f75);
    --studio4209-action-surface: #050505;

    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin: 0;
}

.studio4209-product-action {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    flex: 1 1 0;
    padding: 11px 18px;
    margin: 0;
    border: 1px solid var(--studio4209-action-primary);
    border-radius: 2px;
    background: var(--studio4209-action-surface);
    color: var(--studio4209-action-primary);
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color 180ms ease,
        border-color 180ms ease,
        color 180ms ease,
        transform 180ms ease;
}

.studio4209-product-action:hover,
.studio4209-product-action:focus-visible {
    background: var(--studio4209-action-secondary);
    border-color: var(--studio4209-action-secondary);
    color: var(--studio4209-action-primary);
    text-decoration: none;
}

.studio4209-product-action:active {
    transform: translateY(1px);
}

.studio4209-product-action:focus-visible {
    outline: 2px solid var(--studio4209-action-primary);
    outline-offset: 3px;
}

.studio4209-product-actions-warning {
    margin: 0;
}


/* ------------------------------------------------------------------------- */
/* Product identity, price, and variation selectors                          */
/* ------------------------------------------------------------------------- */

.studio4209-product-title {
    margin: 0 0 14px;
    color: var(--e-global-color-primary, #ffffff);
    font-family: var(--e-global-typography-primary-font-family, inherit);
    font-size: var(--e-global-typography-primary-font-size, 32px);
    font-weight: var(--e-global-typography-primary-font-weight, 400);
    font-style: var(--e-global-typography-primary-font-style, normal);
    line-height: var(--e-global-typography-primary-line-height, 1.2);
    letter-spacing: var(--e-global-typography-primary-letter-spacing, normal);
}

.studio4209-product-price {
    margin: 0;
    color: var(--e-global-color-secondary, #1b6f75);
    font-family: var(--e-global-typography-primary-font-family, inherit);
    font-size: var(--e-global-typography-primary-font-size, 24px);
    font-weight: var(--e-global-typography-primary-font-weight, 400);
    font-style: var(--e-global-typography-primary-font-style, normal);
    line-height: var(--e-global-typography-primary-line-height, 1.2);
}

.studio4209-product-price .woocommerce-Price-amount,
.studio4209-product-price .woocommerce-Price-currencySymbol {
    color: inherit;
    font: inherit;
}

.studio4209-product-selection {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin: 18px 0 0;
}

.studio4209-product-details {
    width: 100%;
    margin: 24px 0 0;
}

.studio4209-product-selector {
    flex: 1 1 0;
    min-width: 0;
}

.studio4209-product-selector label {
    display: block;
    margin: 0 0 7px;
    color: var(--e-global-color-primary, #ffffff);
    font-family: var(--e-global-typography-primary-font-family, inherit);
    font-weight: var(--e-global-typography-primary-font-weight, 400);
    line-height: 1.2;
}

.studio4209-product-selector select {
    appearance: none;
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 11px 42px 11px 18px;
    border: 1px solid var(--e-global-color-primary, #ffffff);
    border-radius: 2px;
    background-color: #050505;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--e-global-color-primary, #ffffff) 50%),
        linear-gradient(135deg, var(--e-global-color-primary, #ffffff) 50%, transparent 50%);
    background-position:
        calc(100% - 20px) 19px,
        calc(100% - 14px) 19px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    color: var(--e-global-color-primary, #ffffff);
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
}

.studio4209-product-selector select:hover:not(:disabled),
.studio4209-product-selector select:focus-visible:not(:disabled) {
    border-color: var(--e-global-color-secondary, #1b6f75);
    outline: none;
}

.studio4209-product-selector select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.studio4209-product-selector select option {
    background: #050505;
    color: var(--e-global-color-primary, #ffffff);
}

/* ------------------------------------------------------------------------- */
/* Shared modal                                                               */
/* ------------------------------------------------------------------------- */

.studio4209-product-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.90);
    backdrop-filter: blur(4px);
}

.studio4209-product-modal.is-open {
    display: flex;
}

.studio4209-product-modal__dialog {
    position: relative;
    width: min(1200px, 96vw);
    max-height: 92vh;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: #050505;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.65);
}

.studio4209-product-modal__dialog--preview {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    border: 0;
    background: #050505;
    box-shadow: none;
}

.studio4209-product-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.studio4209-product-modal__close:hover,
.studio4209-product-modal__close:focus-visible {
    background: var(--e-global-color-secondary, #1b6f75);
    outline: none;
}

/* ------------------------------------------------------------------------- */
/* Zoom                                                                        */
/* ------------------------------------------------------------------------- */

/*
 * The Zoom+ modal owns the interactive enlargement. The product-page image is
 * intentionally not targeted here; WooCommerce's native gallery zoom is
 * disabled in the plugin PHP, while WooCommerce/WooLentor continues to render
 * the normal product image.
 */
.studio4209-product-zoom-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(1200px, 96vw);
    max-width: 96vw;
    height: min(88vh, 100%);
    max-height: 88vh;
    overflow: hidden;
    background: #000;
}

.studio4209-product-zoom {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 88vh;
    object-fit: contain;
    background: #000;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    transform: scale(1);
    transform-origin: center center;
    transition: transform 180ms ease, transform-origin 0ms;
    will-change: transform, transform-origin;
}

.studio4209-product-zoom-stage.is-zooming .studio4209-product-zoom {
    cursor: zoom-out;
    transform: scale(1.85);
}

@media (hover: hover) and (pointer: fine) {
    .studio4209-product-zoom-stage {
        cursor: default;
    }

    .studio4209-product-zoom-stage.is-zooming {
        cursor: zoom-out;
    }
}

@media (prefers-reduced-motion: reduce) {
    .studio4209-product-zoom {
        transition: none;
    }
}



/* ------------------------------------------------------------------------- */
/* Art preview scene: layer-based renderer                                    */
/* ------------------------------------------------------------------------- */

.studio4209-preview-scene {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #050505;
}

.studio4209-preview-stage {
    position: absolute;
    top: 0;
    left: 50%;
    width: min(100vw, 150vh);
    height: min(100vh, 66.6667vw);
    max-width: none;
    max-height: none;
    transform: translateX(-50%);
    overflow: hidden;
    background: #000;
    touch-action: none;
    isolation: isolate;
}

.studio4209-preview-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.studio4209-preview-layer--environment { z-index: 0; }
.studio4209-preview-layer--reference { z-index: 1; }
.studio4209-preview-layer--artwork { z-index: 2; }
.studio4209-preview-layer--material { z-index: 3; }
.studio4209-preview-layer--effects { z-index: 4; }

.studio4209-preview-background {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.studio4209-preview-reference {
    position: absolute;
    display: block;
    height: var(--studio4209-reference-height, 50%);
    width: auto;
    left: var(--studio4209-reference-left, 89%);
    bottom: var(--studio4209-reference-bottom, 2%);
    transform: translateX(-50%);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    opacity: 0.94;
}

.studio4209-preview-layer--reference.is-hidden {
    visibility: hidden;
}

.studio4209-preview-artwork {
    position: absolute;
    left: 50%;
    top: 43%;
    display: block;
    width: auto;
    height: auto;
    max-width: 30%;
    max-height: 25%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: auto;
    filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.45));
}

.studio4209-preview-artwork.is-dragging {
    cursor: grabbing;
}

/*
 * The controls float over the lower edge of the scene and remain persistently
 * visible. The reference is positioned above this overlay so its floor contact
 * remains visible.
 */
.studio4209-preview-controls-wrap {
    position: absolute;
    z-index: 10;
    left: 50%;
    bottom: 0;
    width: min(100vw, 150vh);
    transform: translateX(-50%);
    padding: 14px 18px 18px;
    box-sizing: border-box;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.72) 24%,
        rgba(0, 0, 0, 0.94)
    );
}

.studio4209-preview-controls {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.studio4209-preview-selector {
    flex: 1 1 0;
    min-width: 0;
}

.studio4209-preview-selector label {
    display: block;
    margin: 0 0 5px;
    color: var(--e-global-color-primary, #ffffff);
    font-family: var(--e-global-typography-primary-font-family, inherit);
    font-weight: var(--e-global-typography-primary-font-weight, 400);
    line-height: 1.2;
}

.studio4209-preview-selector select {
    appearance: none;
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
    padding: 8px 36px 8px 14px;
    border: 1px solid var(--e-global-color-primary, #ffffff);
    border-radius: 2px;
    background-color: #050505;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--e-global-color-primary, #ffffff) 50%),
        linear-gradient(135deg, var(--e-global-color-primary, #ffffff) 50%, transparent 50%);
    background-position:
        calc(100% - 17px) 16px,
        calc(100% - 11px) 16px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    color: var(--e-global-color-primary, #ffffff);
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
}

.studio4209-preview-selector select:hover:not(:disabled),
.studio4209-preview-selector select:focus-visible:not(:disabled) {
    border-color: var(--e-global-color-secondary, #1b6f75);
    outline: none;
}

.studio4209-preview-selector select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.studio4209-preview-selector select option {
    background: #050505;
    color: var(--e-global-color-primary, #ffffff);
}

.studio4209-preview-toggle {
    appearance: none;
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--e-global-color-primary, #ffffff);
    border-radius: 2px;
    background: #050505;
    color: var(--e-global-color-primary, #ffffff);
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    transition:
        background-color 180ms ease,
        border-color 180ms ease,
        color 180ms ease;
}

.studio4209-preview-revert-button {
    font-size: 22px;
    line-height: 1;
    padding: 4px 14px;
}

.studio4209-preview-toggle:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.studio4209-preview-toggle:hover:not(:disabled),
.studio4209-preview-toggle:focus-visible:not(:disabled) {
    background: var(--e-global-color-secondary, #1b6f75);
    border-color: var(--e-global-color-secondary, #1b6f75);
    color: var(--e-global-color-primary, #ffffff);
    outline: none;
}

.studio4209-preview-help {
    position: absolute;
    z-index: 11;
    left: 50%;
    bottom: 76px;
    transform: translateX(-50%);
    width: min(100vw, 150vh);
    box-sizing: border-box;
    padding: 0 18px;
    margin: 0;
    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    pointer-events: none;
}

@media (max-width: 640px) {
    .studio4209-preview-controls-wrap {
        padding: 10px 10px 12px;
    }

    .studio4209-preview-controls {
        flex-direction: column;
        gap: 8px;
    }

    .studio4209-preview-help {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .studio4209-product-action {
        transition: none;
    }
}
