/**
 * Section Navigation Widget Styles - Enhanced Version with Loading States - Fixed
 */

/* Base Container */
.metal-rouge-section-navigation-wrapper {
    position: relative;
    z-index: 999;
}

.metal-rouge-section-nav {
    position: fixed;
    z-index: 999;
    transform: translateY(-50%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Position Variants */
.metal-rouge-section-nav.position-left {
    left: 30px;
}

.metal-rouge-section-nav.position-right {
    right: 30px;
}

/* Auto Hide Functionality */
.metal-rouge-section-nav.auto-hide {
    opacity: 0.3;
    transform: translateY(-50%) scale(0.9);
}

.metal-rouge-section-nav.auto-hide:hover,
.metal-rouge-section-nav.auto-hide.show {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* Navigation List */
.section-nav-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
}

/* Progress Line Background - Dynamically calculated */
.section-nav-list::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, rgba(220, 38, 38, 0.2), rgba(220, 38, 38, 0.1));
    transform: translateX(-50%);
    z-index: 0;
    border-radius: 1px;
    transition: height 0.3s ease;
}

/* Dynamic Progress Indicator */
.section-nav-list .progress-indicator {
    position: absolute;
    top: 6px;
    left: 50%;
    width: 3px;
    height: 0;
    background: linear-gradient(to bottom, #dc2626, #f59e0b);
    transform: translateX(-50%);
    z-index: 1;
    border-radius: 2px;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

/* Navigation Items */
.section-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.section-nav-list > .section-nav-item:not(:last-of-type) {
    margin-bottom: 30px;
}

.section-nav-list > .section-nav-item:last-of-type {
    margin-bottom: 0 !important;
}

/* Navigation Dots */
.section-nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(220, 38, 38, 0.4);
    border: 2px solid rgba(220, 38, 38, 0.6);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Dot Inner Ring for Progress */
.section-nav-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

/* Hover States */
.section-nav-item:hover .section-nav-dot {
    background-color: rgba(220, 38, 38, 0.8);
    border-color: #dc2626;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.section-nav-item:hover .section-nav-dot::before {
    width: 4px;
    height: 4px;
    opacity: 0.8;
}

/* Active State */
.section-nav-item.active .section-nav-dot {
    background-color: #dc2626;
    border-color: #b91c1c;
    transform: scale(1.4);
    box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.3), 0 6px 12px rgba(0, 0, 0, 0.2);
    animation: activeGlow 2.5s infinite ease-in-out;
}

.section-nav-item.active .section-nav-dot::before {
    width: 4px;
    height: 4px;
    opacity: 1;
    animation: pulse 2s infinite;
}

/* Progress States for Completed Sections */
.section-nav-item.completed .section-nav-dot {
    background-color: #dc2626 !important;
    border-color: #b91c1c !important;
    opacity: 1 !important;
    transform: scale(1.2);
}

.section-nav-item.completed .section-nav-dot::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 8px;
    font-weight: bold;
    line-height: 1;
}

/* Transition State */
.section-nav-item.transitioning .section-nav-dot {
    animation: transitionPulse 0.6s ease-out;
}

@keyframes transitionPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.6);
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.2);
    }
    100% {
        transform: scale(1.4);
    }
}

/* Enhanced Animations */
@keyframes activeGlow {
    0%, 100% {
        box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.3), 0 6px 12px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.2), 0 8px 16px rgba(0, 0, 0, 0.15);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Tooltip Styles */
.section-nav-tooltip {
    position: absolute;
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Tooltip Positioning */
.position-right .section-nav-tooltip {
    right: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    margin-right: 10px;
}

.position-left .section-nav-tooltip {
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
    margin-left: 10px;
}

/* Tooltip Arrows */
.section-nav-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    border-style: solid;
    transform: translateY(-50%);
}

.position-right .section-nav-tooltip::after {
    left: 100%;
    border-width: 5px 0 5px 6px;
    border-color: transparent transparent transparent #333;
}

.position-left .section-nav-tooltip::after {
    right: 100%;
    border-width: 5px 6px 5px 0;
    border-color: transparent #333 transparent transparent;
}

/* Show Tooltip on Hover */
.section-nav-item:hover .section-nav-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* Smooth Scroll Indicator */
.section-nav-item.scrolling .section-nav-dot {
    background-color: #f59e0b;
    border-color: #d97706;
    animation: scroll-indicator 0.8s ease-in-out;
}

@keyframes scroll-indicator {
    0%, 100% {
        transform: scale(1.3);
    }
    50% {
        transform: scale(1.6);
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.3);
    }
}

/* LOADING STATES */
.metal-rouge-section-nav.loading {
    opacity: 0.7;
}

