// ========================================
// 地区选择器组件样式（分栏联动，支持二栏/三栏）
// 全局 1rem = 100px，表单元素用固定 height 控制
// 颜色统一使用 variables.scss 变量
// 风格与行业/岗位选择器保持一致
// ========================================
@use '../variables' as *;

.region-selector {
  position: relative;
  //display: inline-block;

  // ==================== 触发按钮 ====================
  &__trigger {
    display: flex;
    align-items: center;
    gap: 0.04rem;
    background: $bg-main;
    border: 1px solid $border-color;
    border-radius: 0.2rem;
    padding: 0.05rem 0.14rem;
    color: $text-dark;
    font-size: 0.12rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 2rem;

    &:hover {
      border-color: $accent;
      color: $accent;
      background: $theme-color;
    }
  }

  &__display {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 1.2rem;
  }

  &__arrow {
    width: 0.1rem;
    height: 0.1rem;
    color: $text-light;
    flex-shrink: 0;
    transition: transform 0.2s;

    &--open {
      transform: rotate(180deg);
    }
  }

  // ==================== 下拉面板 ====================
  &__panel {
    width: 4.2rem;
    background: $bg-white;
    border: 1px solid $border-color;
    border-radius: 0.1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 0.1rem;

    // level=2 时只有两栏，面板收窄
    &--two-col {
      width: 3rem;
    }
  }

  // ==================== 选中区 ====================
  &__selected-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.06rem;
    margin-bottom: 0.1rem;
    max-height: 0.8rem;
    overflow-y: auto;
  }

  &__tag {
    display: inline-flex;
    align-items: center;
    gap: 0.03rem;
    height: 0.22rem;
    background: $theme-color;
    border: 1px solid rgba(79, 194, 201, 0.3);
    border-radius: 0.04rem;
    padding: 0 0.08rem;
    font-size: 0.11rem;
    line-height: 0.22rem;
    color: $accent-hover;
    white-space: nowrap;
    box-sizing: border-box;
  }

  &__tag-close {
    width: 0.1rem;
    height: 0.1rem;
    cursor: pointer;
    color: $accent;
    flex-shrink: 0;
    transition: color 0.15s;

    &:hover {
      color: $danger;
    }
  }

  // ==================== 搜索框 ====================
  &__search-wrap {
    margin-bottom: 0.08rem;
  }

  &__search {
    display: block;
    width: 100%;
    height: 0.3rem;
    box-sizing: border-box;
    border: 1px solid $border-color;
    border-radius: 0.06rem;
    padding: 0 0.1rem;
    font-size: 0.12rem;
    line-height: 0.3rem;
    color: $text-dark;
    outline: none;
    background: $bg-main;
    margin: 0;
    transition: border-color 0.2s;

    &::placeholder {
      color: $text-light;
      line-height: 0.3rem;
    }

    &:focus {
      border-color: $accent;
      background: $bg-white;
    }
  }

  // ==================== 搜索结果 ====================
  &__search-results {
    max-height: 2rem;
    overflow-y: auto;
    border: 1px solid $border-color;
    border-radius: 0.06rem;
    background: $bg-white;
  }

  &__search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 0.3rem;
    padding: 0 0.1rem;
    font-size: 0.12rem;
    line-height: 0.3rem;
    color: $text-dark;
    cursor: pointer;
    transition: all 0.15s;

    &:hover {
      background: $theme-color;
      color: $accent-hover;
    }

    & + & {
      border-top: 1px solid $border-color;
    }
  }

  &__search-empty {
    padding: 0.1rem;
    font-size: 0.12rem;
    line-height: 1;
    color: $text-light;
    text-align: center;
  }

  &__check {
    width: 0.12rem;
    height: 0.12rem;
    color: $accent;
    flex-shrink: 0;
  }

  // ==================== 分栏联动选择区 ====================
  &__columns {
    display: flex;
    border: 1px solid $border-color;
    border-radius: 0.06rem;
    overflow: hidden;
    height: 2.4rem;
  }

  &__col {
    overflow-y: auto;
    height: 100%;

    &--left {
      width: 1.1rem;
      flex-shrink: 0;
      border-right: 1px solid $border-color;
      background: $bg-main;
    }

    &--mid {
      width: 1.2rem;
      flex-shrink: 0;
      border-right: 1px solid $border-color;
      background: $bg-white;

      // level=2 时中栏是最后一栏，撑满剩余空间且去掉右边框
      &:last-child {
        flex: 1;
        border-right: none;
      }
    }

    &--right {
      flex: 1;
      background: $bg-white;
    }
  }

  &__col-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 0.32rem;
    padding: 0 0.1rem;
    font-size: 0.12rem;
    line-height: 0.32rem;
    color: $text-dark;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    &:hover {
      background: $theme-color;
      color: $accent-hover;
    }

    &--active {
      background: $bg-white;
      color: $accent;
      font-weight: 600;
      box-shadow: inset 3px 0 0 $accent;
    }

    &--selected {
      color: $accent;
      background: $theme-color;
    }
  }

  &__col-empty {
    padding: 0.2rem 0.1rem;
    font-size: 0.12rem;
    line-height: 1;
    color: $text-light;
    text-align: center;
  }

  // ==================== 底部操作按钮 ====================
  &__actions {
    display: flex;
    justify-content: space-between;
    margin-top: 0.1rem;
    gap: 0.1rem;
  }

  &__btn {
    flex: 1;
    height: 0.3rem;
    border-radius: 0.06rem;
    font-size: 0.12rem;
    line-height: 0.3rem;
    cursor: pointer;
    border: 1px solid $border-color;
    transition: all 0.2s;

    &--reset {
      background: $bg-main;
      color: $text-dark;

      &:hover {
        border-color: $text-light;
        color: $text-dark;
      }
    }

    &--confirm {
      background: $accent;
      color: $bg-white;
      border-color: $accent;

      &:hover {
        background: $accent-hover;
        border-color: $accent-hover;
      }
    }
  }
}