/**
 * ================================================================
 * Crowdaa Success Modal - Système unifié de modals de confirmation
 * Version: 4.5.0
 * ================================================================
 *
 * Modal de succès unifié pour toutes les activités du calendrier.
 * Basé sur les meilleures pratiques de Memory Game et Mystery Box.
 *
 * Standards:
 * - Icône/Emoji: 80px
 * - Titre: 28px, font-weight: 700
 * - Message: 16px
 * - Auto-close: 3s avec option de fermeture manuelle
 * - Safe areas iOS complètes
 * - Animation d'apparition fluide
 */

/* ================================================================
   1. OVERLAY - Fond semi-transparent
   ================================================================ */

.crowdaa-success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--cal-z-modal-overlay, 100000); /* v4.5.0 - Au-dessus du catchup modal (99999) */

    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--cal-spacing-lg, 24px);

    /* Safe areas iOS */
    padding-top: max(var(--cal-spacing-lg, 24px), env(safe-area-inset-top));
    padding-bottom: max(var(--cal-spacing-lg, 24px), env(safe-area-inset-bottom));
    padding-left: max(var(--cal-spacing-lg, 24px), env(safe-area-inset-left));
    padding-right: max(var(--cal-spacing-lg, 24px), env(safe-area-inset-right));

    /* Animation d'apparition */
    opacity: 0;
    animation: crowdaa-fadeIn 0.3s ease forwards;

    /* GPU acceleration */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes crowdaa-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ================================================================
   2. MODAL CONTAINER - Carte centrée
   ================================================================ */

.crowdaa-success-modal {
    background: white;
    border-radius: var(--cal-radius-xl, 24px);
    box-shadow: var(--cal-shadow-2xl, 0 20px 60px rgba(0, 0, 0, 0.3));
    max-width: 480px;
    width: 100%;
    padding: var(--cal-spacing-2xl, 48px) var(--cal-spacing-xl, 32px);
    text-align: center;
    position: relative;

    /* Animation d'apparition */
    opacity: 0;
    transform: translateY(30px) scale(0.95) translate3d(0, 0, 0);
    animation: crowdaa-slideUp 0.4s ease 0.1s forwards;

    /* GPU acceleration */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@keyframes crowdaa-slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95) translate3d(0, 0, 0);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) translate3d(0, 0, 0);
    }
}

/* Mobile ajustements */
@media (max-width: 480px) {
    .crowdaa-success-modal {
        padding: var(--cal-spacing-xl, 32px) var(--cal-spacing-lg, 24px);
        max-width: 100%;
    }
}

/* ================================================================
   3. ICÔNE / EMOJI - 80px standard
   ================================================================ */

.crowdaa-success-icon {
    font-size: 80px;
    line-height: 1;
    margin-bottom: var(--cal-spacing-lg, 24px);

    /* Animation de pop */
    opacity: 0;
    transform: scale(0) translate3d(0, 0, 0);
    animation: crowdaa-iconPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s forwards;
}

@keyframes crowdaa-iconPop {
    0% {
        opacity: 0;
        transform: scale(0) translate3d(0, 0, 0);
    }
    50% {
        transform: scale(1.1) translate3d(0, 0, 0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translate3d(0, 0, 0);
    }
}

/* ================================================================
   4. TITRE - 28px bold
   ================================================================ */

.crowdaa-success-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--cal-text, #2B3674);
    margin-bottom: var(--cal-spacing-md, 16px);
    line-height: var(--cal-line-height-tight, 1.2);
}

/* Mobile ajustements */
@media (max-width: 480px) {
    .crowdaa-success-title {
        font-size: 24px;
    }
}

/* ================================================================
   5. MESSAGE - 16px
   ================================================================ */

