/* Style global optimisé pour mobile */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #f5f5f5;
    touch-action: manipulation;
    position: relative;
}

/* Bouton Labs en haut à gauche */
.labs-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.labs-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Zone du ventilateur qui prend toute la place disponible */
#fan-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none; /* Permet aux interactions de passer à travers */
}

#fan-container canvas {
    pointer-events: auto; /* Réactive les interactions sur le canvas */
}

/* Bouton flottant pour afficher/masquer le panneau de contrôle */
.floating-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #3498db;
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s ease;
}

.floating-button:hover, .floating-button:active {
    transform: scale(1.1);
    background-color: #2980b9;
}

/* Animation pulsatile optimisée pour attirer l'attention */
.pulse-effect {
    animation: pulse 2.5s ease-in-out infinite;
    will-change: box-shadow;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(52, 152, 219, 0);
        transform: scale(1.02);
    }
}

/* Mode interactif - États d'humeur optimisés */
.fan-happy {
    animation: floating 3s ease-in-out infinite;
    will-change: transform;
}

.fan-sleepy {
    filter: brightness(0.7) saturate(0.8);
    transition: filter 1s ease;
    will-change: filter;
}

/* Panneau de contrôle optimisé pour mobile */
#control-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 80vh;
    background-color: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.2);
    z-index: 99;
    padding: 20px;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateY(0);
    will-change: transform;
}

#control-panel.hidden {
    transform: translateY(100%);
}

/* En-tête du panneau de contrôle */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.panel-header h2 {
    font-size: 1.2rem;
    color: #333;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #777;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Bouton de fermeture mobile fixe */
.mobile-close-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    transform: scale(1);
}

.mobile-close-button:hover,
.mobile-close-button:active {
    background-color: rgba(231, 76, 60, 0.8);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.mobile-close-button:active {
    transform: scale(0.95);
}

/* Masquer le bouton desktop sur mobile */
.desktop-only {
    display: inline-block;
}

/* Groupes de contrôles */
.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.control-group input[type="range"] {
    width: 100%;
    height: 20px;
    -webkit-appearance: none;
    background: #e0e0e0;
    border-radius: 10px;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

.control-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.control-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: white;
    font-size: 1rem;
}

/* Interrupteur toggle pour les néons */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #3498db;
}

