/**
 * Interactive Testimonials Widget - CSS complet et professionnel
 * TOUS les contrôles Elementor fonctionnels en temps réel
 */

/* ========================================
   VARIABLES CSS
======================================== */
:root {
    --testimonials-primary-color: #4f63d2;
    --testimonials-text-color: #555555;
    --testimonials-title-color: #2c3e50;
    --testimonials-meta-color: #7f8c8d;
    --testimonials-bg-color: #ffffff;
    --testimonials-border-radius: 20px;
    --testimonials-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --testimonials-transition: all 0.3s ease;
    --text-width: 50%;
    --avatars-width: 50%;
}

/* ========================================
   BASE ET CONTENEUR PRINCIPAL
======================================== */
.interactive-testimonials-widget {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.testimonials-container {
    background: var(--testimonials-bg-color);
    border-radius: var(--testimonials-border-radius);
    padding: 50px;
    box-shadow: var(--testimonials-shadow);
    position: relative;
    overflow: hidden;
}

/* ========================================
   TITRE ET SOUS-TITRE
======================================== */
.testimonials-title {
    text-align: center;
    color: var(--testimonials-title-color);
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 50px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.testimonials-subtitle {
    text-align: center;
    color: var(--testimonials-meta-color);
    font-size: 1.1rem;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* ========================================
   LAYOUT FLEXBOX PRINCIPAL
======================================== */
.testimonials-content {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: center;
    min-height: 350px;
}

/* Assurer l'affichage horizontal par défaut */
.interactive-testimonials-widget .testimonials-content {
    flex-direction: row !important;
}

/* ========================================
   SECTIONS TEXTE ET AVATARS - BASE
======================================== */
.testimonial-text-section {
    flex: 1 1 var(--text-width, 50%);
    min-width: 0;
    position: relative;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.testimonial-avatars-section {
    flex: 1 1 var(--avatars-width, 50%);
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   PRESETS DE LARGEUR - VARIABLES CSS
======================================== */
.interactive-testimonials-widget[style*="--text-width"] .testimonial-text-section {
    flex: 0 0 var(--text-width) !important;
}

.interactive-testimonials-widget[style*="--avatars-width"] .testimonial-avatars-section {
    flex: 0 0 var(--avatars-width) !important;
}

/* Fallback pour les classes de presets */
.preset-70-30 {
    --text-width: 70%;
    --avatars-width: 30%;
}

.preset-60-40 {
    --text-width: 60%;
    --avatars-width: 40%;
}

.preset-50-50 {
    --text-width: 50%;
    --avatars-width: 50%;
}

.preset-40-60 {
    --text-width: 40%;
    --avatars-width: 60%;
}

.preset-30-70 {
    --text-width: 30%;
    --avatars-width: 70%;
}

/* ========================================
   TÉMOIGNAGES INDIVIDUELS
======================================== */
.testimonial-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.testimonial-item.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.testimonial-quote {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--testimonials-text-color);
    margin-bottom: 30px;
    font-style: italic;
    position: relative;
    quotes: """ """;
}

.testimonial-quote::before {
    content: open-quote;
    font-size: 16px;
    color: #181818;
    position: absolute;
    top: 1px;
    left: -13px;
    font-family: Georgia, serif;
    line-height: 1;
    opacity: 0.8;
}

.testimonial-quote::after {
    content: close-quote;
    font-size: 16px;
    color: #181818;
    font-family: Georgia, serif;
    line-height: 1;
    opacity: 0.8;
    display: inline;
    position: relative;
    top: -3px;
    margin-left: 2px;
}

.testimonial-author {
    font-weight: 600;
    color: var(--testimonials-title-color);
    font-size: 1.1rem;
    margin-bottom: 5px;
    font-style: normal;
}

.testimonial-author a {
    color: inherit;
    text-decoration: none;
}

.testimonial-author a:hover {
    text-decoration: underline;
}

.testimonial-role {
    color: var(--testimonials-meta-color);
    font-size: 0.9rem;
    font-style: normal;
}

/* Styles pour les notes */
.testimonial-rating {
    margin-bottom: 20px;
}

.testimonial-rating .star {
    color: #ddd;
    font-size: 1.2rem;
    margin-right: 2px;
}

.testimonial-rating .star.filled {
    color: #ffd700;
}

/* ========================================
   GRILLE D'AVATARS
======================================== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    justify-items: center;
    align-content: center;
    width: 100%;
}

.client-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #e8f0fe;
    cursor: pointer;
    transition: var(--testimonials-transition);
    border: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--testimonials-primary-color);
    font-size: 1.2rem;
    overflow: hidden;
    position: relative;
    user-select: none;
    outline: none;
}

.client-avatar:focus {
    outline: 2px solid var(--testimonials-primary-color);
    outline-offset: 2px;
}

.client-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.client-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(79, 99, 210, 0.3);
}

.client-avatar.active {
    border-color: var(--testimonials-primary-color);
    background: var(--testimonials-primary-color);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 8px 25px rgba(79, 99, 210, 0.4);
}

.client-avatar.active img {
    filter: brightness(1.1);
}

/* ========================================
   ANIMATIONS HOVER
======================================== */
.hover-scale .client-avatar:hover {
    transform: scale(1.1);
}

.hover-bounce .client-avatar:hover {
    animation: bounce 0.6s ease-in-out;
}

.hover-pulse .client-avatar:hover {
    animation: pulse 0.6s ease-in-out;
}

.hover-none .client-avatar:hover {
    transform: none;
    animation: none;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ========================================
   BARRE DE PROGRESSION
======================================== */
.progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    margin-top: 30px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--testimonials-primary-color), #667eea);
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 2px;
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

/* Tablette (1024px et moins) */
@media (max-width: 1024px) {
    .testimonials-container {
        padding: 40px 30px;
    }
    
    .testimonials-content {
        gap: 30px;
        min-height: 300px;
    }
    
    .testimonials-title {
        font-size: 2.2rem;
        margin-bottom: 40px;
    }
    
    .client-avatar {
        width: 70px;
        height: 70px;
        font-size: 1.1rem;
    }
    
    /* Grille 3 colonnes sur tablette par défaut */
    .clients-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Ajuster les presets pour tablette */
    .preset-70-30,
    .preset-60-40 {
        --text-width: 60%;
        --avatars-width: 40%;
    }
    
    .preset-30-70,
    .preset-40-60 {
        --text-width: 40%;
        --avatars-width: 60%;
    }
}

/* Mobile (768px et moins) */
@media (max-width: 768px) {
    .testimonials-container {
        padding: 30px 20px;
    }
    
    .testimonials-title {
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .testimonial-text-section {
        min-height: 250px;
    }
    
    .testimonial-quote {
        font-size: 1.1rem;
    }
    
    .client-avatar {
        width: 60px;
        height: 60px;
        font-size: 1rem;
    }
    
    /* Grille 2 colonnes sur mobile par défaut */
    .clients-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    /* LAYOUT MOBILE */
    .mobile-stacked .testimonials-content {
        flex-direction: column !important;
        gap: 25px;
        min-height: auto;
    }
    
    .mobile-stacked .testimonial-text-section,
    .mobile-stacked .testimonial-avatars-section {
        flex: none !important;
        width: 100%;
    }
    
    /* Par défaut, forcer en vertical sur mobile */
    .testimonials-content {
        flex-direction: column !important;
        gap: 25px;
        min-height: auto;
    }
    
    .testimonial-text-section,
    .testimonial-avatars-section {
        flex: none !important;
        width: 100%;
    }
    
    /* Option côte à côte sur mobile (si choisi) */
    .mobile-side_by_side .testimonials-content {
        flex-direction: row !important;
    }
    
    .mobile-side_by_side .testimonial-text-section,
    .mobile-side_by_side .testimonial-avatars-section {
        flex: 1 1 50% !important;
    }
}

/* Petit mobile (480px et moins) */
@media (max-width: 480px) {
    .testimonials-container {
        padding: 20px 15px;
    }
    
    .testimonials-title {
        font-size: 1.8rem;
        margin-bottom: 25px;
    }
    
    .testimonial-text-section {
        min-height: 200px;
    }
    
    .testimonial-quote {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .client-avatar {
        width: 50px;
        height: 50px;
        font-size: 0.9rem;
    }
    
    .clients-grid {
        gap: 10px;
    }
    
    .testimonials-content {
        gap: 20px;
    }
    
    /* Forcer le layout vertical sur très petit écran */
    .testimonials-content {
        flex-direction: column !important;
    }
    
    .testimonial-text-section,
    .testimonial-avatars-section {
        flex: none !important;
        width: 100%;
    }
}

/* ========================================
   SUPPORT TOTAL DES CONTRÔLES ELEMENTOR
======================================== */

/* Assurer que tous les changements sont visibles dans l'éditeur */
.elementor-editor-active .testimonials-content {
    transition: all 0.3s ease;
}

.elementor-editor-active .testimonial-text-section,
.elementor-editor-active .testimonial-avatars-section {
    transition: all 0.3s ease;
}

/* Direction flexbox - Support complet */
.elementor-widget-interactive_testimonials .testimonials-content[style*="flex-direction: row"] {
    flex-direction: row !important;
}

.elementor-widget-interactive_testimonials .testimonials-content[style*="flex-direction: row-reverse"] {
    flex-direction: row-reverse !important;
}

.elementor-widget-interactive_testimonials .testimonials-content[style*="flex-direction: column"] {
    flex-direction: column !important;
}

/* Alignements verticaux */
.elementor-widget-interactive_testimonials .testimonials-content[style*="align-items: flex-start"] {
    align-items: flex-start !important;
}

.elementor-widget-interactive_testimonials .testimonials-content[style*="align-items: center"] {
    align-items: center !important;
}

.elementor-widget-interactive_testimonials .testimonials-content[style*="align-items: flex-end"] {
    align-items: flex-end !important;
}

/* Support des contrôles responsive de colonnes */
@media (max-width: 1024px) {
    .elementor-widget-interactive_testimonials .clients-grid[style*="repeat(3"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .elementor-widget-interactive_testimonials .clients-grid[style*="repeat(4"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .elementor-widget-interactive_testimonials .clients-grid[style*="repeat(5"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 767px) {
    .elementor-widget-interactive_testimonials .clients-grid[style*="repeat(3"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .elementor-widget-interactive_testimonials .clients-grid[style*="repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .elementor-widget-interactive_testimonials .clients-grid[style*="repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========================================
   ACCESSIBILITÉ
======================================== */
@media (prefers-reduced-motion: reduce) {
    .testimonial-item,
    .client-avatar,
    .progress-fill {
        transition: none;
    }
    
    .hover-bounce .client-avatar:hover,
    .hover-pulse .client-avatar:hover {
        animation: none;
    }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    :root {
        --testimonials-bg-color: #1a1a1a;
        --testimonials-text-color: #e0e0e0;
        --testimonials-title-color: #ffffff;
        --testimonials-meta-color: #b0b0b0;
        --testimonials-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }
    
    .client-avatar {
        background: #2a2a2a;
    }
    
    .progress-bar {
        background: #333333;
    }
    
    .testimonial-quote::before,
    .testimonial-quote::after {
        color: #ffffff;
    }
}

/* ========================================
   PRINT STYLES
======================================== */
@media print {
    .interactive-testimonials-widget {
        break-inside: avoid;
    }
    
    .testimonials-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .progress-bar {
        display: none;
    }
    
    .testimonials-content {
        flex-direction: column !important;
    }
    
    .testimonial-item {
        position: static !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    .testimonial-item:not(.active) {
        display: none;
    }
}

/* ========================================
   ÉTATS D'ERREUR ET DE CHARGEMENT
======================================== */
.testimonials-error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
    font-weight: 500;
}

.testimonials-loading {
    text-align: center;
    padding: 40px;
    color: var(--testimonials-meta-color);
}

/* ========================================
   COMPATIBILITÉ THÈMES
======================================== */
.ast-container .interactive-testimonials-widget,
.content-area .interactive-testimonials-widget,
.site-content .interactive-testimonials-widget,
.nv-content-wrap .interactive-testimonials-widget {
    max-width: 100%;
    margin-bottom: 0;
}

/* Assurer la compatibilité avec les thèmes qui modifient flex */
.ast-container .interactive-testimonials-widget .testimonials-content,
.content-area .interactive-testimonials-widget .testimonials-content,
.site-content .interactive-testimonials-widget .testimonials-content,
.nv-content-wrap .interactive-testimonials-widget .testimonials-content {
    display: flex !important;
}

/* ========================================
   DEBUG MODE
======================================== */
.testimonials-debug .testimonials-content {
    border: 2px dashed #ff6b6b;
    position: relative;
}

.testimonials-debug .testimonials-content::before {
    content: "Direction: " attr(style);
    position: absolute;
    top: -25px;
    left: 0;
    font-size: 12px;
    color: #ff6b6b;
    background: white;
    padding: 2px 5px;
    border-radius: 3px;
}

.testimonials-debug .testimonial-text-section {
    border: 1px solid #4ecdc4;
    background: rgba(78, 205, 196, 0.1);
    position: relative;
}

.testimonials-debug .testimonial-text-section::before {
    content: "Section Texte: " attr(style);
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    color: #4ecdc4;
    background: white;
    padding: 2px;
    border-radius: 2px;
}

.testimonials-debug .testimonial-avatars-section {
    border: 1px solid #ffe66d;
    background: rgba(255, 230, 109, 0.1);
    position: relative;
}

.testimonials-debug .testimonial-avatars-section::before {
    content: "Section Avatars: " attr(style);
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    color: #e6a200;
    background: white;
    padding: 2px;
    border-radius: 2px;
}

/* ========================================
   CLASSES UTILITAIRES
======================================== */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.client-avatar.focused {
    outline: 2px solid var(--testimonials-primary-color) !important;
    outline-offset: 2px !important;
}

/* Force l'affichage des changements Elementor en temps réel */
.elementor-editor-active .interactive-testimonials-widget {
    transition: all 0.1s ease;
}

/* Assurer que les presets sont visibles immédiatement */
.elementor-editor-active .preset-70-30 .testimonial-text-section {
    flex: 0 0 70% !important;
}

.elementor-editor-active .preset-70-30 .testimonial-avatars-section {
    flex: 0 0 30% !important;
}

.elementor-editor-active .preset-60-40 .testimonial-text-section {
    flex: 0 0 60% !important;
}

.elementor-editor-active .preset-60-40 .testimonial-avatars-section {
    flex: 0 0 40% !important;
}

.elementor-editor-active .preset-50-50 .testimonial-text-section {
    flex: 0 0 50% !important;
}

.elementor-editor-active .preset-50-50 .testimonial-avatars-section {
    flex: 0 0 50% !important;
}

.elementor-editor-active .preset-40-60 .testimonial-text-section {
    flex: 0 0 40% !important;
}

.elementor-editor-active .preset-40-60 .testimonial-avatars-section {
    flex: 0 0 60% !important;
}

.elementor-editor-active .preset-30-70 .testimonial-text-section {
    flex: 0 0 30% !important;
}

.elementor-editor-active .preset-30-70 .testimonial-avatars-section {
    flex: 0 0 70% !important;
}