// ===== Mixins =====
.pisell-tabstruct-focus-ring() {
  outline: 2px solid var(--ps-color-primary, #7f56d9);
  outline-offset: 2px;
}

.pisell-tabstruct-disabled() {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.pisell-tabstruct-smooth-scroll() {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.pisell-tabstruct-hide-scrollbar() {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE and Edge */

  &::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
  }
}

// ===== Tab Wrapper =====
.pisell-tabstruct-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  inline-size: 100%;
  box-sizing: border-box;
}

// ===== Tab List =====
.pisell-tabstruct-list {
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  list-style: none;
  gap: 8px;
  border-radius: 20px;
}

// ===== Tab Item =====
.pisell-tabstruct-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 40px;
  border: none;
  background: var(--ps-tab-item-bg, #fff);
  color: #1b1b1b;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  white-space: nowrap;
  user-select: none;
  // 基础样式采用原pill样式
  border-radius: 20px;

  // Focus state
  &:focus-visible {
    .pisell-tabstruct-focus-ring();
  }

  &--selected {
    color: #ffffff;
    border-radius: 20px;
    background-color: var(--ps-color-primary, #7f56d9);;
  }

  &[aria-selected='true'] {
    color: #ffffff;
    border-radius: 20px;
    background-color: var(--ps-color-primary, #7f56d9);;
  }

  // Disabled state
  &--disabled {
    .pisell-tabstruct-disabled();
    color: #adb5bd;
  }
}

// ===== Tab Rail =====
.pisell-tabstruct-rail {
  position: relative;
  display: inline-flex;
  inline-size: 100%;
  overflow: auto;
  scroll-snap-type: x mandatory;
  .pisell-tabstruct-smooth-scroll();
  .pisell-tabstruct-hide-scrollbar();
}

// ===== Selection Indicator =====
.pisell-tabstruct-selection {
  position: absolute;
  z-index: 10;
  transition: all 0.2s ease-in-out;
  pointer-events: none;
  z-index: 0;
  block-size: 100%;
  background-color: var(--ps-color-primary, #7f56d9);
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

  &--positioned {
    inset-block-start: auto;
    inset-block-end: 0;
    inset-inline-start: 0;
  }

  &::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: calc(20px - 2px);
  }

  &--focused {
    .pisell-tabstruct-focus-ring();
  }
}

// ===== Scroll Shadow =====
.pisell-tabstruct-shadow {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity all 0.2s ease-in-out;

  &--visible {
    opacity: 1;
  }

  &--start {
    inset-block-start: 0;
    inset-block-end: 0;
    inset-inline-start: 0;
    inline-size: 20px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
  }

  &--end {
    inset-block-start: 0;
    inset-block-end: 0;
    inset-inline-end: 0;
    inline-size: 20px;
    background: linear-gradient(
      270deg,
      rgba(0, 0, 0, 0.1) 0%,
      transparent 100%
    );
  }
}

// ===== Chevron Controls =====
.pisell-tabstruct-chevron-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 15;
}

.pisell-tabstruct-chevron-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: #f8f9fa;
  color: #262626;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  flex-shrink: 0;

  &:hover:not(.pisell-tabstruct-chevron-button--disabled) {
    background-color: #e9ecef;
    color: #495057;
  }

  &:focus-visible {
    .pisell-tabstruct-focus-ring();
  }

  &--disabled {
    .pisell-tabstruct-disabled();
    color: #adb5bd;
    background-color: #f2f4f7;
  }

  svg {
    font-size: 20px;
    font-weight: bold;
    flex-shrink: 0;
  }
}
