@use 'ui-design-system/src/styles/semantic/index' as *;

.ui-scroll-container {
  // Core Structure
  display: flex;
  position: relative;
  flex-direction: column;
  
  // Layout & Spacing
  width: 100%;
  height: 100%;
  
  // Visual Design
  background: $semantic-color-surface-primary;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-md;
  
  // Base overflow behavior
  overflow: auto;
  
  // Smooth scrolling when enabled
  &--smooth {
    scroll-behavior: smooth;
  }
  
  // Direction Variants
  &--vertical {
    overflow-x: hidden;
    overflow-y: auto;
  }
  
  &--horizontal {
    overflow-y: hidden;
    overflow-x: auto;
    flex-direction: row;
  }
  
  &--both {
    overflow: auto;
  }
  
  // Scrollbar Visibility Variants
  &--scrollbar-auto {
    // Default behavior - scrollbars appear when needed
  }
  
  &--scrollbar-always {
    overflow: scroll;
  }
  
  &--scrollbar-never {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    
    &::-webkit-scrollbar {
      display: none; /* WebKit */
    }
  }
  
  // Custom Scrollbar Styling
  &:not(&--scrollbar-never) {
    scrollbar-width: thin;
    scrollbar-color: $semantic-color-border-secondary $semantic-color-surface-secondary;
    
    &::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }
    
    &::-webkit-scrollbar-track {
      background: $semantic-color-surface-secondary;
      border-radius: $semantic-border-radius-sm;
    }
    
    &::-webkit-scrollbar-thumb {
      background: $semantic-color-border-secondary;
      border-radius: $semantic-border-radius-sm;
      transition: background-color $semantic-motion-duration-fast $semantic-motion-easing-ease;
      
      &:hover {
        background: $semantic-color-border-primary;
      }
    }
    
    &::-webkit-scrollbar-corner {
      background: $semantic-color-surface-secondary;
    }
  }
  
  // Content Container
  &__content {
    flex: 1;
    position: relative;
    padding: $semantic-spacing-component-md;
    
    // Typography
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: map-get($semantic-typography-body-medium, font-weight);
    line-height: map-get($semantic-typography-body-medium, line-height);
    color: $semantic-color-text-primary;
  }
  
  // Virtual Scrolling Components
  &__virtual-spacer {
    position: relative;
    width: 100%;
  }
  
  &__virtual-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    will-change: transform;
  }
  
  &__virtual-item {
    display: flex;
    align-items: center;
    padding: $semantic-spacing-component-sm;
    border-bottom: $semantic-border-width-1 solid $semantic-color-border-subtle;
    
    // Typography
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: map-get($semantic-typography-body-medium, font-weight);
    line-height: map-get($semantic-typography-body-medium, line-height);
    color: $semantic-color-text-primary;
    
    &:last-child {
      border-bottom: none;
    }
  }
  
  // Scroll Indicators
  &__indicators {
    position: absolute;
    top: $semantic-spacing-component-sm;
    right: $semantic-spacing-component-sm;
    z-index: $semantic-z-index-tooltip;
    pointer-events: none;
  }
  
  &__indicator {
    width: 24px;
    height: 24px;
    border-radius: $semantic-border-radius-full;
    background: $semantic-color-surface-elevated;
    box-shadow: $semantic-shadow-elevation-2;
    margin-bottom: $semantic-spacing-component-xs;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: $semantic-opacity-subtle;
    transition: opacity $semantic-motion-duration-fast $semantic-motion-easing-ease;
    
    &--up::before {
      content: '↑';
      color: $semantic-color-text-primary;
      font-size: map-get($semantic-typography-body-small, font-size);
      font-weight: $semantic-typography-font-weight-bold;
    }
    
    &--down::before {
      content: '↓';
      color: $semantic-color-text-primary;
      font-size: map-get($semantic-typography-body-small, font-size);
      font-weight: $semantic-typography-font-weight-bold;
    }
    
    .ui-scroll-container:hover & {
      opacity: 1;
    }
  }
  
  // Focus States
  &:focus-visible {
    outline: 2px solid $semantic-color-focus;
    outline-offset: 2px;
  }
  
  // Responsive Design
  @media (max-width: $semantic-breakpoint-md - 1) {
    &__content {
      padding: $semantic-spacing-component-sm;
    }
    
    &__virtual-item {
      padding: $semantic-spacing-component-xs;
      
      // Smaller typography on mobile
      font-family: map-get($semantic-typography-body-small, font-family);
      font-size: map-get($semantic-typography-body-small, font-size);
      font-weight: map-get($semantic-typography-body-small, font-weight);
      line-height: map-get($semantic-typography-body-small, line-height);
    }
    
    &__indicators {
      top: $semantic-spacing-component-xs;
      right: $semantic-spacing-component-xs;
    }
    
    &__indicator {
      width: 20px;
      height: 20px;
      
      &--up::before,
      &--down::before {
        font-size: map-get($semantic-typography-body-small, font-size);
      }
    }
  }
  
  @media (max-width: $semantic-breakpoint-sm - 1) {
    &__content {
      padding: $semantic-spacing-component-xs;
    }
  }
  
  // Reduced Motion Support
  @media (prefers-reduced-motion: reduce) {
    &--smooth {
      scroll-behavior: auto;
    }
    
    &::-webkit-scrollbar-thumb,
    &__indicator {
      transition: none;
    }
  }
  
  // High Contrast Mode Support
  @media (prefers-contrast: high) {
    border-width: $semantic-border-width-2;
    
    &::-webkit-scrollbar-thumb {
      background: $semantic-color-border-primary;
    }
    
    &__indicator {
      border: $semantic-border-width-1 solid $semantic-color-border-primary;
    }
  }
}