.crowdaa-success-message {
    font-size: 16px;
    color: var(--cal-text-muted, #6B7280);
    line-height: var(--cal-line-height-relaxed, 1.75);
    margin-bottom: var(--cal-spacing-xl, 32px);
}

/* Points gagnés - Mise en évidence */
.crowdaa-success-points {
    display: inline-block;
    background: linear-gradient(135deg, var(--cal-primary, #667eea) 0%, var(--cal-secondary, #764ba2) 100%);
    color: white;
    padding: var(--cal-spacing-xs, 8px) var(--cal-spacing-md, 16px);
    border-radius: var(--cal-radius-full, 9999px);
    font-weight: 700;
    font-size: 18px;
    margin: var(--cal-spacing-md, 16px) 0;
    box-shadow: var(--cal-shadow-md, 0 2px 10px rgba(0, 0, 0, 0.1));
}

/* ================================================================
   6. BOUTON DE FERMETURE
   ================================================================ */

.crowdaa-success-close {
    background: linear-gradient(135deg, var(--cal-primary, #667eea) 0%, var(--cal-secondary, #764ba2) 100%);
    color: white;
    border: none;
    border-radius: var(--cal-radius-md, 12px);
    padding: var(--cal-spacing-md, 16px) var(--cal-spacing-xl, 32px);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--cal-transition-base, 0.3s);
    box-shadow: var(--cal-shadow-md, 0 2px 10px rgba(0, 0, 0, 0.1));

    /* Touch */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;

    /* Minimum touch target */
    min-width: 44px;
    min-height: 44px;
}

/* Hover pour devices avec souris */
@media (hover: hover) {
    .crowdaa-success-close:hover {
        transform: translateY(-2px) translate3d(0, 0, 0);
        box-shadow: var(--cal-shadow-lg, 0 4px 20px rgba(79, 91, 213, 0.1));
    }
}

/* Touch feedback */
.crowdaa-success-close:active {
    transform: translateY(0) scale(0.98) translate3d(0, 0, 0);
}

/* ================================================================
   7. TIMER DE FERMETURE AUTOMATIQUE
   ================================================================ */

.crowdaa-success-timer {
    font-size: 14px;
    color: var(--cal-text-light, #A3AED0);
    margin-top: var(--cal-spacing-md, 16px);
    opacity: 0.8;
}

/* ================================================================
   8. VARIANTES - Succès, Erreur, Info
   ================================================================ */

/* Succès (par défaut) */
.crowdaa-success-modal.success .crowdaa-success-icon {
    color: var(--cal-success, #7ED957);
}

/* Erreur */
.crowdaa-success-modal.error .crowdaa-success-icon {
    color: var(--cal-danger, #ff4757);
}

.crowdaa-success-modal.error .crowdaa-success-close {
    background: var(--cal-danger, #ff4757);
}

/* Info */
.crowdaa-success-modal.info .crowdaa-success-icon {
    color: var(--cal-primary, #667eea);
}

/* ================================================================
   9. CONFETTI CONTAINER (optionnel)
   ================================================================ */

.crowdaa-confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--cal-z-modal, 10000);
    overflow: hidden;
}

/* ================================================================
   10. ANIMATIONS DE SORTIE
   ================================================================ */

.crowdaa-success-overlay.closing {
    animation: crowdaa-fadeOut 0.3s ease forwards;
}

@keyframes crowdaa-fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.crowdaa-success-modal.closing {
    animation: crowdaa-slideDown 0.3s ease forwards;
}

@keyframes crowdaa-slideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1) translate3d(0, 0, 0);
    }
    to {
        opacity: 0;
        transform: translateY(30px) scale(0.95) translate3d(0, 0, 0);
    }
}

/* ================================================================
   11. ACCESSIBILITY
   ================================================================ */

/* Focus visible pour navigation clavier */
.crowdaa-success-close:focus-visible {
    outline: 3px solid var(--cal-primary, #667eea);
    outline-offset: 3px;
}

/* Réduire les animations si préférence utilisateur */
@media (prefers-reduced-motion: reduce) {
    .crowdaa-success-overlay,
    .crowdaa-success-modal,
    .crowdaa-success-icon,
    .crowdaa-success-close {
        animation: none !important;
        transition: none !important;
    }
}

/* ================================================================
   12. QUIZ RESULTS EXTENSIONS (v4.5.0)
   Styles spécifiques pour l'écran de résultats Quiz/Blindtest/Rebus
   ================================================================ */

/* Quiz Results Overlay - Hérite des styles de base */
.quiz-results-overlay .quiz-results-content {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Score Banner - Affichage des résultats */
.quiz-results-content .score-banner {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, var(--cal-primary, #667eea) 0%, var(--cal-secondary, #764ba2) 100%);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.quiz-results-content .score-item {
    text-align: center;
    color: white;
}

.quiz-results-content .score-label {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quiz-results-content .score-value {
    font-size: 32px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Quiz Answers Recap - Liste des réponses */
.quiz-results-content .quiz-answers-recap {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

.quiz-results-content .quiz-answers-recap h4 {
    margin-top: 0;
    color: var(--crowdaa-dark-blue, #2B3674);
    font-size: 14px;
}

/* Responsive mobile */
@media (max-width: 768px) {
    .quiz-results-overlay .quiz-results-content {
        max-width: 95%;
        max-height: 85vh;
    }

    .quiz-results-content .score-banner {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .quiz-results-content .score-value {
        font-size: 28px;
    }
}
