/* WooCommerce Milestone Rewards - Compact Frontend Styles */

.milestone-container {
    margin: 1.5em 0;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: visible; /* Changed from hidden to visible to allow tooltips */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 60px; /* Significantly reduced from previous height */
    isolation: isolate; /* Create stacking context for z-index management */
}

.milestone-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

.milestone-header {
    position: relative;
    z-index: 2;
    margin-bottom: 15px; /* Reduced from 30px */
}

.milestone-main-message {
    text-align: center;
    font-size: 1em; /* Reduced from 1.2em */
    margin: 0;
    color: #ffffff;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.3; /* Reduced from 1.4 */
}

.milestone-bar-wrapper {
    position: relative;
    width: 100%;
    height: 50px; /* Reduced from 80px */
    margin: 15px 0; /* Reduced from 30px */
    z-index: 2;
}

.milestone-bar-track {
    position: absolute;
    width: 100%;
    height: 8px; /* Reduced from 12px */
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px; /* Reduced from 6px */
    top: 50%;
    transform: translateY(-50%);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.milestone-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b 0%, #feca57 50%, #48cab2 100%);
    border-radius: 4px; /* Reduced from 6px */
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.4); /* Reduced from 20px */
}

.milestone-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.milestone-bar-glow {
    position: absolute;
    top: -2px; /* Reduced from -4px */
    left: 0;
    right: 0;
    bottom: -2px; /* Reduced from -4px */
    background: linear-gradient(90deg, #ff6b6b 0%, #feca57 50%, #48cab2 100%);
    border-radius: 6px; /* Reduced from 10px */
    opacity: 0.3;
    filter: blur(6px); /* Reduced from 8px */
    z-index: -1;
}

.milestone-current-position {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: left 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.milestone-current-position .milestone-icon {
    width: 30px; /* Reduced from 40px */
    height: 30px; /* Reduced from 40px */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.3); /* Reduced from 20px */
    animation: pulse 2s infinite;
}

.milestone-current-position .milestone-icon svg {
    width: 16px; /* Reduced from 20px */
    height: 16px; /* Reduced from 20px */
    fill: #ffffff;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.milestone-marker-group {
    position: absolute;
    top: 50%;
    transform: translateX(-50%);
    text-align: center;
    transition: all 0.3s ease;
}

.milestone-marker-group .milestone-icon {
    width: 28px; /* Reduced from 36px */
    height: 28px; /* Reduced from 36px */
    margin: 0 auto;
    border-radius: 6px; /* Reduced from 8px */
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1); /* Reduced from 12px */
}

.milestone-marker-group .milestone-icon svg {
    width: 14px; /* Reduced from 18px */
    height: 14px; /* Reduced from 18px */
    transition: all 0.3s ease;
}

/* Locked milestone */
.milestone-marker-group.locked .milestone-icon {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.milestone-marker-group.locked .milestone-icon svg {
    fill: rgba(255, 255, 255, 0.7);
}

/* Current milestone */
.milestone-marker-group.current .milestone-icon {
    background: linear-gradient(135deg, #feca57 0%, #ff9ff3 100%);
    border: 3px solid #ffffff;
    transform: translateY(-50%) scale(1.1);
    animation: glow 2s infinite alternate;
}

.milestone-marker-group.current .milestone-icon svg {
    fill: #ffffff;
}

@keyframes glow {
    0% { box-shadow: 0 4px 12px rgba(254, 202, 87, 0.4); }
    100% { box-shadow: 0 8px 25px rgba(254, 202, 87, 0.8); }
}

/* Unlocked milestone */
.milestone-marker-group.unlocked .milestone-icon {
    background: linear-gradient(135deg, #48cab2 0%, #2dd4bf 100%);
    border: 3px solid #ffffff;
    transform: translateY(-50%) scale(1.05);
}

.milestone-marker-group.unlocked .milestone-icon svg {
    fill: #ffffff;
}

.milestone-label {
    position: absolute;
    bottom: -35px; /* Reduced from -45px */
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.98); /* Increased opacity for better visibility */
    padding: 6px 10px; /* Reduced from 8px 12px */
    border-radius: 6px; /* Reduced from 8px */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25); /* Stronger shadow */
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    font-size: 0.8em; /* Added to make text smaller */
    z-index: 10000; /* Very high z-index to appear above stats */
    border: 1px solid rgba(255, 255, 255, 0.5); /* Add border for better visibility */
}

.milestone-marker-group:hover .milestone-label {
    opacity: 1;
    bottom: -30px; /* Reduced from -40px */
}

/* Prevent hover states when touch is active */
.milestone-marker-group.touch-active:hover .milestone-label {
    opacity: 0; /* Override hover when touch is active */
}

/* Ensure touch tooltips have priority */
.milestone-marker-group.touch-active .milestone-label.show-mobile {
    opacity: 1 !important;
}

.milestone-label .reward-text {
    display: block;
    font-weight: 700;
    font-size: 0.8em; /* Reduced from 0.85em */
    color: #2d3748;
    margin-bottom: 1px; /* Reduced from 2px */
}

.milestone-label .milestone-value {
    display: block;
    font-size: 0.7em; /* Reduced from 0.75em */
    color: #718096;
}

.milestone-label .unlocked-badge {
    display: block;
    font-size: 0.65em; /* Reduced from 0.7em */
    color: #48cab2;
    font-weight: 600;
    margin-top: 1px; /* Reduced from 2px */
}

.milestone-sparkle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #feca57;
    border-radius: 50%;
    animation: sparkle 1.5s infinite;
}

