/**
 * 3D Scroll Animation Widget - Styles
 * 
 * @package 3D_Scroll_Widget
 * @version 1.0.0
 */

/* ==========================================
   CONTAINER PRINCIPAL
   ========================================== */

.elementor-3d-scroll-widget {
    position: relative;
    width: 100%;
    height: 100%;
}

.canvas-3d-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: -1;
    transition: opacity 1s ease;
}

.canvas-3d-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ==========================================
   ÉCRAN DE CHARGEMENT
   ========================================== */

.loading-screen-3d {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-screen-3d .loading-content {
    text-align: center;
    color: #ffffff;
}

/* Spinner animé */
.loading-screen-3d .spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin-3d-widget 1s linear infinite;
}

@keyframes spin-3d-widget {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-screen-3d .loading-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 10px;
    color: #ffffff;
}

.loading-screen-3d .loading-progress {
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
}

/* ==========================================
   ANIMATIONS ET TRANSITIONS
   ========================================== */

.canvas-3d-container.loaded {
    opacity: 1;
}

/* Effet de pulse pour le chargement */
@keyframes pulse-3d-widget {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-screen-3d .loading-text {
    animation: pulse-3d-widget 2s ease-in-out infinite;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    .loading-screen-3d .spinner {
        width: 50px;
        height: 50px;
    }
    
    .loading-screen-3d .loading-text {
        font-size: 16px;
    }
    
    .loading-screen-3d .loading-progress {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .loading-screen-3d .spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
    
    .loading-screen-3d .loading-text {
        font-size: 14px;
    }
}

/* ==========================================
   OPTIMISATIONS PERFORMANCES
   ========================================== */

.canvas-3d-container canvas {
    /* Accélération matérielle */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Désactiver le sélection de texte sur le canvas */
.canvas-3d-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ==========================================
   MODE DEBUG (optionnel)
   ========================================== */

.canvas-3d-container[data-debug="true"]::after {
    content: "DEBUG MODE";
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10000;
}

/* ==========================================
   STATES ET CLASSES UTILITAIRES
   ========================================== */

.canvas-3d-container.is-loading {
    opacity: 0;
}

.canvas-3d-container.is-ready {
    opacity: 1;
}

.canvas-3d-container.has-error {
    opacity: 0.3;
}

/* Message d'erreur */
.canvas-3d-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(244, 67, 54, 0.9);
    color: white;
    padding: 20px 30px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    z-index: 1000;
}

.canvas-3d-error h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
}

.canvas-3d-error p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

/* ==========================================
   ELEMENTOR EDITOR
   ========================================== */

/* Styles spécifiques pour l'éditeur Elementor */
.elementor-editor-active .canvas-3d-container {
    position: relative;
    min-height: 400px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.elementor-editor-active .canvas-3d-container::before {
    content: "Aperçu 3D (visible uniquement en front-end)";
    color: #666;
    font-size: 16px;
    font-weight: 500;
}

/* ==========================================
   ACCESSIBILITÉ
   ========================================== */

/* Réduction de mouvement pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
    .canvas-3d-container,
    .loading-screen-3d,
    .spinner {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus visible pour l'accessibilité */
.canvas-3d-container:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .canvas-3d-container,
    .loading-screen-3d {
        display: none !important;
    }
}

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */

@media (prefers-color-scheme: dark) {
    .loading-screen-3d {
        background: rgba(10, 10, 10, 0.95);
    }
    
    .elementor-editor-active .canvas-3d-container {
        background: #1a1a1a;
    }
    
    .elementor-editor-active .canvas-3d-container::before {
        color: #ccc;
    }
}

/* ==========================================
   BROWSER SPECIFIC FIXES
   ========================================== */

/* Fix pour Safari */
@supports (-webkit-appearance: none) {
    .canvas-3d-container canvas {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

/* Fix pour Firefox */
@-moz-document url-prefix() {
    .canvas-3d-container {
        transform: translateZ(0);
    }
}

/* ==========================================
   ANIMATIONS ADDITIONNELLES
   ========================================== */

/* Fade in du container */
@keyframes fadeIn-3d-widget {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.canvas-3d-container.animate-in {
    animation: fadeIn-3d-widget 1s ease;
}

/* Rotation du spinner */
@keyframes rotate-3d-spinner {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

.loading-screen-3d .spinner.enhanced {
    animation: rotate-3d-spinner 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

/* ==========================================
   CUSTOM SCROLLBAR (optionnel)
   ========================================== */

body:has(.canvas-3d-container) {
    scrollbar-width: thin;
    scrollbar-color: #667eea rgba(0, 0, 0, 0.1);
}

body:has(.canvas-3d-container)::-webkit-scrollbar {
    width: 8px;
}

body:has(.canvas-3d-container)::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

body:has(.canvas-3d-container)::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

body:has(.canvas-3d-container)::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}