/* Back to Top Button Styles */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 100px; /* Position to the left of floating help */
    z-index: 999;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

.back-to-top:active {
    transform: translateY(-1px);
}

.back-to-top i {
    font-size: 18px;
    color: white;
    transition: all 0.3s ease;
}

.back-to-top:hover i {
    transform: translateY(-2px);
}

/* Pulse animation for attention */
.back-to-top::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    animation: backToTopPulse 2s infinite;
    opacity: 0;
}

.back-to-top.visible::before {
    opacity: 1;
}

@keyframes backToTopPulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Tooltip */
.back-to-top::after {
    content: 'Back to top';
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--glass-bg);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.back-to-top::before {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid var(--glass-bg);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.back-to-top:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(-5px);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 90px; /* Adjust for mobile floating help position */
        width: 45px;
        height: 45px;
    }
    
    .back-to-top i {
        font-size: 16px;
    }
    
    .back-to-top::after {
        display: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .back-to-top::before {
        animation: none;
    }
    
    .back-to-top:hover {
        transform: none;
    }
    
    .back-to-top:hover i {
        transform: none;
    }
}

/* Dark/Light theme adjustments */
[data-theme="light"] .back-to-top::after {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .back-to-top::before {
    border-left-color: rgba(255, 255, 255, 0.95);
}

/* Focus styles for accessibility */
.back-to-top:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.back-to-top:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .back-to-top {
        border: 2px solid var(--text-primary);
    }
    
    .back-to-top:hover {
        border-color: var(--primary-color);
    }
}
