/**
 * Commercify Banner Video Controls CSS
 * Namespace: .cf-banner-video-*
 * Optimisé pour performances GPU, support RTL/LTR
 */

/* Overlay pour les contrôles vidéo */
.cf-banner-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s ease, background-color 0.3s ease;
    will-change: opacity, background-color;
    pointer-events: none;
}

/* Support RTL */
html[dir="rtl"] .cf-banner-video-overlay {
    /* Pas de changement nécessaire, centré symétriquement */
}

/* Overlay visible au hover */
.vignette-ad:hover .cf-banner-video-overlay,
.vignette-ad .product-card:hover ~ .cf-banner-video-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* Quand la vidéo joue, réduire le fond mais garder le bouton visible par défaut */
.cf-banner-video-overlay.cf-banner-video-overlay-hidden {
    background: rgba(0, 0, 0, 0.1);
    opacity: 1;
    pointer-events: none;
}

/* Le bouton reste toujours visible et cliquable même quand la vidéo joue */
.cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
    opacity: 1;
    pointer-events: auto;
    display: flex;
}

/* Améliorer la visibilité au hover quand la vidéo joue */
.vignette-ad:hover .cf-banner-video-overlay.cf-banner-video-overlay-hidden {
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.vignette-ad:hover .cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
    opacity: 1;
    pointer-events: auto;
}

/* Bouton play/pause - toujours visible par défaut */
.cf-banner-video-play-btn {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.75);
    border: 3px solid rgba(255, 255, 255, 0.9);
    color: #ffffff;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, opacity 0.3s ease;
    will-change: transform, opacity;
    pointer-events: auto;
    z-index: 11;
    outline: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    opacity: 1 !important;
    visibility: visible !important;
}

/* Hover sur le bouton */
.cf-banner-video-play-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.cf-banner-video-play-btn:active {
    transform: scale(0.95);
}

/* Focus pour accessibilité */
.cf-banner-video-play-btn:focus {
    outline: 2px solid rgba(255, 215, 0, 0.8);
    outline-offset: 2px;
}

/* Support RTL pour le bouton */
html[dir="rtl"] .cf-banner-video-play-btn {
    /* Pas de changement nécessaire, centré symétriquement */
}

/* Icône play */
.cf-banner-video-play-icon {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transform: translateX(2px); /* Ajustement visuel pour centrer le triangle */
    transition: transform 0.2s ease;
    will-change: transform;
}

/* Support RTL pour l'icône */
html[dir="rtl"] .cf-banner-video-play-icon {
    transform: translateX(-2px); /* Inverser l'ajustement en RTL */
}

/* État pause (quand la vidéo joue) */
.cf-banner-video-play-btn.cf-banner-video-pause-state .cf-banner-video-play-icon {
    transform: translateX(0);
}

/* Icône pause (deux barres) - sera géré par JS en changeant le SVG */
.cf-banner-video-play-btn.cf-banner-video-pause-state .cf-banner-video-play-icon path {
    /* L'icône pause sera injectée par JavaScript */
}

/* Responsive : petits écrans */
@media (max-width: 576px) {
    .cf-banner-video-play-btn {
        width: 48px;
        height: 48px;
        border-width: 2px;
    }
    
    .cf-banner-video-play-icon {
        width: 20px;
        height: 20px;
    }
}

/* Responsive : très petits écrans */
@media (max-width: 400px) {
    .cf-banner-video-play-btn {
        width: 40px;
        height: 40px;
    }
    
    .cf-banner-video-play-icon {
        width: 16px;
        height: 16px;
    }
}

/* Adaptation pour les différents formats de bannières */
.vignette-ad-1x1 .cf-banner-video-overlay,
.vignette-ad-2x1 .cf-banner-video-overlay,
.vignette-ad-1x2 .cf-banner-video-overlay {
    /* Styles communs déjà définis */
}

/* Optimisation pour les bannières 2x1 (plus larges) */
.vignette-ad-2x1 .cf-banner-video-play-btn {
    width: 72px;
    height: 72px;
}

.vignette-ad-2x1 .cf-banner-video-play-icon {
    width: 32px;
    height: 32px;
}

/* Optimisation pour les bannières 1x2 (plus hautes) */
.vignette-ad-1x2 .cf-banner-video-play-btn {
    width: 72px;
    height: 72px;
}

.vignette-ad-1x2 .cf-banner-video-play-icon {
    width: 32px;
    height: 32px;
}

/* En mode autoplay, les contrôles sont toujours visibles par défaut */
.cf-banner-video[autoplay] ~ .cf-banner-video-overlay {
    opacity: 1;
    pointer-events: none;
}

/* Le bouton reste toujours visible et cliquable en mode autoplay */
.cf-banner-video[autoplay] ~ .cf-banner-video-overlay .cf-banner-video-play-btn {
    opacity: 1;
    pointer-events: auto;
    display: flex;
}

/* Quand la vidéo joue en mode autoplay, réduire le fond mais garder le bouton visible */
.cf-banner-video[autoplay] ~ .cf-banner-video-overlay.cf-banner-video-overlay-hidden {
    background: rgba(0, 0, 0, 0.1);
    opacity: 1;
    pointer-events: none;
}

.cf-banner-video[autoplay] ~ .cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
    opacity: 1;
    pointer-events: auto;
    display: flex;
}

/* Améliorer la visibilité au hover en mode autoplay */
.vignette-ad:hover .cf-banner-video[autoplay] ~ .cf-banner-video-overlay {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.vignette-ad:hover .cf-banner-video[autoplay] ~ .cf-banner-video-overlay.cf-banner-video-overlay-hidden {
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

/* Animation d'apparition pour l'overlay */
@keyframes cf-banner-video-overlay-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.cf-banner-video-overlay {
    animation: cf-banner-video-overlay-fade-in 0.3s ease;
}

/* Optimisation GPU : utiliser transform au lieu de top/left */
.cf-banner-video-overlay,
.cf-banner-video-play-btn {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Règles générales pour garantir la visibilité des boutons dans toutes les vues */
/* Thumbs, customthumbs, minicustomthumbs - tous les contextes */
.product-thumb .cf-banner-video-overlay .cf-banner-video-play-btn,
.vignette-item .cf-banner-video-overlay .cf-banner-video-play-btn,
.card .cf-banner-video-overlay .cf-banner-video-play-btn {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    pointer-events: auto !important;
}

/* S'assurer que l'overlay est visible dans tous les contextes */
.product-thumb .cf-banner-video-overlay,
.vignette-item .cf-banner-video-overlay,
.card .cf-banner-video-overlay {
    opacity: 1 !important;
    display: flex !important;
}

/* Hover sur toutes les bannières vidéo - améliorer la visibilité */
.product-thumb:hover .cf-banner-video-overlay,
.vignette-item:hover .cf-banner-video-overlay,
.card:hover .cf-banner-video-overlay {
    background: rgba(0, 0, 0, 0.5) !important;
}

