/* Scroll to Top/Bottom Buttons Styles */

/* Ensure chat-section has relative positioning for proper button positioning */
.chat-section {
    position: relative;
}

.scroll-buttons-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 152px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    /* Will be positioned relative to chat-section parent */
}

.scroll-buttons-container.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.scroll-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease, opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 4px 16px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.scroll-button:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: scale(1.05);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 6px 20px rgba(0, 0, 0, 0.08);
}

.scroll-button:active {
    transform: scale(0.95);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

.scroll-button svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.scroll-button:hover svg {
    transform: translateY(-1px);
}

.scroll-to-top svg {
    transform: rotate(0deg);
}

.scroll-to-bottom svg {
    transform: rotate(0deg);
}

/* Dark theme support */
[data-theme="dark"] .scroll-button {
    background: rgba(45, 45, 45, 0.95);
    color: #ccc;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 4px 16px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .scroll-button:hover {
    background: rgba(60, 60, 60, 1);
    color: #fff;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Mobile optimizations - Hide scroll buttons completely on mobile */
@media screen and (max-width: 768px) {
    .scroll-buttons-container {
        display: none !important;
    }
}

/* Only show tooltips on devices that support hover */
@media (hover: none) {
    .scroll-button::after,
    .scroll-button::before {
        display: none !important;
    }
}

/* Very small screens */
@media screen and (max-width: 480px) {
    .scroll-buttons-container {
        left: 50%;
        transform: translateX(-50%);
        bottom: 90px;
    }
    
    .scroll-button {
        width: 44px;
        height: 44px;
    }
    
    .scroll-button svg {
        width: 12px;
        height: 12px;
    }
}

/* Hide when sidebar is expanded on mobile */
@media screen and (max-width: 768px) {
    .history-sidebar.expanded ~ .main-layout .scroll-buttons-container {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/* Scroll buttons automatically center within chat-section regardless of artifact state */
/* No special positioning needed since we use absolute positioning relative to chat-section */

/* Only hide on mobile fullscreen artifacts where they would interfere */
@media screen and (max-width: 768px) {
    .superAgent-artifact-popup.mobile-fullscreen ~ .scroll-buttons-container,
    .chat-artifact-wrapper.showing-artifact-mobile .scroll-buttons-container {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: all 0.2s ease;
    }
    
    /* Positioning is now automatic with absolute positioning relative to chat-section */
}

/* Animation for button appearance */
@keyframes slideInFromCenter {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Single animation for all states since positioning is now always centered */

.scroll-buttons-container.visible {
    animation: slideInFromCenter 0.3s ease-out;
}

/* Individual button animations with slight delay */
.scroll-button:nth-child(1) {
    transition-delay: 0ms;
}

.scroll-button:nth-child(2) {
    transition-delay: 50ms;
}

/* Smooth hide/show animations for individual buttons */
.scroll-button[style*="display: none"] {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.scroll-button[style*="display: flex"] {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Tooltip styles */
.scroll-button {
    position: relative;
}

.scroll-button::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.scroll-button::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.scroll-button:hover::after,
.scroll-button:hover::before,
.scroll-button:focus::after,
.scroll-button:focus::before {
    opacity: 1;
    visibility: visible;
}

/* Dark theme tooltips */
[data-theme="dark"] .scroll-button::after {
    background: rgba(60, 60, 60, 0.95);
    color: #fff;
}

[data-theme="dark"] .scroll-button::before {
    border-top-color: rgba(60, 60, 60, 0.95);
}

/* High contrast support */
@media (prefers-contrast: high) {
    .scroll-button {
        background: #ffffff;
        color: #000000;
        border: 2px solid #000000;
    }
    
    [data-theme="dark"] .scroll-button {
        background: #000000;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .scroll-button,
    .scroll-buttons-container,
    .scroll-button svg,
    .scroll-button::after,
    .scroll-button::before {
        transition: none;
        animation: none;
    }
    
    .scroll-button:hover {
        transform: none;
    }
    
    .scroll-button:active {
        transform: none;
    }
}