input:focus + .slider {
    box-shadow: 0 0 1px #3498db;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Section des ambiances */
.ambiance-section h3 {
    margin-bottom: 12px;
    color: #555;
    font-weight: 500;
}

.ambiance-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ambiance-button {
    flex: 1;
    min-width: 100px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ambiance-button:hover, .ambiance-button:active {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.ambiance-button.romantic {
    background: linear-gradient(45deg, #ff9a9e, #fad0c4);
}

.ambiance-button.disco {
    background: linear-gradient(45deg, #a18cd1, #fbc2eb);
}

.ambiance-button.relax {
    background: linear-gradient(45deg, #84fab0, #8fd3f4);
}

.ambiance-button.space {
    background: linear-gradient(45deg, #1a2980, #26d0ce);
}

.ambiance-button.tropical {
    background: linear-gradient(45deg, #56ab2f, #a8e063);
}

.ambiance-button.cyberpunk {
    background: linear-gradient(45deg, #bc4e9c, #f80759);
}

.ambiance-button.seasons {
    background: linear-gradient(45deg, #ff416c, #ff4b2b, #40e0d0, #1e9600);
    background-size: 200% 200%;
    animation: gradient-shift 6s ease infinite;
    will-change: background-position;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Confettis pour l'aspect ludique */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Section options fun */
.fun-options-section {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.fun-options-section h3 {
    margin-bottom: 15px;
    color: #555;
    font-weight: 500;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.effect-button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background-color: #f1f1f1;
    color: #333;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.effect-button:hover, .effect-button:active {
    background-color: #e0e0e0;
    transform: scale(1.05);
}

.effect-button i {
    font-size: 1.1em;
}

/* Vidéo selfie en arrière-plan */
.selfie-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: -1;
    transform: scaleX(-1); /* Effet miroir pour une meilleure expérience */
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.selfie-background.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Contrôles selfie flottants */
#selfie-controls {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 150;
    flex-direction: column;
    transition: opacity 0.3s ease;
}

#selfie-controls.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Canvas caché pour les captures */
#selfie-canvas {
    position: absolute;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Prévisualisation de capture */
#capture-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

#capture-preview.hidden {
    opacity: 0;
    pointer-events: none;
}

.preview-content {
    text-align: center;
    max-width: 90%;
    max-height: 90%;
}

#captured-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.preview-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.preview-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    background-color: #3498db;
    color: white;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    min-width: 120px;
    justify-content: center;
}

.preview-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.preview-btn i {
    font-size: 16px;
}

.round-button {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background-color: rgba(52, 152, 219, 0.9);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.round-button:hover, .round-button:active {
    transform: scale(1.1);
    background-color: rgba(41, 128, 185, 0.95);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.capture-btn {
    background-color: rgba(231, 76, 60, 0.9);
}

.capture-btn:hover {
    background-color: rgba(192, 57, 43, 0.95);
}

.switch-btn {
    background-color: rgba(142, 68, 173, 0.9);
}

.switch-btn:hover {
    background-color: rgba(125, 60, 152, 0.95);
}

.close-btn {
    background-color: rgba(149, 165, 166, 0.9);
}

.close-btn:hover {
    background-color: rgba(127, 140, 141, 0.95);
}

/* Container pour météo */
.weather-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

/* Container pour karaoké */
#karaoke-container {
    position: fixed;
    bottom: 90px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 10px;
    border-radius: 10px;
    z-index: 90;
}

#karaoke-container.hidden {
    display: none;
}

#audio-visualizer {
    width: 200px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}

#karaoke-level {
    text-align: center;
    font-weight: bold;
    font-size: 18px;
}

/* Effet hypnotique */
.hypnotic-timer.hidden {
    display: none;
}

/* Responsive design pour différentes tailles d'écran */
@media (min-width: 768px) {
    #control-panel {
        width: 360px;
        left: auto;
        right: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 20px 0 0 20px;
        transform: translateX(0);
    }
    
    #control-panel.hidden {
        transform: translateX(100%);
    }
    
    .floating-button {
        bottom: 30px;
        right: 30px;
    }
    
    #selfie-controls {
        top: 30px;
        left: 30px;
        flex-direction: row;
        gap: 15px;
    }
    
    .preview-controls {
        gap: 20px;
    }
    
    .preview-btn {
        min-width: 140px;
        padding: 15px 25px;
        font-size: 16px;
    }
    
    /* Masquer le bouton mobile sur desktop */
    .mobile-close-button {
        display: none;
    }
}

/* Optimisations pour les performances sur mobile */
@media (max-width: 767px) {
    .selfie-background {
        transform: scaleX(-1) scale(1.1); /* Légèrement plus grand sur mobile */
    }
    
    #captured-image {
        max-height: 60vh;
    }
    
    .preview-controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .preview-btn {
        width: 100%;
        min-width: auto;
    }
    
    /* Masquer le bouton desktop sur mobile */
    .desktop-only {
        display: none;
    }
    
    /* Ajuster la position du bouton mobile quand le panneau est ouvert */
    #control-panel:not(.hidden) ~ * .mobile-close-button,
    #control-panel:not(.hidden) .mobile-close-button {
        top: 15px;
        right: 15px;
        background-color: rgba(231, 76, 60, 0.9);
        animation: pulse-close 2s infinite;
    }
}

/* Animation pour attirer l'attention sur le bouton de fermeture */
@keyframes pulse-close {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
        transform: scale(1.05);
    }
}

/* Animations optimisées pour les modes spéciaux */
@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pulse-color {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(180deg); }
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-3px, 3px); }
    40% { transform: translate(3px, -3px); }
    60% { transform: translate(-3px, -3px); }
    80% { transform: translate(3px, 3px); }
}

/* Animation pour les éléments météo */
.raindrop {
    position: absolute;
    width: 2px;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.8));
    border-radius: 50%;
    animation: fall linear;
    z-index: 5;
}

@keyframes fall {
    0% { transform: translateY(-100px); }
    100% { transform: translateY(100vh); }
}

.lightning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    z-index: 6;
    pointer-events: none;
}

@keyframes flash {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 0.1; }
    50% { opacity: 0.9; }
}

.leaf {
    position: absolute;
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 7;
    animation: float-down 6s ease-in-out;
}

@keyframes float-down {
    0% { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

.snowflake {
    position: absolute;
    color: white;
    font-size: 20px;
    animation: snow-fall linear;
    z-index: 7;
    opacity: 0.8;
}

@keyframes snow-fall {
    0% { transform: translateY(-10vh) rotate(0deg); }
    100% { transform: translateY(110vh) rotate(360deg); }
}

.petal {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: #ffccdd;
    border-radius: 30% 70%;
    z-index: 7;
    animation: float-around 8s ease-in-out;
}

@keyframes float-around {
    0% { transform: translateY(-10vh) translateX(-5vw) rotate(0deg); opacity: 0; }
    10% { opacity: 0.8; }
    100% { transform: translateY(110vh) translateX(10vw) rotate(720deg); opacity: 0; }
}

/* Animation pour le ventilateur */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
