@use "../mixins/function.scss" as *;
@use "../mixins/mixins.scss" as *;
@use "../common/var.scss" as *;

@include b(date-picker) {
  color: getCssVar("color", "text-1");
  line-height: 1.5715;
  @include e(wrapper) {
    display: inline-flex;
    align-items: center;
    height: 100%;
    width: 100%;
    gap: 8px;
    background-color: getCssVar("color", "bg-2");
    border: 1px solid getCssVar("color", "fill-3");
    &:hover {
      border: 1px solid getCssVar("color", "fill-4");
    }
    &:focus-within {
      border-color: getCssVar("color", "primary-6");
    }
    @include when(range) {
      &:focus-within {
        @include be(date-picker, input) {
          &:focus {
            background-color: getCssVar("color", "fill-2");
          }
        }
      }
    }
    @include when(disabled) {
      background-color: getCssVar("color", "fill-2");
      border-color: getCssVar("color", "fill-2");
      cursor: not-allowed;
    }
    @include when(error) {
      @include this-be(date-picker, wrapper) {
        border-color: getCssVar("color", "danger-6");
        &:hover {
          border-color: getCssVar("color", "danger-6");
        }
        &:focus-within {
          border-color: getCssVar("color", "danger-6");
        }
        @include when(filled) {
          background-color: getCssVar("color", "error-1");
          border-color: getCssVar("color", "error-1");
          &:hover {
            background-color: getCssVar("color", "error-2");
          }
          &:focus-within {
            background-color: getCssVar("color", "bg-2");
            border-color: getCssVar("color", "error-5");
          }
        }
      }
    }
    @include when(filled) {
      background-color: getCssVar("color", "fill-2");
      border: 1px solid getCssVar("color", "fill-2");
      &:hover {
        background-color: getCssVar("color", "fill-2");
      }
      &:focus-within {
        background-color: getCssVar("color", "bg-2");
        border-color: getCssVar("color", "primary-6");
      }
    }
  }

  @each $size in $size-list {
    @include m(#{$size}) {
      height: getCssVar("size", $size);
      line-height: getCssVar("size", $size);
      @include be(date-picker, wrapper) {
        border-radius: getCssVar("radius", $size);
        @if $size == "mini" {
          padding: 0px 8px 0 0;
        }
        @if $size == "small" {
          padding: 0px 8px 0 0;
        }
        @if $size == "medium" {
          padding: 4px 8px 4px 4px;
        }
        @if $size == "large" {
          padding: 4px 8px 4px 4px;
        }
      }
      @include be(date-picker, input) {
        font-size: getCssVar("font-size", $size);
      }
    }
  }

  @include e(input) {
    height: 100%;
    width: 100%;
    padding: 0 8px 0 8px;
    color: inherit;
    background: none;
    border: none;
    border-radius: 0;
    outline: none;
    color: getCssVar("color", "text-1");
    cursor: inherit;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    vertical-align: middle;
    &::placeholder {
      color: getCssVar("color", "text-3");
    }
  }

  @include e(close) {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    user-select: none;
    height: 18px;
    width: 18px;
    font-size: 14px;
    border-radius: getCssVar("radius", "circle");
    &:hover {
      background-color: getCssVar("color", "fill-2");
    }
  }
  @include e(icon) {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    user-select: none;
    height: 18px;
    width: 18px;
    font-size: 14px;
    color: getCssVar("color", "text-2");
  }
  @include e(content) {
    background-color: getCssVar("color", "bg-3");
    border-radius: getCssVar("radius", "medium");
    border: 1px solid getCssVar("color", "fill-3");
    box-shadow: getCssVar("shadow", "1");
  }

  @include e(panel-range) {
    width: 100%;
    display: flex;
  }

  @include e(panel-wrapper) {
    width: 264px;
    display: flex;
    flex-direction: column;
  }

  @include e(week-wrapper) {
    width: 300px;
    display: flex;
    flex-direction: column;
  }

  @include e(panel-header) {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid getCssVar("color", "fill-3");
    user-select: none;
  }
  @include e(panel-header-btn) {
    height: getCssVar("size", "small");
    line-height: getCssVar("size", "small");
    width: getCssVar("size", "small");
    text-align: center;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    border-radius: getCssVar("radius", "medium");
    &:hover {
      background-color: getCssVar("color", "fill-2");
      color: getCssVar("color", "primary-6");
    }
  }
  @include e(panel-header-btn-hidden) {
    height: getCssVar("size", "small");
    line-height: getCssVar("size", "small");
    width: getCssVar("size", "small");
  }
  @include e(panel-header-center) {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  @include e(panel-header-center-btn) {
    height: getCssVar("size", "small");
    line-height: getCssVar("size", "small");
    padding: 0 8px;
    text-align: center;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    border-radius: getCssVar("radius", "medium");
    &:hover {
      background-color: getCssVar("color", "fill-2");
      color: getCssVar("color", "primary-6");
    }
  }
  @include e(panel-week-list) {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 12px 20px 0 20px;
  }
  @include e(panel-main) {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  @include e(panel-list) {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 20px;
    gap: 4px;
  }
  @include e(panel-item) {
    height: getCssVar("size", "medium");
    line-height: getCssVar("size", "medium");
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 4px;
    @include when(start) {
      border-top-left-radius: getCssVar("radius", "medium");
      border-bottom-left-radius: getCssVar("radius", "medium");
    }
    @include when(end) {
      border-top-right-radius: getCssVar("radius", "medium");
      border-bottom-right-radius: getCssVar("radius", "medium");
    }
    @include when(in-range) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "fill-2");
      }
    }
    @include when(hover-in-range) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "fill-2");
      }
    }
    @include when(today) {
      &::after {
        content: "";
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: -4px;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background-color: getCssVar("color", "primary-6");
        color: #fff;
      }
    }
    @include when(secondary) {
      color: getCssVar("color", "text-3");
      @include be(date-picker, panel-value) {
        background-color: transparent;
        color: getCssVar("color", "text-3");
        &:hover {
          background-color: transparent;
          color: getCssVar("color", "text-3");
        }
      }
    }
  }

  @include e(panel-value) {
    height: getCssVar("size", "mini");
    line-height: getCssVar("size", "mini");
    width: 100%;
    text-align: center;
    border-radius: getCssVar("radius", "medium");
    cursor: pointer;
    &:hover {
      background-color: getCssVar("color", "fill-2");
      color: getCssVar("color", "primary-6");
    }
    @include when(active) {
      background-color: getCssVar("color", "primary-6");
      color: #fff;
    }
    @include when(start) {
      background-color: getCssVar("color", "primary-6");
      color: #fff;
    }
    @include when(end) {
      background-color: getCssVar("color", "primary-6");
      color: #fff;
    }
  }

  @include e(panel-day-row) {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
  }
  @include e(panel-day-item) {
    aspect-ratio: 1;
  }
  @include e(panel-month-row) {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  @include e(panel-year-row) {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  @include e(panel-week-header) {
    display: flex;
    padding: 12px 20px 0 20px;
  }
  @include e(panel-week-header-label) {
    height: getCssVar("size", "medium");
    line-height: getCssVar("size", "medium");
    width: getCssVar("size", "medium");
    text-align: center;
    margin-right: 4px;
  }
  @include e(panel-week-header-list) {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
  }
  @include e(panel-week-header-item) {
    height: getCssVar("size", "medium");
    line-height: getCssVar("size", "medium");
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 4px;
  }
  @include e(panel-week-main-list) {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 20px;
    gap: 4px;
  }
  @include e(panel-week-content) {
    display: flex;
  }
  @include e(panel-week-number) {
    height: getCssVar("size", "medium");
    line-height: getCssVar("size", "medium");
    width: getCssVar("size", "medium");
    text-align: center;
    margin-right: 4px;
  }
  @include e(panel-week-row) {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    &:hover {
      background-color: getCssVar("color", "fill-2");
      color: getCssVar("color", "primary-6");
    }
    @include when(in-range) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "fill-2");
      }
    }
    @include when(hover-in-range) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "fill-2");
      }
    }
  }
  @include e(panel-week-item) {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 4px;
    @include when(active) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "primary-6");
        color: #fff;
      }
    }
    @include when(start) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "primary-6");
        color: #fff;
      }
    }
    @include when(end) {
      &:not(.is-secondary) {
        background-color: getCssVar("color", "primary-6");
        color: #fff;
      }
    }
    @include when(secondary) {
      color: getCssVar("color", "text-3");
      @include be(date-picker, panel-week-value) {
        background-color: transparent;
        color: getCssVar("color", "text-3");
        &:hover {
          background-color: transparent;
          color: getCssVar("color", "text-3");
        }
      }
    }
    @include when(today) {
      &::after {
        content: "";
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: -4px;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background-color: getCssVar("color", "primary-6");
        color: #fff;
      }
    }
  }
  @include e(panel-week-value) {
    height: getCssVar("size", "mini");
    line-height: getCssVar("size", "mini");
    width: getCssVar("size", "mini");
    text-align: center;
  }
}
