/* PPWI — overlay on WooCommerce gallery + summary controls */

.ppwi-configurator {
    margin: 1rem 0 1.25rem;
    padding: 0.75rem 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.ppwi-configurator__fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.ppwi-configurator__legend {
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding: 0;
}

.ppwi-configurator__tiers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ppwi-configurator__tier {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.ppwi-configurator__tier-price {
    font-weight: 600;
    margin-left: 0.25rem;
}

.ppwi-configurator__live {
    margin: 0.75rem 0 0.25rem;
    font-size: 1rem;
}

.ppwi-configurator__upload {
    margin-top: 0.75rem;
}

.ppwi-configurator__file-label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.35rem;
    cursor: pointer;
}

.ppwi-configurator__file-text {
    font-weight: 500;
}

.ppwi-configurator__upload-status {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: #334155;
}

.ppwi-configurator__resize {
    margin-top: 0.85rem;
    max-width: 22rem;
}

.ppwi-configurator__resize-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.ppwi-configurator__resize-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ppwi-configurator__resize-row input[type='range'] {
    flex: 1;
    min-width: 0;
}

.ppwi-configurator__resize-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

.ppwi-configurator__resize-hint {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: #64748b;
}

.ppwi-order-downloads {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0 0;
    border-top: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

.ppwi-order-downloads__title {
    margin: 0 0 0.35rem;
    font-weight: 600;
}

.ppwi-order-downloads__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ppwi-order-downloads__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.ppwi-order-downloads__thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.ppwi-order-downloads__link {
    font-weight: 500;
}

.ppwi-configurator__warn {
    margin: 0.75rem 0;
}

/* Overlay sits on first gallery slide (logo-on-shirt style) */
.woocommerce-product-gallery__image {
    position: relative;
}

/* When WC zoom is off or still injects .zoomImg, keep it from intercepting drags (see ProductConfigurator). */
body.ppwi-disable-gallery-zoom .woocommerce-product-gallery img.zoomImg {
    pointer-events: none !important;
}

/* Stacking context so overlay z-index wins over theme rules on the gallery link/img. */
body.ppwi-disable-gallery-zoom .woocommerce-product-gallery__image.flex-active-slide,
body.ppwi-disable-gallery-zoom .woocommerce-product-gallery__image:first-child {
    isolation: isolate;
}

.ppwi-gallery-overlay {
    position: absolute;
    z-index: 2147483000;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35) inset;
    pointer-events: none;
    transition: box-shadow 0.15s ease;
}

.ppwi-gallery-overlay--active {
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.65) inset;
}

/* Image is display-only; hits go to __hit layer so drags never fall through to the gallery. */
.ppwi-gallery-overlay--active .ppwi-gallery-overlay__img {
    pointer-events: none;
    position: relative;
    z-index: 0;
}

.ppwi-gallery-overlay__hit {
    position: absolute;
    inset: 0;
    z-index: 2;
    cursor: inherit;
    touch-action: none;
    background: transparent;
}

.ppwi-gallery-overlay--dragging {
    cursor: grabbing;
    touch-action: none;
}

.ppwi-gallery-overlay--dragging .ppwi-gallery-overlay__hit {
    cursor: grabbing;
}

.ppwi-gallery-overlay__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.15);
}

.ppwi-admin-fields {
    border-top: 1px solid #eee;
    padding-top: 8px;
}

/* Full-page subtle dim while generating composite */
body.ppwi-body-loading::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    z-index: 9998;
    pointer-events: all;
}

form.ppwi-form-loading button.single_add_to_cart_button.ppwi-add-to-cart--busy {
    position: relative;
    opacity: 0.85;
    pointer-events: none;
}

form.ppwi-form-loading button.single_add_to_cart_button.ppwi-add-to-cart--busy::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    border: 2px solid rgba(0, 0, 0, 0.25);
    border-top-color: rgba(0, 0, 0, 0.75);
    border-radius: 50%;
    animation: ppwi-spin 0.7s linear infinite;
}

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