/* Advanced Scroll to Top Button with Progress Indicator */

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: scale(0) rotate(-180deg);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 
        0 8px 25px rgba(40, 167, 69, 0.4),
        0 4px 10px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.scroll-to-top::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scroll-to-top:hover::before {
    opacity: 1;
}

/* Progress Circle */
.scroll-to-top::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px;
    height: 70px;
    transform: translate(-50%, -50%) rotate(-90deg);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    transition: all 0.3s ease;
}

/* Icon inside button */
.scroll-to-top i {
    position: relative;
    z-index: 2;
    color: white;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

/* Visible state */
.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) rotate(0deg);
}

/* Hover effects */
.scroll-to-top:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 
        0 12px 35px rgba(40, 167, 69, 0.5),
        0 6px 15px rgba(40, 167, 69, 0.5);
}

.scroll-to-top:hover i {
    transform: translateY(-3px);
    animation: bounceUp 0.6s ease infinite;
}

/* Active/Click effect */
.scroll-to-top:active {
    transform: scale(0.95);
    box-shadow: 
        0 4px 15px rgba(40, 167, 69, 0.3),
        0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Pulse animation when first appearing */
.scroll-to-top.visible {
    animation: pulseIn 0.6s ease-out;
}

@keyframes pulseIn {
    0% {
        transform: scale(0) rotate(-180deg);
    }
    50% {
        transform: scale(1.15) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* Bounce animation for icon */
@keyframes bounceUp {
    0%, 100% {
        transform: translateY(-3px);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* Progress indicator animation */
.scroll-to-top.scrolling::after {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: translate(-50%, -50%) rotate(-90deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(270deg);
    }
}

/* Ripple effect on click */
.scroll-to-top .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .scroll-to-top {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
    }
    
    .scroll-to-top::after {
        width: 60px;
        height: 60px;
    }
    
    .scroll-to-top i {
        font-size: 1.25rem;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .scroll-to-top {
        width: 55px;
        height: 55px;
        bottom: 25px;
        right: 25px;
    }
}

/* Extra small mobile */
@media (max-width: 480px) {
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: 15px;
        right: 15px;
    }
    
    .scroll-to-top::after {
        width: 55px;
        height: 55px;
        border-width: 2px;
    }
    
    .scroll-to-top i {
        font-size: 1.1rem;
    }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .scroll-to-top,
    .scroll-to-top i,
    .scroll-to-top::before,
    .scroll-to-top::after {
        animation: none !important;
        transition: opacity 0.2s ease, visibility 0.2s ease !important;
    }
    
    .scroll-to-top:hover {
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .scroll-to-top {
        background: linear-gradient(135deg, #20c997 0%, #28a745 100%);
        box-shadow: 
            0 8px 25px rgba(32, 201, 151, 0.4),
            0 4px 10px rgba(0, 0, 0, 0.3);
    }
}

/* Print - hide button */
@media print {
    .scroll-to-top {
        display: none !important;
    }
}

/* Additional states */
.scroll-to-top.loading {
    pointer-events: none;
    opacity: 0.7;
}

.scroll-to-top.loading::after {
    animation: rotate 0.8s linear infinite;
}

/* Tooltip on hover (optional) */
.scroll-to-top[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.875rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.scroll-to-top[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Glow effect on scroll */
.scroll-to-top.glow {
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 
            0 8px 25px rgba(40, 167, 69, 0.4),
            0 4px 10px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 
            0 8px 35px rgba(40, 167, 69, 0.6),
            0 4px 15px rgba(0, 0, 0, 0.3),
            0 0 30px rgba(40, 167, 69, 0.4);
    }
}
