/**
 * Styles pour le système unifié de gestion des crédits TCF
 * Version 2.0.0 - Badges colorés et popups modernes
 */

/* =================================================================
   BADGES DE CRÉDITS SUR LES BOUTONS
   ================================================================= */

.tcf-credits-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 2px 6px;
    margin-left: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    border-radius: 10px;
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

/* Badge ROUGE - Crédits épuisés */
.tcf-credits-badge.tcf-badge-red {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid #b91c1c;
    animation: pulse-red 2s infinite;
}

/* Badge ORANGE - Crédits faibles */
.tcf-credits-badge.tcf-badge-orange {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: 1px solid #c2410c;
    animation: pulse-orange 3s infinite;
}

/* Badge VERT - Crédits suffisants */
.tcf-credits-badge.tcf-badge-green {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1px solid #047857;
}

/* Animations de pulsation pour attirer l'attention */
@keyframes pulse-red {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.9; }
}

@keyframes pulse-orange {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.95; }
}

/* État hover des badges */
.tcf-credits-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Adaptation pour boutons désactivés */
.btn-correct.disabled .tcf-credits-badge,
.btn-correct.credits-disabled .tcf-credits-badge {
    opacity: 0.7;
    animation: none;
}

/* =================================================================
   POPUPS DE GESTION DES CRÉDITS
   ================================================================= */

.tcf-popup-overlay.tcf-credits-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tcf-popup-overlay.tcf-credits-popup.tcf-popup-show {
    opacity: 1;
    visibility: visible;
}

.tcf-popup-container {
    background: white;
    border-radius: 10px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.tcf-popup-show .tcf-popup-container {
    transform: scale(1) translateY(0);
}

/* En-tête de la popup */
.tcf-popup-header {
    display: flex;
    align-items: center;
    padding: 24px 24px 16px;
    /* border-bottom: 1px solid #e5e7eb; */
    position: relative;
}

.tcf-popup-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    margin-right: 16px;
    flex-shrink: 0;
}

.tcf-popup-no-credits .tcf-popup-icon {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.tcf-popup-low-credits .tcf-popup-icon {
    background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
    color: #d97706;
}

.tcf-popup-correction-confirmation .tcf-popup-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #2563eb;
}

.tcf-popup-anonymous .tcf-popup-icon {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #6b7280;
}

.tcf-popup-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    flex: 1;
}

.tcf-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6b7280;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tcf-popup-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Contenu de la popup */
.tcf-popup-content {
    padding: 0 24px 0;
}

.tcf-popup-message {
    font-size: 15px;
    font-weight: 400;
    color: #111827;
    margin: 0 0 12px;
    margin-top: 8px;
    line-height: 1.5;
}

.tcf-popup-details {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 20px;
    line-height: 1.6;
}

/* .tcf-popup-checkbox {
    margin-top: 20px;
} */

.tcf-popup-checkbox label {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
}

.tcf-popup-checkbox input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

/* Actions de la popup */
.tcf-popup-actions {
    display: flex;
    gap: 12px;
    padding: 20px 24px 24px;
    /* border-top: 1px solid #e5e7eb; */
}

.tcf-popup-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    text-align: center;
}

.tcf-popup-btn-secondary {
    background: #EEF2FF;
    color: #374151;
    border: 1px solid #EEF2FF;
}

.tcf-popup-btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.tcf-popup-btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: 1px solid #1e40af;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.tcf-popup-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

/* Variantes selon le type de popup */
.tcf-popup-no-credits .tcf-popup-btn-primary {
    background: #2563EB;
    border-color: #2563EB;
    flex: 2;
}

.tcf-popup-no-credits .tcf-popup-btn-primary:hover {
    background: #10b981;
    border-color: #10b981;
}

.tcf-credits-count {
    color: #2563EB;
    font-weight: 500;
}

.tcf-popup-low-credits .tcf-popup-btn-primary {
    background: #2563EB;
    border-color: #2563EB;
}

.tcf-popup-low-credits .tcf-popup-btn-primary:hover {
    background: #10b981;
    border-color: #10b981;
}

/* =================================================================
   NOTIFICATIONS DE SUCCÈS/ERREUR
   ================================================================= */

.tcf-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 999999;
    max-width: 400px;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.tcf-notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tcf-notification-success {
    border-left: 4px solid #10b981;
}

.tcf-notification-success .tcf-notification-content i {
    color: #10b981;
}

.tcf-notification-error {
    border-left: 4px solid #ef4444;
}

.tcf-notification-error .tcf-notification-content i {
    color: #ef4444;
}

.tcf-notification-content span {
    flex: 1;
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
}

.tcf-notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tcf-notification-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

/* =================================================================
   ÉTATS DES BOUTONS DE CORRECTION
   ================================================================= */

/* Boutons désactivés */
.btn-correct.disabled,
.btn-correct.credits-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
}

.btn-correct.disabled::after,
.btn-correct.credits-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.1) 0px,
        rgba(255, 255, 255, 0.1) 2px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
}

/* =================================================================
   BLOCAGE DU SCROLL QUAND POPUP OUVERTE
   ================================================================= */

body.tcf-popup-open {
    overflow: hidden;
    padding-right: 15px; /* Compenser la barre de scroll */
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */

@media (max-width: 640px) {
    .tcf-popup-container:has([data-lucide="alert-triangle"]) .tcf-popup-header h3 {
        font-size: 17px;
        margin-right: 20px;
    }
    .tcf-popup-header{
        gap: 10px;
    }
    .tcf-popup-container {
        max-width: 95%;
        margin: 0 auto;
    }
    
    .tcf-popup-header {
        padding: 20px 20px 12px;
    }
    
    .tcf-popup-content {
        padding: 0 20px 0px;
    }
    
    .tcf-popup-actions {
        padding: 16px 20px 20px;
        flex-direction: column-reverse;
    }
    
    .tcf-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        min-width: auto;
    }
    
    .tcf-credits-badge {
        font-size: 11px;
        min-width: 18px;
        height: 18px;
        margin-left: 6px;
    }
}

/* =================================================================
   AMÉLIORATIONS D'ACCESSIBILITÉ
   ================================================================= */

.tcf-popup-container:focus-within {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.tcf-popup-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Mode sombre (si supporté) */
@media (prefers-color-scheme: dark) {
    .tcf-popup-container {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .tcf-popup-header {
        border-bottom-color: #374151;
    }
    
    .tcf-popup-header h3 {
        color: #f9fafb;
    }
    
    .tcf-popup-message {
        color: #f9fafb;
    }
    
    .tcf-popup-details {
        color: #d1d5db;
    }
    
    .tcf-popup-actions {
        border-top-color: #374151;
    }
    
    .tcf-notification {
        background: #1f2937;
        color: #f9fafb;
    }
}

/* =================================================================
   INTÉGRATION AVEC LES STYLES EXISTANTS
   ================================================================= */

/* S'assurer que les badges fonctionnent avec les boutons existants */
.btn-download.btn-correct,
.btn-correct,
#btn-correct,
#btn-correct-mobile,
#btn-correct-again {
    position: relative;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Ajustements pour les anciens badges (compatibilité) */
.credits-badge,
.credits-badge-red,
.credits-badge-orange,
.credits-badge-green {
    display: none !important; /* Masquer les anciens badges */
}
