/* ================================
   SCROLL TO TOP BUTTON
   ================================ */

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: var(--color-white);
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9999;
    box-shadow: 0 5px 20px rgba(0, 197, 142, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* RTL Support */
[dir="rtl"] .scroll-to-top {
    right: auto;
    left: 30px;
}

/* Show state */
.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Hover effect */
.scroll-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 30px rgba(0, 197, 142, 0.5);
    background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
}

/* Active state */
.scroll-to-top:active {
    transform: translateY(-2px) scale(1.05);
}

/* Icon animation on hover */
.scroll-to-top:hover i {
    animation: bounce-up 0.6s ease-in-out infinite;
}

@keyframes bounce-up {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Pulse animation */
.scroll-to-top::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: var(--color-primary);
    opacity: 0;
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Dark mode support */
body.dark-mode .scroll-to-top {
    background: linear-gradient(135deg, #00ff9d, #00b377);
    box-shadow: 0 5px 20px rgba(0, 255, 157, 0.3);
}

body.dark-mode .scroll-to-top:hover {
    box-shadow: 0 8px 30px rgba(0, 255, 157, 0.5);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
        font-size: 1rem;
    }
    
    [dir="rtl"] .scroll-to-top {
        right: auto;
        left: 20px;
    }
}

@media (max-width: 480px) {
    .scroll-to-top {
        width: 40px;
        height: 40px;
        bottom: 15px;
        right: 15px;
        font-size: 0.9rem;
    }
    
    [dir="rtl"] .scroll-to-top {
        right: auto;
        left: 15px;
    }
}

/* Accessibility */
.scroll-to-top:focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
}

.scroll-to-top:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .scroll-to-top {
        border: 2px solid var(--color-white);
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .scroll-to-top,
    .scroll-to-top::before,
    .scroll-to-top:hover i {
        animation: none;
        transition: opacity 0.3s ease;
    }
}