.section-nav-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loading-dot {
    width: 10px !important;
    height: 10px !important;
    background-color: rgba(220, 38, 38, 0.3) !important;
    border: 2px solid rgba(220, 38, 38, 0.5) !important;
    animation: loading-pulse 1.5s ease-in-out infinite !important;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ERROR STATE */
.section-nav-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.error-dot {
    width: 12px !important;
    height: 12px !important;
    background-color: rgba(239, 68, 68, 0.5) !important;
    border: 2px solid rgba(239, 68, 68, 0.7) !important;
    animation: error-blink 2s ease-in-out infinite !important;
}

@keyframes error-blink {
    0%, 50%, 100% {
        opacity: 0.5;
    }
    25%, 75% {
        opacity: 1;
    }
}

.section-nav-error .section-nav-tooltip {
    opacity: 1 !important;
    visibility: visible !important;
    position: static !important;
    transform: none !important;
    margin: 0 !important;
    background-color: rgba(239, 68, 68, 0.9) !important;
    font-size: 10px !important;
    padding: 4px 8px !important;
}

.section-nav-error .section-nav-tooltip::after {
    display: none !important;
}

/* SECTION NAME INDICATOR - Amélioré pour Mobile */
.section-name-indicator {
    position: fixed;
    /* Position par défaut: en haut avec safe area */
    top: max(20px, env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.95), rgba(185, 28, 28, 0.95));
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    box-shadow: 
        0 6px 24px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: min(85vw, 300px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Position alternative: au-dessus de la navigation */
.section-name-indicator.above-nav {
    top: auto;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(20px);
}

.section-name-indicator.above-nav.show {
    transform: translateX(-50%) translateY(0);
}

/* Position alternative: côté droit */
.section-name-indicator.side-right {
    top: 50%;
    left: auto;
    right: max(15px, env(safe-area-inset-right, 0px));
    transform: translateY(-50%) translateX(20px);
    max-width: min(40vw, 200px);
    font-size: 14px;
    padding: 10px 16px;
}

.section-name-indicator.side-right.show {
    transform: translateY(-50%) translateX(0);
}

/* Animation d'apparition améliorée */
.section-name-indicator.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    animation: improvedZeldaAppear 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animation de disparition améliorée */
.section-name-indicator.hide {
    opacity: 0;
    transform: translateX(-50%) translateY(-15px);
    animation: improvedZeldaDisappear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Keyframes pour les animations améliorées */
@keyframes improvedZeldaAppear {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-25px) scale(0.8);
        filter: blur(3px);
    }
    60% {
        opacity: 0.9;
        transform: translateX(-50%) translateY(3px) scale(1.02);
        filter: blur(0.5px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
        filter: blur(0px);
    }
}

@keyframes improvedZeldaDisappear {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
        filter: blur(0px);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-15px) scale(0.95);
        filter: blur(1px);
    }
}

/* Effet de brillance plus subtil */
.section-name-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transition: left 0.5s ease;
    border-radius: 10px;
}

.section-name-indicator.show::before {
    left: 100%;
}

/* Variante compacte pour très petits écrans */
@media (max-width: 360px) {
    .section-name-indicator {
        font-size: 14px;
        padding: 10px 16px;
        max-width: 90vw;
        border-radius: 8px;
    }
}

/* Masquer l'indicateur sur desktop */
@media (min-width: 769px) {
    .section-name-indicator {
        display: none !important;
    }
}

