/**
 * PisellSingleSelect 组件样式
 * 基于 Figma 设计规范，覆盖时使用 pisell-lowcode-xxx
 */

.pisell-single-select {
  height: 48px !important;
  width: 100%;

  .pisell-lowcode-select-clear {
    color: #667085;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -22px -8px;
    padding: 10px 8px;

    &:hover {
      color: #344054;
    }
  }

  // Select 触发器（Figma 设计规范，与 Input 体系一致）
  .pisell-lowcode-select:not(.pisell-lowcode-select-disabled):not(.pisell-lowcode-select-customize-input) {
    .pisell-lowcode-select-selector {
      font-size: 16px !important;
      line-height: 24px !important;
      border-radius: 8px !important;
      border: 1px solid #d0d5dd !important; // Gray/300
      padding: 12px 16px !important;
      min-height: 48px !important;
      color: #101828 !important; // Gray/900
      background-color: #ffffff !important;
    }

    &.pisell-lowcode-select-open .pisell-lowcode-select-selector {
      border-color: #d6bbfb !important; // Primary/300
      box-shadow: 0 0 0 4px #f4ebff !important; // Primary/100
    }

    &:not(.pisell-lowcode-select-open):not(.pisell-lowcode-select-disabled)
    .pisell-lowcode-select-selector:hover {
      border-color: #b692f6 !important; // Primary/400
    }

    &.pisell-lowcode-select-disabled .pisell-lowcode-select-selector {
      background-color: #f9fafb !important; // Gray/50
      color: #98a2b3 !important; // Gray/400
      border-color: #d0d5dd !important;
      cursor: not-allowed !important;
    }

    .pisell-lowcode-select-selection-placeholder {
      color: #667085 !important; // Gray/500
    }

    .pisell-lowcode-select-arrow {
      color: #667085;
    }

    .pisell-lowcode-select-clear {
      color: #667085;

      &:hover {
        color: #344054;
      }
    }
  }

  &-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;

    // 下拉选项高度 48px（通过 getPopupContainer 挂到 wrapper 内）
    .pisell-single-select-dropdown .pisell-lowcode-select-item {
      min-height: 48px !important;
      height: 48px !important;
      line-height: 48px !important;
      padding: 0 16px !important;
      font-size: 16px !important;
    }
  }

  &-label {
    font-size: 14px;
    font-weight: 600;
    color: #344054; // Gray/700
    line-height: 20px;

    &-required::after {
      content: ' *';
      color: #d92d20; // Error/600
      margin-left: 0;
    }
  }

  &-helper-text {
    font-size: 14px;
    font-weight: 400;
    color: #667085; // Gray/500
    line-height: 20px;
  }

  &-error-text {
    font-size: 12px;
    font-weight: 400;
    color: #d92d20; // Error/600
    line-height: 1.5;
    animation: pisell-single-select-fadeIn 0.3s ease-in-out;
  }

  &-option-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  &-option-check {
    color: #7f56d9; // Primary/600
    font-size: 16px;
    margin-left: 8px;
  }
}

// 下拉框内的搜索框样式（Figma 设计）
:global {
  .pisell-select-search-wrapper {
    padding: 6px;
    border-bottom: 1px solid #EAECF0;
  }

  .pisell-select-search-input {
    padding: 9px 10px !important;
    font-size: 14px;

    .pisell-lowcode-input {
      font-size: 14px !important;
      color: #344054 !important;

      &::placeholder {
        color: #98A2B3 !important;
        font-size: 12px !important;
      }
    }

    &:hover,
    &:focus-within {
      background-color: transparent !important;
    }
  }
}

.pisell-single-select {
  // 错误状态（Figma 设计体系 Error 色）
  &-error {
    .pisell-lowcode-select .pisell-lowcode-select-selector {
      border-color: #fda29b !important; // Error/300

      &:hover {
        border-color: #f97066 !important; // Error/400
      }
    }

    .pisell-lowcode-select.pisell-lowcode-select-focused .pisell-lowcode-select-selector,
    .pisell-lowcode-select.pisell-lowcode-select-open .pisell-lowcode-select-selector {
      border-color: #f97066 !important; // Error/400
      box-shadow: 0 0 0 4px #fee4e2 !important; // Error/100
    }
  }

  // 只读状态：仅展示 Tag，无 Select 无外框，Tag 使用与 disabled 一致的样式
  &-readonly {
    &-display {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 24px;
    }

    &-tag {
      margin: 0;
      cursor: default;
      border-radius: 12px;
      border: 1px solid transparent;
      font-size: 14px;
      line-height: 22px;
      padding: 2px 10px;
    }

    &-icon {
      display: flex;
      align-items: center;
    }

    &-empty {
      color: #667085;
      font-weight: 400;
    }
  }
}

@keyframes pisell-single-select-fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