.sparkle-1 {
    top: -20px;
    left: -15px;
    animation-delay: 0s;
}

.sparkle-2 {
    top: -25px;
    right: -10px;
    animation-delay: 0.5s;
}

.sparkle-3 {
    bottom: -20px;
    left: -10px;
    animation-delay: 1s;
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
}

.milestone-stats {
    display: flex;
    justify-content: center;
    gap: 10px; /* Reduced from 15px */
    margin-top: 15px; /* Reduced from 20px */
    position: relative;
    z-index: 1; /* Lower z-index than milestone labels */
}

.stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px; /* Reduced from 8px 16px */
    border-radius: 6px; /* Reduced from 8px */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 70px; /* Reduced from 80px */
    font-size: 0.85em; /* Reduced from 0.9em */
}

.stat-item.active-discount {
    background: linear-gradient(135deg, #48cab2 0%, #2dd4bf 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 3px 8px rgba(72, 202, 178, 0.3); } /* Reduced from 12px */
    50% { box-shadow: 0 6px 20px rgba(72, 202, 178, 0.6); } /* Reduced from 25px */
}

.stat-label {
    display: block;
    font-size: 0.7em; /* Reduced from 0.75em */
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1px; /* Reduced from 2px */
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 0.9em; /* Reduced from 0.95em */
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Mobile responsiveness - Even more compact on mobile */
@media (max-width: 768px) {
    .milestone-container {
        padding: 15px 12px; /* Reduced from 20px 15px */
        margin: 1em 0; /* Reduced from 1.5em */
        min-height: 50px; /* Reduced from 60px */
    }
    
    .milestone-main-message {
        font-size: 0.9em; /* Reduced from 1em */
        line-height: 1.2;
    }
    
    .milestone-bar-wrapper {
        height: 40px; /* Reduced from 60px */
        margin: 10px 0; /* Reduced from 15px */
    }
    
    .milestone-bar-track {
        height: 6px; /* Reduced from 8px */
    }
    
    .milestone-marker-group .milestone-icon {
        width: 24px; /* Reduced from 28px */
        height: 24px; /* Reduced from 28px */
    }
    
    .milestone-marker-group .milestone-icon svg {
        width: 12px; /* Reduced from 14px */
        height: 12px; /* Reduced from 14px */
    }
    
    .milestone-current-position .milestone-icon {
        width: 26px; /* Reduced from 32px */
        height: 26px; /* Reduced from 32px */
    }
    
    .milestone-current-position .milestone-icon svg {
        width: 13px; /* Reduced from 16px */
        height: 13px; /* Reduced from 16px */
    }
    
    .milestone-stats {
        flex-direction: column;
        gap: 8px; /* Reduced from 10px */
        margin-top: 10px; /* Reduced from 15px */
    }
    
    .stat-item {
        min-width: auto;
        padding: 5px 10px; /* Reduced */
        font-size: 0.8em; /* Reduced */
    }
    
    .milestone-header {
        margin-bottom: 10px; /* Reduced from 15px */
    }
    
    /* Fix milestone label positioning on mobile */
    .milestone-label {
        bottom: -60px; /* Increased from -50px to clear stats completely */
        max-width: 200px; /* Limit width on mobile */
        font-size: 0.75em; /* Smaller text on mobile */
        z-index: 10001; /* Even higher on mobile */
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); /* Stronger shadow for better visibility */
        background: rgba(255, 255, 255, 0.98); /* More opaque background */
        border: 2px solid rgba(255, 255, 255, 0.8); /* Stronger border */
    }
    
    .milestone-marker-group:hover .milestone-label,
    .milestone-marker-group:active .milestone-label,
    .milestone-marker-group:focus .milestone-label {
        opacity: 1;
        bottom: -55px; /* Adjusted for mobile */
        transform: translateX(-50%) scale(0.95); /* Slightly smaller on mobile */
    }
    
    /* Alternative: Show labels above on mobile if there's overlap */
    .milestone-label-above {
        bottom: auto;
        top: -70px; /* Increased from -60px to clear content above */
    }
    
    .milestone-marker-group:hover .milestone-label-above {
        top: -65px; /* Adjusted accordingly */
    }
    
    /* Mobile-specific tooltip states */
    .milestone-label.show-mobile {
        opacity: 1 !important;
        pointer-events: auto;
        bottom: -55px; /* Clear the stats section */
        z-index: 10001; /* Highest priority */
        transition: opacity 0.3s ease, bottom 0.3s ease !important; /* Ensure smooth transitions */
    }
    
    .milestone-label.show-mobile.milestone-label-above {
        bottom: auto !important;
        top: -65px !important; /* Show well above the milestone bar */
    }
    
    /* Touch-friendly milestone markers on mobile */
    .milestone-marker-group {
        touch-action: manipulation;
        cursor: pointer;
    }
    
    .milestone-marker-group .milestone-icon {
        transition: transform 0.2s ease;
    }
    
    .milestone-marker-group:active .milestone-icon {
        transform: translateY(-50%) scale(1.1);
    }
    
    /* Prevent hover conflicts on touch devices */
    .milestone-marker-group.touch-active .milestone-label {
        transition: none; /* Disable transitions during touch interaction */
    }
    
    .milestone-marker-group.touch-active:hover .milestone-label:not(.show-mobile) {
        opacity: 0 !important; /* Completely disable hover when touch is active */
    }
}

/* Animation for cart updates */
.milestone-container.updating {
    opacity: 0.8;
    pointer-events: none;
}

.milestone-container.updating .milestone-bar-fill {
    animation: updating-pulse 1s infinite;
}

@keyframes updating-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}