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

.ui-split-view {
  // Core Structure
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  
  // Layout & Spacing
  gap: $semantic-spacing-component-xs;
  
  // Visual Design
  background: $semantic-color-surface;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-md;
  
  // Direction Variants
  &--horizontal {
    flex-direction: row;
  }
  
  &--vertical {
    flex-direction: column;
  }
  
  // Size Variants
  &--sm {
    min-height: $semantic-sizing-button-height-sm * 4; // Reasonable minimum for resizable panels
    gap: $semantic-spacing-component-xs;
  }
  
  &--md {
    min-height: $semantic-sizing-button-height-md * 6;
    gap: $semantic-spacing-component-sm;
  }
  
  &--lg {
    min-height: $semantic-sizing-button-height-lg * 8;
    gap: $semantic-spacing-component-md;
  }
  
  // Panel Element
  &__panel {
    position: relative;
    overflow: hidden;
    background: $semantic-color-surface-primary;
    border: $semantic-border-width-1 solid $semantic-color-border-secondary;
    border-radius: $semantic-border-radius-sm;
    
    // 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;
    
    // Transitions
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
    
    // Panel Content
    &-content {
      padding: $semantic-spacing-component-md;
      height: 100%;
      overflow: auto;
    }
    
    // Panel States
    &--primary {
      background: $semantic-color-surface-primary;
      border-color: $semantic-color-border-primary;
    }
    
    &--secondary {
      background: $semantic-color-surface-secondary;
      border-color: $semantic-color-border-secondary;
    }
    
    &--elevated {
      background: $semantic-color-surface-elevated;
      box-shadow: $semantic-shadow-elevation-2;
    }
    
    &--collapsed {
      min-width: 0;
      min-height: 0;
      opacity: $semantic-opacity-subtle;
    }
  }
  
  // Resizer Handle
  &__resizer {
    position: relative;
    background: $semantic-color-surface-secondary;
    border: $semantic-border-width-1 solid $semantic-color-border-primary;
    cursor: col-resize;
    z-index: $semantic-z-index-dropdown;
    
    // Transitions
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
    
    // Horizontal Resizer (for vertical split)
    &--horizontal {
      min-height: 4px;
      cursor: row-resize;
      border-left: none;
      border-right: none;
      
      &:hover,
      &:focus-visible {
        background: $semantic-color-interactive-primary;
        min-height: 6px;
      }
      
      &:active {
        background: $semantic-color-primary;
        min-height: 8px;
      }
    }
    
    // Vertical Resizer (for horizontal split)
    &--vertical {
      min-width: 4px;
      cursor: col-resize;
      border-top: none;
      border-bottom: none;
      
      &:hover,
      &:focus-visible {
        background: $semantic-color-interactive-primary;
        min-width: 6px;
      }
      
      &:active {
        background: $semantic-color-primary;
        min-width: 8px;
      }
    }
    
    // Focus States
    &:focus-visible {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }
    
    // Disabled State
    &--disabled {
      cursor: not-allowed;
      opacity: $semantic-opacity-disabled;
      pointer-events: none;
    }
  }
  
  // Resizer Handle Visual Indicator
  &__resizer-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 4px;
    background: $semantic-color-text-tertiary;
    border-radius: $semantic-border-radius-sm;
    opacity: $semantic-opacity-hover;
    
    &::before,
    &::after {
      content: '';
      position: absolute;
      left: 0;
      width: 100%;
      height: 2px;
      background: $semantic-color-text-tertiary;
      border-radius: $semantic-border-radius-sm;
    }
    
    &::before {
      top: -4px;
    }
    
    &::after {
      bottom: -4px;
    }
    
    // Horizontal orientation
    .ui-split-view__resizer--horizontal & {
      width: 4px;
      height: 20px;
      
      &::before,
      &::after {
        top: 0;
        width: 2px;
        height: 100%;
      }
      
      &::before {
        left: -4px;
      }
      
      &::after {
        right: -4px;
        left: auto;
      }
    }
  }
  
  // State Variants
  &--disabled {
    opacity: $semantic-opacity-disabled;
    pointer-events: none;
  }
  
  &--resizing {
    user-select: none;
    
    .ui-split-view__panel {
      pointer-events: none;
    }
  }
  
  // Responsive Design
  @media (max-width: $semantic-breakpoint-md - 1) {
    gap: $semantic-spacing-component-xs;
    
    .ui-split-view__panel-content {
      padding: $semantic-spacing-component-sm;
    }
    
    .ui-split-view__resizer {
      &--vertical {
        min-width: 6px;
      }
      
      &--horizontal {
        min-height: 6px;
      }
    }
  }
  
  @media (max-width: $semantic-breakpoint-sm - 1) {
    // Stack vertically on small screens
    &--horizontal {
      flex-direction: column;
      
      .ui-split-view__resizer--vertical {
        cursor: row-resize;
        min-width: auto;
        min-height: 6px;
      }
    }
    
    .ui-split-view__panel-content {
      padding: $semantic-spacing-component-xs;
      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);
    }
  }
}