@use "../base/mixins" as *;
@use "../base/variables" as *;
@use "../base/typography" as *;

.select {
  width: 100%;
}

.selectbox {
  position: relative;
  height: 4.4rem;

  @include media("lg") {
    height: 3.8rem;

    .selectbox__item {
      height: 3.8rem;
    }
  }

  &--xl {
    height: 5.6rem;

    .selectbox__item {
      height: 5.6rem;
    }
  }

  &--lg {
    height: 4.8rem;

    .selectbox__item {
      height: 4.8rem;
    }

    @include media("lg") {
      height: 3.6rem;

      .selectbox__item {
        height: 3.6rem;
      }
    }
  }

  &--md {
    @include typography("p2");

    height: 4rem;

    .selectbox__item {
      height: 4rem;

      @include media("lg") {
        height: 3.6rem;
      }
    }
  }

  &--sm {
    height: 3.2rem;

    .selectbox__item {
      height: 3.2rem;
    }
  }

  &.active {
    .selectbox__btn {
      &::after {
        rotate: -180deg;
      }
    }
  }

  &--top {
    .selectbox__list {
      bottom: 100%;
    }

    &.active {
      .selectbox__btn {
      }
    }
  }

  &--bottom {
    .selectbox__list {
      top: 100%;
    }
  }

  &--form {
    display: flex;
    align-items: center;

    &::after {
      content: "";
      position: absolute;
      right: 1.2rem;
      width: 2rem;
      height: 2rem;
    }

    &.active {
      &::after {
        rotate: -180deg;
      }
    }
  }

  &__btn {
    display: flex;
    align-items: center;
    position: relative;
    padding: 0 1.2rem;
    width: 100%;
    height: 100%;
    background-color: theme-color($container);
    border: 1px solid theme-color($border-low);
    border-radius: 0.8rem;
    color: theme-color($text-high);

    &.ico-after {
      &::after {
        position: absolute;
        right: 1.2rem;
        width: 2rem;
        height: 2rem;
      }
    }
  }

  &__list {
    overflow: hidden;
    position: absolute;
    top: 100%;
    right: 0;
    translate: 0 0.4rem;
    z-index: 9;
    padding: 0.8rem 0;
    width: 24rem;
    border-radius: 0.8rem;

    @include media("lg") {
      width: 100%;
    }

    [data-theme="dark"] & {
      background-color: #332e35;
    }

    [data-theme="light"] & {
      background-color: #ffffff;
    }

    border: 1px solid theme-color($border-low);
  }

  &__item {
    @include transition(background);
    @include typography("h6");

    display: flex;
    align-items: center;
    position: relative;
    padding: 0 1.2rem;
    height: 4rem;
    color: theme-color($text-high);
    cursor: pointer;

    &::after {
      position: absolute;
      top: 50%;
      right: 1.2rem;
      translate: 0 -50%;
    }

    &:hover,
    &.active {
      [data-theme="dark"] & {
        background-color: #534c56;
      }

      [data-theme="light"] & {
        background-color: #eef1f8;
      }
    }

    &:has(a) {
      padding: 0;
    }

    a {
      display: flex;
      align-items: center;
      padding: 0 1.2rem;
      width: 100%;
      height: 100%;
    }

    span {
      @include flexCenter(flex-start);

      gap: 0.4rem;
    }
  }

  &__date {
    position: absolute;
    top: 100%;
    right: 100%;
    translate: -2.8rem 0.4rem;
    z-index: 10;
    width: 26rem;

    @include media("lg") {
      right: 0;
      translate: 0 0.4rem;
      width: 100%;
      min-width: 25rem;
    }

    [data-theme="dark"] & {
      background-color: #332e35;
    }

    [data-theme="light"] & {
      background-color: #ffffff;
    }

    border-radius: 0.8rem;
    border: 1px solid theme-color($border-low);
  }

  &__select {
    @include transition((border-color, color));
    @include typography("h6");
    @include ellipsis(1);

    display: flex;
    align-items: center;
    position: relative;
    padding: 0 1.2rem;
    width: 100%;
    height: 100%;
    background-color: theme-color($container);
    border: 1px solid theme-color($border-low);
    border-radius: 0.8rem;
    -webkit-appearance: none;
    cursor: pointer;
  }

  .vc-bordered {
    width: 100%;
    height: 100%;
    background-color: transparent;
    border: none;
  }

  .vc-bordered * {
    font-family: "AppFont";
    border-radius: 0.4rem !important;
    outline: none;
  }

  .vc-weeks {
    padding: 0.8rem 1.2rem;
  }

  .vc-header .vc-arrow {
    width: 2rem;
    height: 2rem;
    background: transparent;
    color: theme-color($text-high);

    &:hover {
      background: transparent;
    }
  }

  .vc-header .vc-title {
    @include typography("p2");

    font-weight: 700;
    color: theme-color($text-high);
    background: transparent;

    &:hover {
      opacity: 1;
      background: transparent;
    }
  }

  .vc-weekday {
    @include typography("p2");

    color: theme-color($text-low);
    font-weight: 500;
  }

  .vc-container {
    @include typography("p2");

    color: theme-color($text-low);
    font-weight: 600;

    @include media("lg") {
      font-size: 1.4rem;
      line-height: 2rem;
    }
  }

  .vc-day-content {
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 0.4rem;

    &:hover {
      background-color: theme-color($primary);

      [data-theme="dark"] & {
        color: #111;
      }

      [data-theme="light"] & {
        color: #fff;
      }
    }
  }

  .vc-highlight-content-outline,
  .vc-highlight-content-none {
    font-weight: 600;

    [data-theme="dark"] & {
      color: #111;
    }

    [data-theme="light"] & {
      color: #fff;
    }
  }

  .vc-blue {
    [data-theme="dark"] & {
      --vc-accent-600: rgba(64, 250, 182, 0.2);
      --vc-accent-200: rgba(64, 250, 182, 0.2);
      --vc-accent-900: #fff;
    }
    [data-theme="light"] & {
      --vc-accent-600: rgba(0, 201, 128, 0.2);
      --vc-accent-200: rgba(0, 201, 128, 0.2);
      --vc-accent-900: #111;
    }
  }

  .vc-light.vc-attr,
  .vc-light .vc-attr {
    [data-theme="dark"] & {
      --vc-highlight-outline-bg: #40fab6;
      --vc-highlight-solid-bg: #40fab6;
      --vc-highlight-solid-content-color: #111;
    }
    [data-theme="light"] & {
      --vc-highlight-outline-bg: #00c980;
      --vc-highlight-solid-bg: #00c980;
      --vc-highlight-solid-content-color: #fff;
    }
  }
  .vc-nav-arrow,
  .vc-nav-title,
  .vc-nav-item {
    background: transparent;
    color: theme-color($text-high);
  }

  .vc-light {
    --vc-focus-ring: transparent;
    [data-theme="dark"] & {
      --vc-nav-item-active-bg: #40fab6;
      --vc-nav-item-active-color: #111;
      --vc-popover-content-bg: #221a25;
      --vc-popover-content-border: rgba(255, 255, 255, 0.15);
      --vc-nav-hover-bg: #40fab6;
    }
    [data-theme="light"] & {
      --vc-nav-item-active-bg: #00c980;
      --vc-nav-item-active-color: #fff;
      --vc-popover-content-bg: #eef2f6;
      --vc-popover-content-border: #111;
      --vc-nav-hover-bg: #00c980;
    }
  }

  .vc-nav-title:hover,
  .vc-nav-arrow:hover,
  .vc-nav-item:hover {
    [data-theme="dark"] & {
      color: #111;
    }
    [data-theme="light"] & {
      color: #fff;
    }
  }
}
