/**
 * Optimisations de performance pour Enjoy Star Web
 * Gestion de charge pour 100+ utilisateurs simultanés
 */

/* ===== OPTIMISATIONS D'IMAGES ===== */

/* Affichage simple des images */
.candidate-image img,
.candidate-image .candidate-img {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.candidate-image img:hover,
.candidate-image .candidate-img:hover {
    opacity: 0.9;
}

/* ===== CENTRAGE DES BOUTONS ===== */

/* Modal de paiement - centrage des boutons */
.payment-modal .modal-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    flex-wrap: wrap;
}

.payment-modal .btn {
    min-width: 120px;
    margin: 0.25rem;
}

/* Boutons Annuler/Confirmer centrés */
.payment-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.payment-actions .btn {
    min-width: 140px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.payment-actions .btn-cancel {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    border: none;
    color: white;
}

.payment-actions .btn-confirm {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    border: none;
    color: white;
}

.payment-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* ===== OPTIMISATIONS DE PERFORMANCE ===== */

/* Réduction des animations sur les appareils lents */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimisations pour les écrans tactiles */
@media (hover: none) and (pointer: coarse) {
    .candidate-card:hover .candidate-image img {
        transform: none;
    }
    
    .payment-actions .btn:hover {
        transform: none;
    }
}

/* ===== GESTION DE CHARGE ===== */

/* Indicateur de chargement */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #4ecdc4, #44a08d, #4ecdc4);
    background-size: 200% 100%;
    animation: loading 2s infinite;
    z-index: 9999;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton loading pour les candidats */
.candidate-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: 20px;
    height: 280px;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== OPTIMISATIONS RESPONSIVE ===== */

/* Optimisations pour mobile */
@media (max-width: 768px) {
    .payment-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .payment-actions .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .candidate-image {
        height: 200px;
    }
}

/* Optimisations pour tablette */
@media (min-width: 769px) and (max-width: 1024px) {
    .payment-actions .btn {
        min-width: 160px;
        padding: 1rem 2rem;
    }
}

/* ===== OPTIMISATIONS D'ACCESSIBILITÉ ===== */

/* Focus visible pour l'accessibilité */
.btn:focus,
.candidate-image-link:focus {
    outline: 2px solid #4ecdc4;
    outline-offset: 2px;
}

/* Contraste amélioré */
.candidate-image .vote-count,
.candidate-image .ranking-position {
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ===== OPTIMISATIONS DE MÉMOIRE ===== */

/* Réduction des reflows */
.candidate-card {
    contain: layout style paint;
}

.candidate-image {
    contain: layout style paint;
}

/* Optimisations GPU */
.candidate-image img,
.payment-actions .btn {
    will-change: transform;
    transform: translateZ(0);
}

/* ===== GESTION DES ERREURS ===== */

/* Messages d'erreur optimisés */
.error-message {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    color: #d63031;
}

.success-message {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    color: #2e7d32;
}

/* ===== OPTIMISATIONS DE RÉSEAU ===== */

/* Préchargement des ressources critiques */
.preload-critical {
    display: none;
}

/* Indicateur de connexion lente */
.slow-connection .candidate-image img {
    filter: blur(1px);
    transition: filter 0.3s ease;
}

.slow-connection .candidate-image img.loaded {
    filter: none;
}

/* ===== OPTIMISATIONS DE BASE DE DONNÉES ===== */

/* Indicateur de chargement des données */
.data-loading {
    opacity: 0.6;
    pointer-events: none;
}

.data-loaded {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

/* ===== OPTIMISATIONS DE SÉCURITÉ ===== */

/* Protection contre les clics multiples */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.processing {
    position: relative;
    color: transparent;
}

.btn.processing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
} 