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

.ui-tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  position: relative;
  
  // Layout & Spacing
  padding: $semantic-spacing-interactive-input-padding-y $semantic-spacing-interactive-input-padding-x;
  gap: $semantic-spacing-component-xs;
  min-height: $semantic-sizing-input-height-md;
  
  // Visual Design
  background: $semantic-color-surface-primary;
  border: $semantic-border-width-1 solid $semantic-color-border-primary;
  border-radius: $semantic-border-input-radius;
  
  // Typography
  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);
  
  // Transitions
  transition: border-color $semantic-motion-duration-fast $semantic-motion-easing-ease,
              box-shadow $semantic-motion-duration-fast $semantic-motion-easing-ease;
  
  // Size Variants
  &--sm {
    min-height: $semantic-sizing-input-height-sm;
    padding: $semantic-spacing-component-xs;
    gap: $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);
    
    .ui-tag-input__input {
      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);
    }
  }
  
  &--md {
    // Already defined above
  }
  
  &--lg {
    min-height: $semantic-sizing-input-height-lg;
    padding: $semantic-spacing-component-md;
    gap: $semantic-spacing-component-sm;
    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-tag-input__input {
      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);
    }
  }
  
  // Style Variants
  &--outlined {
    background: transparent;
    border-color: $semantic-color-border-primary;
  }
  
  &--filled {
    background: $semantic-color-surface-secondary;
    border-color: $semantic-color-border-subtle;
  }
  
  // State Variants
  &--disabled {
    opacity: $semantic-opacity-disabled;
    cursor: not-allowed;
    pointer-events: none;
    
    .ui-tag-input__input {
      cursor: not-allowed;
      color: $semantic-color-text-disabled;
    }
  }
  
  &--error {
    border-color: $semantic-color-border-error;
    
    &:focus-within {
      border-color: $semantic-color-border-error;
      box-shadow: 0 0 0 2px rgba($semantic-color-danger, 0.2);
    }
  }
  
  // Interactive States
  &:not(.ui-tag-input--disabled) {
    &:hover {
      border-color: $semantic-color-border-focus;
    }
    
    &:focus-within {
      border-color: $semantic-color-focus;
      box-shadow: 0 0 0 2px rgba($semantic-color-focus, 0.2);
    }
  }
  
  // Tags Container
  &__tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: $semantic-spacing-component-xs;
    flex: 1;
    min-width: 0;
  }
  
  // Input Element
  &__input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 120px;
    padding: 0;
    margin: 0;
    color: $semantic-color-text-primary;
    
    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);
    
    &::placeholder {
      color: $semantic-color-text-tertiary;
    }
    
    &:disabled {
      color: $semantic-color-text-disabled;
      cursor: not-allowed;
    }
  }
  
  // Tag Item (using existing chip component)
  &__tag {
    .ui-chip {
      margin: 0;
    }
  }
  
  // Max Tags Reached Indicator
  &--max-reached {
    .ui-tag-input__input {
      display: none;
    }
  }
  
  // Focus Management
  &__focus-trap {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    top: -1px;
    left: -1px;
  }
  
  // Responsive Design
  @media (max-width: 767px) {
    .ui-tag-input__input {
      min-width: 80px;
    }
  }
}

// Error Message
.ui-tag-input-error {
  margin-top: $semantic-spacing-component-xs;
  color: $semantic-color-danger;
  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);
}

// Help Text
.ui-tag-input-help {
  margin-top: $semantic-spacing-component-xs;
  color: $semantic-color-text-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);
}