@use "sass:map";
@use "sass:list";
@use "./functions.scss" as *;

.default__dropdown {
  position: relative;
  width: 100%;
  &:focus-within {
    box-shadow: 0px 0px 0px 2px var(--_gray-100);
    border-radius: 4px;
  }

  .bo-dropdown__container {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    align-self: stretch;
    justify-content: space-between;
    border: 1px solid var(--_gray-300);
    border-radius: 4px;
    background-color: var(--_base-white);
    min-height: 40px;
    cursor: pointer;
    transition: 0.2s ease;
    padding-inline: 12px !important;
    // .bod-trigger-left {
    //   padding-left: 12px;
    // }
    .bo-dropdown__actions {
      //   padding-right: 12px;
      .bo-dropdown__clear-btn {
        span {
          display: flex;
        }
      }
    }
    .bod-trigger-left {
      width: -webkit-fill-available;
    }
  }

  .bo-dropdown__container--search {
    padding: 0;
    cursor: text;
    line-height: 125%;
  }

  .bo-dropdown__container--disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }

  .bo-dropdown__value-wrapper {
    flex: 1;
    min-width: 0;
  }

  .bo-dropdown__placeholder {
    color: #9ca3af;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bo-dropdown__selected {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .bo-dropdown__selected-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .bo-dropdown__selected-name {
    font-weight: normal;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bo-dropdown__selected-code {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bo-dropdown__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .bo-dropdown__clear-btn,
  .bo-dropdown__toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
  }

  .bo-dropdown__chevron {
    transition: transform 0.2s ease;
  }

  .bo-dropdown__chevron--open {
    transform: rotate(180deg);
  }

  .bo-dropdown__panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    margin-top: 4px;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow:
      0 10px 15px -3px rgba(0, 0, 0, 0.1),
      0 4px 6px -2px rgba(0, 0, 0, 0.05);
    max-height: 320px;
    overflow: hidden;
  }

  .bo-dropdown__list {
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .bo-dropdown__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    .variant__img {
      border: 1px solid var(--_gray-200);
      border-radius: 4px;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain;
      }
    }
  }

  .bo-dropdown__option:last-child {
    border-bottom: none;
  }

  .bo-dropdown__option--highlighted {
    // @include BgColorLighter(var(--_thm-cs-at-py), 10%);
    background-color: var(--_gray-50);
    color: var(--_thm-cs-at-py);
    border-radius: 4px;
  }

  .bo-dropdown__option--selected {
    // background-color: var(--_base-white);
    border-radius: 4px;
    // @include BgColorLighter(var(--_thm-cs-at-py), 10%);
    background-color: var(--_gray-100);
    .bo-dropdown__option-name {
      color: var(--_gray-900);
    }
    .bo-dropdown__option-code {
      color: var(--_gray-700);
    }
  }

  .bo-dropdown__check {
    svg path {
      stroke: var(--_gray-900);
    }
  }

  .bo-dropdown__option-text {
    flex: 1;
    min-width: 0;
  }

  .bo-dropdown__option-name {
    font-weight: 500;
    color: var(--_gray-700);
    font-size: 13px;
    line-height: 1.2;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bo-dropdown__option-code {
    font-size: 11px;
    color: var(--_gray-500);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    .code__icon {
      display: flex;
      gap: 4px;
      margin-top: 4px;
    }
  }

  .bo-dropdown__empty,
  .bo-dropdown__loading {
    padding: 24px 12px;
    text-align: center;
    color: #6b7280;
  }

  .bo-dropdown__empty-title {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
  }

  .bo-dropdown__empty-sub {
    font-size: 12px;
    color: #9ca3af;
  }

  @keyframes pulse {
    0%,
    100% {
      opacity: 0.4;
    }
    50% {
      opacity: 1;
    }
  }
}