/* MOBILE RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .metal-rouge-section-nav {
        position: fixed !important;
        bottom: max(20px, env(safe-area-inset-bottom, 0px)) !important;
        left: 50% !important;
        right: unset !important;
        top: unset !important;
        transform: translateX(-50%) !important;
        padding: 12px 20px !important;
        border-radius: 25px !important;
        background-color: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(15px);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
    }
    
    .metal-rouge-section-nav.auto-hide {
        opacity: 0.8;
        transform: translateX(-50%) translateY(10px) !important;
    }
    
    .metal-rouge-section-nav.auto-hide:hover,
    .metal-rouge-section-nav.auto-hide.show {
        opacity: 1;
        transform: translateX(-50%) translateY(0) !important;
    }
    
    /* Horizontal Layout for Mobile */
    .section-nav-list {
        flex-direction: row !important;
        align-items: center;
        gap: 15px;
    }
    
    /* Horizontal Progress Line */
    .section-nav-list::before {
        top: 50% !important;
        left: 0px !important;
        width: 100% !important;
        height: 2px !important;
        transform: translateY(-50%) !important;
        background: linear-gradient(to right, rgba(220, 38, 38, 0.2), rgba(220, 38, 38, 0.1));
    }
    
    /* Horizontal Progress Indicator */
    .section-nav-list .progress-indicator {
        top: 50% !important;
        left: 3px !important;
        width: 0 !important;
        height: 3px !important;
        transform: translateY(-50%) !important;
        transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
        background: linear-gradient(to right, #dc2626, #f59e0b);
    }
    
    .section-nav-item {
        margin-bottom: 0 !important;
        margin-right: 0;
    }
    
    .section-nav-item:last-child {
        margin-right: 0;
    }
    
    /* Smaller dots for mobile */
    .section-nav-dot {
        width: 10px;
        height: 10px;
        border-width: 2px;
    }
    
    .section-nav-item:hover .section-nav-dot {
        transform: scale(1.4);
    }
    
    .section-nav-item.active .section-nav-dot {
        transform: scale(1.5);
    }
    
    /* Hide tooltips on mobile except for error state */
    .section-nav-tooltip {
        display: none !important;
    }
    
    .section-nav-error .section-nav-tooltip {
        display: block !important;
    }
    
    /* Loading state adjustments for mobile */
    .section-nav-loading {
        flex-direction: row !important;
        gap: 10px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .metal-rouge-section-nav {
        bottom: max(15px, env(safe-area-inset-bottom, 0px)) !important;
        padding: 10px 16px !important;
    }
    
    .section-nav-list {
        gap: 12px;
    }
    
    .section-nav-dot {
        width: 8px;
        height: 8px;
    }
    
    .section-nav-item:hover .section-nav-dot {
        transform: scale(1.3);
    }
    
    .section-nav-item.active .section-nav-dot {
        transform: scale(1.4);
    }
}

/* Tablet Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
    .metal-rouge-section-nav {
        transform: translateY(-50%) scale(0.9);
    }
    
    .metal-rouge-section-nav.position-left {
        left: 20px;
    }
    
    .metal-rouge-section-nav.position-right {
        right: 20px;
    }
    
    .section-nav-dot {
        width: 11px;
        height: 11px;
    }
    
    .section-nav-tooltip {
        font-size: 11px;
        padding: 7px 10px;
    }
}

/* Support for landscape mode on phones */
@media (max-width: 768px) and (orientation: landscape) {
    .section-name-indicator {
        font-size: 14px;
        padding: 8px 16px;
        top: max(10px, env(safe-area-inset-top, 0px));
    }
    
    .section-name-indicator.above-nav {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .metal-rouge-section-nav,
    .section-nav-dot,
    .section-nav-tooltip,
    .section-nav-item,
    .progress-indicator,
    .section-name-indicator {
        transition: none !important;
        animation: none !important;
    }
    
    .section-name-indicator.show {
        animation: none !important;
    }
    
    .section-name-indicator.hide {
        animation: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .section-nav-dot {
        border-width: 3px;
        background-color: #000;
        border-color: #fff;
    }
    
    .section-nav-item.active .section-nav-dot {
        background-color: #fff;
        border-color: #000;
    }
    
    .section-nav-tooltip {
        background-color: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .progress-indicator {
        background: #fff !important;
    }
    
    .section-name-indicator {
        background: #000 !important;
        color: #fff !important;
        border: 2px solid #fff;
    }
}

/* Focus States for Accessibility */
.section-nav-item:focus {
    outline: 2px solid #dc2626;
    outline-offset: 3px;
    border-radius: 50%;
}

.section-nav-item:focus .section-nav-dot {
    transform: scale(1.4);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.3);
}

/* Dark Mode Support */
/* @media (prefers-color-scheme: dark) {
    .metal-rouge-section-nav {
        background-color: rgba(31, 41, 55, 0.95) !important;
    }
    
    .section-nav-tooltip {
        background-color: rgba(0, 0, 0, 0.95);
        color: #fff;
    }
    
    .section-name-indicator {
        background: linear-gradient(135deg, rgba(31, 41, 55, 0.95), rgba(17, 24, 39, 0.95)) !important;
        box-shadow: 
            0 6px 24px rgba(0, 0, 0, 0.4),
            0 0 0 1px rgba(255, 255, 255, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    }
    
    @media (max-width: 768px) {
        .metal-rouge-section-nav {
            background-color: rgba(31, 41, 55, 0.95) !important;
        }
    }
} */

/* Enhanced Mobile Bottom Navigation */
@media (max-width: 768px) {
    .metal-rouge-section-nav {
        /* Ensure it doesn't interfere with bottom content */
        margin-bottom: env(safe-area-inset-bottom, 0);
    }
    
    /* Animation when section changes on mobile */
    .section-nav-item.active .section-nav-dot {
        animation: mobileActiveGlow 2s infinite ease-in-out;
    }
    
    @keyframes mobileActiveGlow {
        0%, 100% {
            box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
        }
        50% {
            box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.2);
        }
    }
}

/* Support pour les appareils avec des encoches/notches */
@supports (env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .section-name-indicator {
            /* Position sécurisée en tenant compte de l'encoche */
            top: max(20px, calc(env(safe-area-inset-top) + 10px));
        }
        
        .section-name-indicator.above-nav {
            bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px));
        }
        
        .metal-rouge-section-nav {
            bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px)) !important;
        }
    }
}