/**
 * TopApp Visual Effects - Widget Styles
 * Version: 1.1.0
 * Author: TopApp Tomas Folgado
 * Update: Añadido modo background
 */

/* ============================================================
   CONTENEDOR BASE
   ============================================================ */
.topapp-visual-effect-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.topapp-effect-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
}

/* ============================================================
   MODO BACKGROUND
   ============================================================ */
.topapp-visual-effect-container.topapp-mode-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Contenedor padre necesita position relative */
.topapp-background-parent {
    position: relative !important;
}

/* ============================================================
   MODO FIXED (Parallax)
   ============================================================ */
.topapp-visual-effect-container.topapp-position-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

/* ============================================================
   CONTROL DE INTERACCIÓN
   ============================================================ */
.topapp-visual-effect-container.topapp-no-interaction {
    pointer-events: none;
}

.topapp-visual-effect-container.topapp-no-interaction canvas {
    pointer-events: none;
}

/* Cuando SÍ tiene interacción */
.topapp-visual-effect-container.topapp-has-interaction {
    pointer-events: auto;
}

.topapp-visual-effect-container.topapp-has-interaction canvas {
    pointer-events: auto;
}

/* ============================================================
   OVERLAY PARA CONTENIDO ENCIMA
   ============================================================ */
.topapp-content-overlay {
    position: relative;
    z-index: 10;
}

/* ============================================================
   ELEMENTOR EDITOR MODE
   ============================================================ */
.elementor-editor-active .topapp-visual-effect-container {
    pointer-events: none;
    min-height: 200px;
}

.elementor-editor-active .topapp-visual-effect-container.topapp-mode-background {
    position: relative;
    height: 300px;
}

/* Indicador visual en el editor */
.elementor-editor-active .topapp-visual-effect-container::after {
    content: '🎨 TopApp Effect';
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9999;
}

/* ============================================================
   LOADING STATE
   ============================================================ */
.topapp-visual-effect-container.loading::before {
    content: 'Cargando efecto...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.7);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    z-index: 1;
}

/* ============================================================
   PERFORMANCE OPTIMIZATION
   ============================================================ */
.topapp-visual-effect-container canvas {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .topapp-visual-effect-container {
        min-height: 300px;
    }
    
    .topapp-visual-effect-container.topapp-position-fixed {
        min-height: 100vh;
    }
}

/* ============================================================
   Z-INDEX LAYERS (Referencia)
   -1   : Detrás de todo
   0    : Normal
   1-9  : Contenido normal
   10+  : Overlay/contenido encima
   ============================================================ */