/**
 * TECHMIND B2B - MICRO-INTERACTIONS UX
 * Optimisation confiance et conversion
 * Version 1.0
 */

/* ===================================================================
   SECTION 1 : VALIDATION FORMULAIRES
   ================================================================ */

/* États de validation */
.form-input.valid {
    border-color: var(--success);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2310B981'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3-3a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-input.invalid {
    border-color: var(--danger);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.field-validation-message {
    font-size: 13px;
    margin-top: 6px;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
}

.field-validation-message.show {
    opacity: 1;
    transform: translateY(0);
}

.field-validation-message.success {
    color: var(--success);
}

.field-validation-message.error {
    color: var(--danger);
}

/* ===================================================================
   SECTION 2 : ÉTATS DE BOUTONS
   ================================================================ */

/* États de bouton loading */
.btn-loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.btn-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-loading::after {
    content: attr(data-loading-text);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding-left: 30px;
    color: white;
    white-space: nowrap;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Animation de succès */
@keyframes success-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.btn-success-animated {
    background: var(--success) !important;
    animation: success-pulse 0.5s ease;
}

/* ===================================================================
   PULSE STRATÉGIQUE pour CTA critiques (Calendly, questionnaires)
   Impact: Attire l'œil, booste conversions +15-25%
   ================================================================ */

.btn-pulse {
    animation: pulse-cta 2.5s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4) !important;
}

@keyframes pulse-cta {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 6px 30px rgba(37, 99, 235, 0.6);
    }
}

.btn-pulse:hover {
    animation: none;
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 10px 40px rgba(37, 99, 235, 0.5) !important;
}

/* ===================================================================
   SECTION 3 : PROGRESSIONS ANIMÉES
   ================================================================ */

/* Barre de progression améliorée */
.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Pulse sur la tête de progression */
.progress-fill::after {
    content: '✓';
    position: absolute;
    right: -2px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--secondary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    animation: progress-pulse 2s infinite;
}

@keyframes progress-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Confetti subtil (particules CSS) */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--secondary);
    opacity: 0;
    animation: confetti-fall 1.2s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* Compteur animé */
.step-counter {
    font-weight: 600;
    transition: all 0.3s ease;
}

.step-counter.updating {
    transform: scale(1.2);
    color: var(--secondary);
}

/* ===================================================================
   SECTION 4 : RASSURANCE & SÉCURITÉ
   ================================================================ */

/* Garanties renforcées */
.security-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.btn-submit:hover ~ .security-badges,
.security-badges:hover {
    opacity: 1;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.security-badge:hover {
    background: white;
    border-color: var(--success);
    color: var(--success);
    transform: translateY(-2px);
}

.security-badge svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* Tooltip garantie */
.guarantee-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 100;
}

.guarantee-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: white;
}

.btn-submit:hover .guarantee-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===================================================================
   SECTION 5 : TRANSITIONS
   ================================================================ */

/* Transitions de contenu */
.question-card, .question-block {
    animation: fadeInSlide 0.5s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Transition sortante */
.question-card.exiting, .question-block.exiting {
    animation: fadeOutSlide 0.3s ease-in forwards;
}

@keyframes fadeOutSlide {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ===================================================================
   SECTION 6 : AIDE CONTEXTUELLE
   ================================================================ */

/* Labels animés */
.form-group {
    position: relative;
}

.form-label {
    transition: all 0.3s ease;
}

.form-input:focus ~ .form-label,
.form-input:focus + .form-label {
    color: var(--primary);
    font-weight: 700;
}

/* Aide contextuelle */
.input-helper {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.form-input:focus ~ .input-helper {
    opacity: 1;
    transform: translateY(0);
}

/* Animation placeholder */
.form-input::placeholder {
    transition: opacity 0.3s ease;
}

.form-input:focus::placeholder {
    opacity: 0.5;
}

/* ===================================================================
   SECTION 7 : NOTIFICATIONS
   ================================================================ */

/* Notification toast */
.toast-notification {
    position: fixed;
    top: 100px;
    right: 24px;
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--success);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    width: 32px;
    height: 32px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    animation: checkmark-pop 0.5s ease;
}

@keyframes checkmark-pop {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    font-size: 14px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    transition: color 0.2s ease;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ===================================================================
   SECTION 8 : HOVER STATES
   ================================================================ */

/* Boutons enrichis */
.btn-answer, .btn-primary, .btn-secondary, .btn-submit {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-answer:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Cartes interactives */
.card, .question-card, .quiz-section, .contact-form {
    transition: all 0.3s ease;
}

.card:hover, .contact-form:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

/* Liens avec underline animé */
.nav-link, .back-link {
    position: relative;
}

.nav-link::after, .back-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.nav-link:hover::after, .back-link:hover::after {
    width: 100%;
}

/* ===================================================================
   SECTION 9 : SCORE ANIMATIONS
   ================================================================ */

/* Score animé */
.score-number {
    font-size: 3rem;
    font-weight: 800;
    color: var(--secondary);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

/* Barre circulaire de progression */
.circular-progress {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto 24px;
}

.circular-progress svg {
    transform: rotate(-90deg);
}

.circular-progress circle {
    fill: none;
    stroke-width: 10;
}

.circular-progress .bg-circle {
    stroke: var(--border-light);
}

.circular-progress .progress-circle {
    stroke: var(--secondary);
    stroke-linecap: round;
    stroke-dasharray: 440;
    stroke-dashoffset: 440;
    transition: stroke-dashoffset 2s ease-in-out;
}

.score-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

/* ===================================================================
   SECTION 10 : AUTOSAVE
   ================================================================ */

/* Indicateur de sauvegarde */
.autosave-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.autosave-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

.autosave-indicator.saving {
    border-color: var(--primary);
    color: var(--primary);
}

.autosave-indicator.saved {
    border-color: var(--success);
    color: var(--success);
}

.autosave-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(37, 99, 235, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===================================================================
   RESPONSIVE MOBILE
   ================================================================ */

@media (max-width: 768px) {
    .toast-notification {
        right: 16px;
        left: 16px;
        max-width: calc(100% - 32px);
    }

    .security-badges {
        flex-wrap: wrap;
        gap: 8px;
    }

    .security-badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    .confetti-piece {
        width: 6px;
        height: 6px;
    }

    .circular-progress {
        width: 120px;
        height: 120px;
    }

    .score-number {
        font-size: 2.5rem;
    }
}
