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

.ui-transfer-list {
  display: flex;
  align-items: flex-start;
  gap: $semantic-spacing-component-lg;
  width: 100%;
  
  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);
  
  &--sm {
    gap: $semantic-spacing-component-sm;
    
    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);
  }
  
  &--lg {
    gap: $semantic-spacing-component-xl;
    
    font-family: map-get($semantic-typography-body-large, font-family);
    font-size: map-get($semantic-typography-body-large, font-size);
    font-weight: map-get($semantic-typography-body-large, font-weight);
    line-height: map-get($semantic-typography-body-large, line-height);
  }
  
  &--disabled {
    opacity: $semantic-opacity-disabled;
    pointer-events: none;
  }

  // Transfer List Panel
  &__panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: $semantic-color-surface-primary;
    border: $semantic-border-width-1 solid $semantic-color-border-primary;
    border-radius: $semantic-border-card-radius;
    box-shadow: $semantic-shadow-elevation-1;
    min-width: 0;

    &--source {
      order: 1;
    }

    &--target {
      order: 3;
    }
  }

  // Panel Header
  &__header {
    padding: $semantic-spacing-component-md;
    border-bottom: $semantic-border-width-1 solid $semantic-color-border-secondary;
    background: $semantic-color-surface-secondary;
    border-radius: $semantic-border-card-radius $semantic-border-card-radius 0 0;
  }

  &__title {
    margin: 0 0 $semantic-spacing-component-sm 0;
    
    font-family: map-get($semantic-typography-heading-h4, font-family);
    font-size: map-get($semantic-typography-heading-h4, font-size);
    font-weight: map-get($semantic-typography-heading-h4, font-weight);
    line-height: map-get($semantic-typography-heading-h4, line-height);
    color: $semantic-color-text-primary;
  }

  // Search
  &__search {
    position: relative;
    margin-bottom: $semantic-spacing-component-sm;
  }

  &__search-icon {
    position: absolute;
    left: $semantic-spacing-interactive-input-padding-x;
    top: 50%;
    transform: translateY(-50%);
    color: $semantic-color-text-tertiary;
    z-index: 1;
  }

  &__search-input {
    width: 100%;
    height: $semantic-sizing-input-height-md;
    padding: $semantic-spacing-interactive-input-padding-y 
             calc($semantic-spacing-interactive-input-padding-x * 3)
             $semantic-spacing-interactive-input-padding-y
             calc($semantic-spacing-interactive-input-padding-x * 2.5);
    box-sizing: border-box;
    
    background: $semantic-color-surface-primary;
    border: $semantic-border-width-1 solid $semantic-color-border-primary;
    border-radius: $semantic-border-input-radius;
    
    font-family: map-get($semantic-typography-input, font-family);
    font-size: map-get($semantic-typography-input, font-size);
    font-weight: map-get($semantic-typography-input, font-weight);
    line-height: map-get($semantic-typography-input, line-height);
    color: $semantic-color-text-primary;
    
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;

    &::placeholder {
      color: $semantic-color-text-tertiary;
    }

    &:focus {
      outline: none;
      border-color: $semantic-color-border-focus;
      box-shadow: 0 0 0 2px $semantic-color-focus;
    }

    &:disabled {
      background: $semantic-color-surface-secondary;
      color: $semantic-color-text-disabled;
      cursor: not-allowed;
    }
  }

  &__search-clear {
    position: absolute;
    right: $semantic-spacing-interactive-input-padding-x;
    top: 50%;
    transform: translateY(-50%);
    
    width: $semantic-sizing-touch-minimum;
    height: $semantic-sizing-touch-minimum;
    padding: 0;
    
    background: transparent;
    border: none;
    border-radius: $semantic-border-radius-sm;
    
    color: $semantic-color-text-secondary;
    cursor: pointer;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;

    &:hover:not(:disabled) {
      background: $semantic-color-surface-secondary;
      color: $semantic-color-text-primary;
    }

    &:focus {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }

    &:disabled {
      color: $semantic-color-text-disabled;
      cursor: not-allowed;
    }
  }

  // Select All
  &__select-all {
    display: flex;
    align-items: center;
    gap: $semantic-spacing-component-xs;
    cursor: pointer;
    
    font-family: map-get($semantic-typography-label, font-family);
    font-size: map-get($semantic-typography-label, font-size);
    font-weight: map-get($semantic-typography-label, font-weight);
    line-height: map-get($semantic-typography-label, line-height);
    color: $semantic-color-text-secondary;

    input[type="checkbox"] {
      margin: 0;
    }

    &:hover {
      color: $semantic-color-text-primary;
    }
  }

  // List Container
  &__list-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  &__list {
    flex: 1;
    overflow-y: auto;
    padding: $semantic-spacing-component-xs;
    min-height: 200px;
    max-height: 400px;

    &:focus {
      outline: 2px solid $semantic-color-focus;
      outline-offset: -2px;
    }
  }

  // List Items
  &__item {
    display: flex;
    align-items: center;
    gap: $semantic-spacing-component-xs;
    padding: $semantic-spacing-component-sm;
    margin-bottom: $semantic-spacing-component-xs;
    
    background: $semantic-color-surface-primary;
    border: $semantic-border-width-1 solid transparent;
    border-radius: $semantic-border-radius-sm;
    
    cursor: pointer;
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;

    &:last-child {
      margin-bottom: 0;
    }

    &:hover:not(&--disabled) {
      background: $semantic-color-surface-secondary;
      border-color: $semantic-color-border-secondary;
    }

    &:focus {
      outline: 2px solid $semantic-color-focus;
      outline-offset: -2px;
    }

    &--selected {
      background: $semantic-color-surface-elevated;
      border-color: $semantic-color-primary;
      color: $semantic-color-text-primary;
    }

    &--disabled {
      opacity: $semantic-opacity-disabled;
      cursor: not-allowed;
    }
  }

  &__checkbox {
    margin: 0;
    flex-shrink: 0;
  }

  &__item-label {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
  }

  &__empty {
    padding: $semantic-spacing-component-lg;
    text-align: center;
    color: $semantic-color-text-tertiary;
    
    font-family: map-get($semantic-typography-caption, font-family);
    font-size: map-get($semantic-typography-caption, font-size);
    font-weight: map-get($semantic-typography-caption, font-weight);
    line-height: map-get($semantic-typography-caption, line-height);
  }

  // Controls
  &__controls {
    order: 2;
    display: flex;
    flex-direction: column;
    gap: $semantic-spacing-component-sm;
    align-items: center;
    justify-content: center;
    padding: $semantic-spacing-component-md 0;
    flex-shrink: 0;
  }

  &__control-btn {
    width: $semantic-sizing-button-height-md;
    height: $semantic-sizing-button-height-md;
    padding: 0;
    
    background: $semantic-color-primary;
    border: $semantic-border-width-1 solid $semantic-color-primary;
    border-radius: $semantic-border-button-radius;
    
    color: $semantic-color-on-primary;
    cursor: pointer;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
    box-shadow: $semantic-shadow-button-rest;

    &:hover:not(:disabled) {
      box-shadow: $semantic-shadow-button-hover;
      transform: translateY(-1px);
    }

    &:focus {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }

    &:active:not(:disabled) {
      transform: translateY(0);
      box-shadow: $semantic-shadow-button-rest;
    }

    &:disabled {
      background: $semantic-color-surface-secondary;
      border-color: $semantic-color-border-secondary;
      color: $semantic-color-text-disabled;
      cursor: not-allowed;
      box-shadow: none;
    }
  }

  // Footer
  &__footer {
    padding: $semantic-spacing-component-sm $semantic-spacing-component-md;
    border-top: $semantic-border-width-1 solid $semantic-color-border-secondary;
    background: $semantic-color-surface-secondary;
    
    font-family: map-get($semantic-typography-caption, font-family);
    font-size: map-get($semantic-typography-caption, font-size);
    font-weight: map-get($semantic-typography-caption, font-weight);
    line-height: map-get($semantic-typography-caption, line-height);
    color: $semantic-color-text-secondary;
    
    text-align: center;
  }

  // Size Variants
  &--sm {
    .ui-transfer-list__panel {
      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);
    }

    .ui-transfer-list__header {
      padding: $semantic-spacing-component-sm;
    }

    .ui-transfer-list__title {
      font-family: map-get($semantic-typography-heading-h5, font-family);
      font-size: map-get($semantic-typography-heading-h5, font-size);
      font-weight: map-get($semantic-typography-heading-h5, font-weight);
      line-height: map-get($semantic-typography-heading-h5, line-height);
    }

    .ui-transfer-list__search-input {
      height: $semantic-sizing-input-height-sm;
    }

    .ui-transfer-list__item {
      padding: $semantic-spacing-component-xs;
    }

    .ui-transfer-list__control-btn {
      width: $semantic-sizing-button-height-sm;
      height: $semantic-sizing-button-height-sm;
    }

    .ui-transfer-list__footer {
      padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
    }
  }

  &--lg {
    .ui-transfer-list__panel {
      font-family: map-get($semantic-typography-body-large, font-family);
      font-size: map-get($semantic-typography-body-large, font-size);
      font-weight: map-get($semantic-typography-body-large, font-weight);
      line-height: map-get($semantic-typography-body-large, line-height);
    }

    .ui-transfer-list__header {
      padding: $semantic-spacing-component-lg;
    }

    .ui-transfer-list__title {
      font-family: map-get($semantic-typography-heading-h3, font-family);
      font-size: map-get($semantic-typography-heading-h3, font-size);
      font-weight: map-get($semantic-typography-heading-h3, font-weight);
      line-height: map-get($semantic-typography-heading-h3, line-height);
    }

    .ui-transfer-list__search-input {
      height: $semantic-sizing-input-height-lg;
    }

    .ui-transfer-list__item {
      padding: $semantic-spacing-component-md;
    }

    .ui-transfer-list__control-btn {
      width: $semantic-sizing-button-height-lg;
      height: $semantic-sizing-button-height-lg;
    }

    .ui-transfer-list__footer {
      padding: $semantic-spacing-component-md $semantic-spacing-component-lg;
    }
  }

  // Responsive Design
  @media (max-width: 768px) {
    flex-direction: column;
    gap: $semantic-spacing-component-md;

    .ui-transfer-list__controls {
      order: 2;
      flex-direction: row;
      padding: $semantic-spacing-component-sm;
    }

    .ui-transfer-list__panel {
      &--source {
        order: 1;
      }

      &--target {
        order: 3;
      }
    }

    .ui-transfer-list__list {
      max-height: 300px;
    }
  }

  @media (max-width: 480px) {
    gap: $semantic-spacing-component-sm;

    .ui-transfer-list__header {
      padding: $semantic-spacing-component-sm;
    }

    .ui-transfer-list__title {
      font-family: map-get($semantic-typography-heading-h5, font-family);
      font-size: map-get($semantic-typography-heading-h5, font-size);
      font-weight: map-get($semantic-typography-heading-h5, font-weight);
      line-height: map-get($semantic-typography-heading-h5, line-height);
    }

    .ui-transfer-list__search-input {
      height: $semantic-sizing-input-height-sm;
      padding: $semantic-spacing-interactive-input-padding-y 
               calc($semantic-spacing-interactive-input-padding-x * 2.5)
               $semantic-spacing-interactive-input-padding-y
               calc($semantic-spacing-interactive-input-padding-x * 2);
      box-sizing: border-box;
    }

    .ui-transfer-list__item {
      padding: $semantic-spacing-component-xs;
    }

    .ui-transfer-list__control-btn {
      width: $semantic-sizing-button-height-sm;
      height: $semantic-sizing-button-height-sm;
    }

    .ui-transfer-list__list {
      max-height: 250px;
      min-height: 150px;
    }
  }
}