/**
 * BeezWoo Touch Preview per WoodMart - Styles
 * @package BeezWoo
 * @since 1.1.0
 */

/* =====================================================
   PREVENT CONTEXT MENU ON SWATCHES
   Queste regole sono FONDAMENTALI per prevenire
   il menu contestuale del sistema operativo
   ===================================================== */

/* Applica a tutti gli swatch WoodMart */
.wd-swatch,
.wd-swatches-grid .wd-btn,
.swatch-on-grid .wd-swatch,
.wd-swatches-product-loop .wd-swatch {
    /* Previene zoom e altri gesti su touch */
    touch-action: manipulation;
    /* Previene selezione testo */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Previene callout su iOS Safari */
    -webkit-touch-callout: none;
    /* Previene highlight su tap */
    -webkit-tap-highlight-color: transparent;
}

/* Durante il long press, impedisci TUTTO - iOS magnifier fix */
.wd-swatch.beezwoo-touching,
.wd-btn.beezwoo-touching {
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* =====================================================
   PREVIEW OVERLAY
   ===================================================== */

.beezwoo-touch-preview-wm {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    
    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    
    /* Transition */
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.beezwoo-touch-preview-wm[hidden] {
    display: none;
}

.beezwoo-touch-preview-wm.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Content container - posizionamento dinamico */
.beezwoo-touch-preview-wm__content {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    max-width: 85vw;
    
    /* Posizione default - sarà sovrascritta da JS */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    
    /* Animation */
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Quando posizionato sopra il dito */
.beezwoo-touch-preview-wm__content.positioned {
    transform: translate(-50%, 0);
}

.beezwoo-touch-preview-wm.is-visible .beezwoo-touch-preview-wm__content {
    opacity: 1;
}

/* Freccia che punta verso il basso (verso il dito) */
.beezwoo-touch-preview-wm__content.positioned::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #fff;
}

/* Image */
.beezwoo-touch-preview-wm__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 220px;
    max-height: 280px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8f8f8;
}

/* Label */
.beezwoo-touch-preview-wm__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hint che appare durante il long press */
.beezwoo-touch-preview-wm__hint {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 12px;
    border-radius: 20px;
    white-space: nowrap;
}

/* =====================================================
   VISUAL FEEDBACK DURANTE LONG PRESS
   ===================================================== */

/* Ring di progresso attorno allo swatch */
.wd-swatch.beezwoo-longpress-active::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid #000;
    border-radius: inherit;
    opacity: 0.5;
    animation: beezwoo-pulse 0.4s ease infinite;
}

@keyframes beezwoo-pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 480px) {
    .beezwoo-touch-preview-wm__image {
        max-width: 180px;
        max-height: 240px;
    }
    
    .beezwoo-touch-preview-wm__content {
        padding: 10px;
    }
}

/* Nascondi completamente su desktop (non serve) */
@media (hover: hover) and (pointer: fine) {
    .beezwoo-touch-preview-wm {
        display: none !important;
    }
}
