/**
 * DataGrid Scroll Helper Styles
 * Provides theme-aware styling for floating scroll buttons
 *
 * @version 1.0.0
 * @author MedPractice Development Team
 */

/* ============================================================================
   Scroll Button Container
   ============================================================================ */

.datagrid-scroll-buttons {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    transition: top 0.1s ease-out, right 0.1s ease-out;
    pointer-events: none;
}

/* Make buttons interactive while keeping container non-interactive */
.datagrid-scroll-buttons > * {
    pointer-events: auto;
}

/* ============================================================================
   Scroll Buttons
   ============================================================================ */

.scroll-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: var(--rz-border-radius);
    border: 1px solid var(--rz-border-color);
    background: var(--rz-panel-background-color);
    color: var(--rz-text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1),
                0 1px 2px rgba(0, 0, 0, 0.06);
    outline: none;
    padding: 0;
}

/* Hover state - use primary color */
.scroll-button:hover:not(.disabled):not(:disabled) {
    background: var(--rz-primary);
    color: var(--rz-primary-contrast);
    border-color: var(--rz-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15),
                0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Active/pressed state */
.scroll-button:active:not(.disabled):not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Disabled state */
.scroll-button.disabled,
.scroll-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--rz-panel-background-color);
    color: var(--rz-text-color);
    border-color: var(--rz-border-color);
}

/* Focus state for keyboard navigation */
.scroll-button:focus-visible {
    outline: 2px solid var(--rz-primary);
    outline-offset: 2px;
}

/* Icon styling */
.scroll-button i {
    font-size: 1rem;
    line-height: 1;
}

/* ============================================================================
   Grid Container Requirements
   ============================================================================ */

/* Ensure grid containers are positioned for absolute button placement */
.modern-data-grid {
    position: relative;
}

/* Alternative class for grids that need scroll helper */
.rz-data-grid.with-scroll-helper {
    position: relative;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

/* Larger buttons on touch devices */
@media (hover: none) and (pointer: coarse) {
    .scroll-button {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .datagrid-scroll-buttons {
        gap: 0.5rem;
        padding: 0.75rem;
    }
}

/* Smaller buttons on very small screens */
@media (max-width: 480px) {
    .scroll-button {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }

    .scroll-button i {
        font-size: 0.875rem;
    }

    .datagrid-scroll-buttons {
        padding: 0.375rem;
    }
}

/* ============================================================================
   Scrollbar Sentinel (visibility detector)
   ============================================================================ */

.scrollbar-sentinel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    opacity: 0;
    z-index: -1;
}

/* ============================================================================
   Dark Theme Adjustments
   ============================================================================ */

/* Add subtle glow effect in dark themes for better visibility */
@media (prefers-color-scheme: dark) {
    .scroll-button {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
                    0 1px 2px rgba(0, 0, 0, 0.2);
    }

    .scroll-button:hover:not(.disabled):not(:disabled) {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4),
                    0 2px 4px rgba(0, 0, 0, 0.3);
    }
}

/* ============================================================================
   Animation for button appearance
   ============================================================================ */

@keyframes fadeInSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.datagrid-scroll-buttons {
    animation: fadeInSlideDown 0.2s ease-out;
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
    .datagrid-scroll-buttons {
        display: none !important;
    }
}

/* ============================================================================
   Accessibility Helpers
   ============================================================================ */

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================================
   High Contrast Mode Support
   ============================================================================ */

@media (prefers-contrast: high) {
    .scroll-button {
        border-width: 2px;
    }

    .scroll-button:hover:not(.disabled):not(:disabled) {
        border-width: 2px;
        outline: 2px solid currentColor;
        outline-offset: 1px;
    }
}

/* ============================================================================
   Reduced Motion Support
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .scroll-button,
    .datagrid-scroll-buttons {
        transition: none;
        animation: none;
    }

    .scroll-button:hover:not(.disabled):not(:disabled) {
        transform: none;
    }

    .scroll-button:active:not(.disabled):not(:disabled) {
        transform: none;
    }
}
