/**
 * CORRECTIONS UX WIZARD - VERSION FINALE OPTIMISÉE
 * Hauteurs réduites + Navigation flux normal + Tous les fixes
 */

/* ============================================
   1. CARD ENGLOBANTE - Ancrage visuel
   ============================================ */
.wizard-card {
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin: 0 auto;
    max-width: 960px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Barre de couleur en haut (branding) */
.wizard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #5e2b8f 0%, #2c3e91 50%, #667eea 100%);
}

/* ============================================
   2. HEADER DU WIZARD
   ============================================ */
.wizard-header {
    text-align: center;
    padding: 3rem 2rem 2rem;
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
    border-bottom: 2px solid #f0f0f0;
}

.wizard-brand {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, #5e2b8f 0%, #2c3e91 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(44, 62, 145, 0.3);
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.wizard-brand i {
    font-size: 2.5rem;
    color: white;
}

.wizard-title {
    color: #2c3e91;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.wizard-subtitle {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
}

@keyframes bounceIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* ============================================
   3. CONTAINER - Hauteur réduite
   ============================================ */
.wizard-container {
    padding: 2rem 3rem 1rem;
    position: relative;
    min-height: auto;
}

/* ============================================
   4. ZONE DE CONTENU - Hauteur minimale réduite
   ============================================ */
.wizard-steps-wrapper {
    position: relative;
    min-height: 300px;
    margin-bottom: 0;
}

/* ============================================
   5. ÉTAPES - Affichage forcé avec largeur stable
   ============================================ */
.wizard-step {
    display: none;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    box-sizing: border-box;
}

.wizard-step.active,
.wizard-step.exiting {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
}

.wizard-step.active {
    opacity: 1;
    position: relative;
    pointer-events: auto;
    animation: fadeInSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.wizard-step.exiting {
    position: absolute;
    pointer-events: none;
    animation: fadeOutSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Navigation arrière */
.wizard-step.active.from-next {
    animation: fadeInSlideReverse 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.wizard-step.exiting.to-previous {
    animation: fadeOutSlideReverse 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Step content avec largeur contrôlée */
.wizard-step .step-content {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Choices containers avec max-width strict */
.wizard-step .choices-container {
    max-width: 600px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.wizard-step .choices-container.choices-vertical {
    max-width: 500px;
}

/* Choice cards sans flex-grow */
.wizard-step .choice-card {
    box-sizing: border-box;
    flex-shrink: 0;
}

/* Grid explicite pour éviter auto-sizing */
.wizard-step .choices-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.wizard-step .choices-container.choices-vertical {
    grid-template-columns: 1fr;
}

/* ============================================
   6. ANIMATIONS OPTIMISÉES
   ============================================ */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translate3d(30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeOutSlide {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
    to {
        opacity: 0;
        transform: translate3d(-30px, 0, 0);
    }
}

@keyframes fadeInSlideReverse {
    from {
        opacity: 0;
        transform: translate3d(-30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeOutSlideReverse {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
    to {
        opacity: 0;
        transform: translate3d(30px, 0, 0);
    }
}

/* Hardware acceleration */
.wizard-step {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   7. CONTENU DES ÉTAPES - Hauteur optimisée
   ============================================ */
.step-content {
    min-height: 250px;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ============================================
   8. NAVIGATION - Flux normal avec séparateur
   ============================================ */
.wizard-navigation {
    position: relative;
    background: white;
    padding: 1.5rem 0rem 2rem;
    border-top: 1px solid #e9ecef;
    box-shadow: none;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    border-radius: 0 0 24px 24px;
}

/* Alignement conditionnel */
.wizard-navigation:has(#btnPrevious[style*="display: none"]) {
    justify-content: flex-end;
}

.wizard-navigation .btn {
    flex-shrink: 0;
    min-width: 160px;
}

/* ============================================
   9. PROGRESS BAR - Intégrée dans le container
   ============================================ */
.wizard-progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wizard-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #5e2b8f 0%, #2c3e91 50%, #667eea 100%);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative;
    box-shadow: 0 2px 8px rgba(44, 62, 145, 0.4);
}

.wizard-progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-30px); }
    100% { transform: translateX(100px); }
}

.wizard-progress-text {
    color: #666;
    font-weight: 600;
    font-size: 0.95rem;
}

/* ============================================
   10. BOUTON RESET
   ============================================ */
#btnResetWizard {
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
}

#btnResetWizard:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
    transform: translateY(-2px);
}

/* ============================================
   11. FIX CONTENEURS QUESTIONS
   ============================================ */
.questions-utilisateur,
.questions-prestataire {
    position: relative;
}

/* ============================================
   12. AMÉLIORATION FEEDBACK VISUEL
   ============================================ */
.choice-card {
    position: relative;
    overflow: hidden;
}

.btn-check:checked + .choice-card::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: white;
    color: var(--primary-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes popIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Flash vert sur sélection */
@keyframes flashGreen {
    0%, 100% {
        box-shadow: 0 15px 40px rgba(44, 62, 145, 0.3);
    }
    50% {
        box-shadow: 0 15px 40px rgba(76, 175, 80, 0.6);
    }
}

.btn-check:checked + .choice-card {
    animation: flashGreen 0.6s ease;
}

/* ============================================
   13. SCROLL SMOOTH
   ============================================ */
html {
    scroll-behavior: smooth;
}

#questionnaire {
    scroll-margin-top: 100px;
}

.wizard-card {
    scroll-margin-top: 100px;
}

/* ============================================
   14. OFFSET POUR MESSAGE RÉSULTAT
   ============================================ */
#wizardResultMessage {
    margin-top: 1rem;
    margin-bottom: 0;
    border-radius: 12px;
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   15. LOADING STATE
   ============================================ */
.wizard-navigation .btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.wizard-navigation .btn.loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* ============================================
   16. RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 992px) {
    .wizard-card {
        border-radius: 20px;
        margin: 0 1rem;
    }
    
    .wizard-container {
        padding: 1.5rem 2rem 1rem;
    }
    
    .wizard-steps-wrapper {
        min-height: 280px;
    }
    
    .step-content {
        min-height: 230px;
        padding: 1.25rem 0;
    }
    
    .wizard-navigation {
        padding: 1.25rem 2rem 1.5rem;
    }
}

@media (max-width: 768px) {
    .wizard-card {
        border-radius: 16px;
        margin: 0 0.5rem;
    }
    
    .wizard-header {
        padding: 2rem 1.5rem 1.5rem;
    }
    
    .wizard-brand {
        width: 70px;
        height: 70px;
        margin-bottom: 1rem;
    }
    
    .wizard-brand i {
        font-size: 2rem;
    }
    
    .wizard-title {
        font-size: 1.6rem;
    }
    
    .wizard-subtitle {
        font-size: 1rem;
    }
    
    .wizard-container {
        padding: 1.5rem 1.5rem 1rem;
    }
    
    .wizard-steps-wrapper {
        min-height: 260px;
    }
    
    .step-content {
        min-height: 220px;
        padding: 1.25rem 0;
    }
    
    .wizard-navigation {
        padding: 1.25rem 2rem 1.5rem;
        flex-direction: column-reverse;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .wizard-navigation .btn {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 576px) {
    .wizard-card {
        border-radius: 12px;
        margin: 0;
    }
    
    .wizard-header {
        padding: 1.5rem 1rem 1rem;
    }
    
    .wizard-brand {
        width: 60px;
        height: 60px;
    }
    
    .wizard-brand i {
        font-size: 1.8rem;
    }
    
    .wizard-title {
        font-size: 1.4rem;
    }
    
    .wizard-subtitle {
        font-size: 0.95rem;
    }
    
    .wizard-container {
        padding: 1rem 1rem 0.75rem;
    }
    
    .wizard-steps-wrapper {
        min-height: 240px;
    }
    
    .step-content {
        min-height: 200px;
        padding: 1rem 0;
    }
    
    .wizard-navigation {
        padding: 1rem 1.5rem 1.25rem;
        margin-top: 1rem;
    }
    
    .wizard-progress-text {
        font-size: 0.85rem;
    }
    
    #btnResetWizard {
        font-size: 0.8rem;
        padding: 0.3rem 0.75rem;
    }
}

/* ============================================
   17. PRINT
   ============================================ */
@media print {
    .wizard-card::before,
    .wizard-header,
    .wizard-progress-bar,
    .wizard-navigation,
    .step-icon,
    #btnResetWizard {
        display: none !important;
    }
    
    .wizard-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .wizard-step {
        display: block !important;
        position: relative !important;
        opacity: 1 !important;
        page-break-inside: avoid;
    }
    
    .wizard-container {
        min-height: auto;
    }
}