@use '_variable';

@mixin little-flag {
  &:after {
    content: '';
    position: absolute;
    bottom: 100%;
    //--- right of datepicker ---//
    // right: 1.2rem;
    //--- center of datepicker ---//
    /* left: 50%; transform: translateX(-50%); */
    //--- left of datepicker ---//
    /* left: 1.2rem; */
    border: solid transparent;
    border-bottom-color: variable.$background;
    border-bottom-color: var(--background);
    border-width: 0.4rem;
  }
}

@mixin scrollbar {
  &::-webkit-scrollbar {
    -webkit-appearance: none;
  }

  &::-webkit-scrollbar:vertical {
    width: 0.4rem;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: variable.$radius;
    border-radius: var(--radius);
    border: 0.1rem solid white;
    /* should match background, can't be transparent */
    background: variable.$border-color;
    background: var(--border-color);
  }
}

@keyframes start {
  from {
    transform: inherit scale(0.5);
    opacity: 0;
  }

  to {
    transform: inherit scale(1);
    opacity: 1;
  }
}

@keyframes startModal {
  from {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }

  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes tada {
  0% {
    transform: scale(1);
  }

  10%,
  20% {
    transform: scale(0.9) rotate(-3deg);
  }

  30%,
  50%,
  70%,
  90% {
    transform: scale(1.1) rotate(3deg);
  }

  40%,
  60%,
  80% {
    transform: scale(1.1) rotate(-3deg);
  }

  100% {
    transform: scale(1) rotate(0);
  }
}

@media (max-width: 700px) {
  .pdp-picker {
    flex-direction: column-reverse;
  }

  .pdp-shortcut {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: space-evenly;
    padding: 0 !important;
    border: none !important;
  }
}

@charset "UTF-8";

.font-fa,
.pdp {
  direction: rtl;
  font-family: Shabnam;
}

.pdp {
  position: relative;

  &:not(.pdp-range) .pdp-day.start-range {
    border-radius: variable.$radius !important;
    border-radius: var(--radius) !important;
  }

  &.pdp-range .pdp-picker.rtl .pdp-day.start-range {
    border-radius: 0 variable.$radius variable.$radius 0 !important;
    border-radius: 0 var(--radius) var(--radius) 0 !important;
  }

  &.pdp-range .pdp-picker.rtl .pdp-day.end-range {
    border-radius: variable.$radius 0 0 variable.$radius !important;
    border-radius: var(--radius) 0 0 var(--radius) !important;
  }

  &.pdp-range .pdp-picker.rtl .pdp-day.end-range.start-range {
    border-radius: variable.$radius !important;
    border-radius: var(--radius) !important;
  }

  &.pdp-range .pdp-picker.ltr .pdp-day.start-range {
    border-radius: variable.$radius 0 0 variable.$radius !important;
    border-radius: var(--radius) 0 0 var(--radius) !important;
  }

  &.pdp-range .pdp-picker.ltr .pdp-day.end-range {
    border-radius: 0 variable.$radius variable.$radius 0 !important;
    border-radius: 0 var(--radius) var(--radius) 0 !important;
  }

  &.pdp-range .pdp-picker.ltr .pdp-day.end-range.start-range {
    border-radius: variable.$radius !important;
    border-radius: var(--radius) !important;
  }

  &.rtl {
    direction: rtl;
    text-align: right;

    .pdp-group {

      :first-child:not(.pdp-inside),
      .pdp-inside:first-child+input {
        border-top-right-radius: variable.$radius;
        border-top-right-radius: var(--radius);
        border-bottom-right-radius: variable.$radius;
        border-bottom-right-radius: var(--radius);
        margin-left: -1px;
      }

      input:last-of-type {
        border-top-left-radius: variable.$radius;
        border-top-left-radius: var(--radius);
        border-bottom-left-radius: variable.$radius;
        border-bottom-left-radius: var(--radius);
      }

      .pdp-icon.pdp-inside {
        &:nth-of-type(2) {
          right: 50%;
        }

        +input {
          padding-right: 3rem;
        }
      }
    }

    &.pdp-dual {
      .pdp-clear {
        &:nth-of-type(1) {
          left: calc(50% + 0.5rem) !important;
        }
      }
    }

    .pdp-picker::after {
      right: 1.2rem;
    }
  }

  &.ltr {
    direction: ltr;
    text-align: left;

    .pdp-group {

      :first-child:not(.pdp-inside),
      .pdp-inside:first-child+input {
        border-top-left-radius: variable.$radius;
        border-top-left-radius: var(--radius);
        border-bottom-left-radius: variable.$radius;
        border-bottom-left-radius: var(--radius);
        margin-right: -1px;
      }

      input:last-of-type {
        border-top-right-radius: variable.$radius;
        border-top-right-radius: var(--radius);
        border-bottom-right-radius: variable.$radius;
        border-bottom-right-radius: var(--radius);
        font-family: sans-serif;
      }

      .pdp-clear {
        left: unset;
        right: 0.5rem;
      }

      .pdp-icon.pdp-inside {
        &:nth-of-type(2) {
          left: 50%;
        }

        +input {
          padding-left: 3rem;
        }
      }
    }

    &.pdp-dual {
      .pdp-clear {
        &:nth-of-type(1) {
          right: calc(50% + 0.5rem) !important;
        }
      }
    }

    .pdp-picker::after {
      left: 1.2rem;
    }
  }

  &.pdp-dual {
    .pdp-picker {
      left: 50%;
      transform: translateX(-50%);

      &::after {
        right: unset;
        left: 50%;
        transform: translateX(-50%);
      }
    }
  }

  &.pdp-modal {
    .pdp-overlay {
      background: rgba(0, 0, 0, 0.5) !important;
    }

    .pdp-picker {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      animation: startModal 0.1s;

      &::after {
        all: unset !important;
      }
    }
  }

  * {
    box-sizing: border-box;
  }

  svg {
    vertical-align: middle;
  }

  input,
  button {
    font-family: inherit;
  }

  .pdp-label {
    display: inline-block;
    margin-bottom: 0.5rem;
  }

  .pdp-group {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;

    .pdp-input {
      display: block;
      height: calc(1.5em + 0.75rem + 2px);
      padding: 0.375rem 0.75rem;
      font-size: 1rem;
      font-weight: 400;
      line-height: 1.5;
      background-clip: padding-box;
      border: 1px solid variable.$border-color;
      border: 1px solid var(--border-color);
      transition:
        border-color 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out;
      position: relative;
      flex: 1 1 auto;
      width: 100%;

      &.pdp-focus {
        outline: none;
        border-bottom: 2px solid variable.$primary-color;
        border-bottom: 2px solid var(--primary-color);
      }
    }

    .pdp-icon {
      padding: 0.375rem 0.75rem;
      line-height: 1.5;
      font-size: 1rem;
      color: variable.$text-color;
      color: var(--text-color);
      background: variable.$icon-background;
      background: var(--icon-background);
      border: 1px solid variable.$border-color;
      border: 1px solid var(--border-color);
      max-height: calc(1.5em + 0.75rem + 2px);

      &:nth-of-type(2) {
        margin-left: -1px;
        margin-right: -1px;
      }

      &.pdp-inside {
        background: transparent;
        border: none;
        position: absolute;
        z-index: 1;
      }
    }

    .pdp-clear {
      border: none;
      background-color: transparent;
      position: absolute;
      left: 0.5rem;
      top: 0;
      bottom: 0;
      z-index: 1;
      cursor: pointer;
      padding: 0 0.5rem;
    }
  }

  .pdp-overlay {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: variable.$z-index;
    z-index: var(--z-index);
    background: variable.$overlay-color;
    background: var(--overlay-color);
  }

  .pdp-picker {
    display: flex;
    position: absolute;
    color: variable.$text-color;
    color: var(--text-color);
    background: variable.$background;
    background: var(--background);
    box-shadow: variable.$main-box-shadow;
    box-shadow: var(--main-box-shadow);
    z-index: variable.$z-index + 1;
    z-index: calc(var(--z-index) + 1);
    border-radius: variable.$radius;
    border-radius: var(--radius);
    transition: all 1s ease;
    margin-top: 0.5rem;
    padding: 0.3rem 0.6rem;
    animation: start 0.1s;

    &.ltr {
      direction: ltr;

      .pdp-header .bottom {
        flex-direction: row-reverse;

        &>div {
          display: flex;
          flex-direction: row-reverse;
        }
      }

      .pdp-select-year,
      .pdp-days,
      .pdp-header .pdp-year,
      .pdp-footer small,
      .pdp-time {
        font-family: sans-serif !important;
      }

      .pdp-shortcut {
        border-right: unset;
        border-left: 1px solid variable.$border-color;
        border-left: 1px solid var(--border-color);
      }
    }

    &.rtl {
      direction: rtl;
    }

    &.pdp-top {
      bottom: calc(1.5em + 0.75rem + 2px);
      margin-top: unset;
      margin-bottom: 0.5rem;

      &::after {
        bottom: unset;
        top: 100%;
        transform: rotate(180deg);
      }
    }

    &.pdp-left {
      left: 0;
      right: unset;

      &::after {
        right: unset;
        left: 1.2rem;
      }
    }

    &.pdp-right {
      left: unset;
      right: 0;

      &::after {
        left: unset;
        right: 1.2rem;
      }
    }

    @include little-flag();

    ::selection {
      all: unset;
    }

    .pdp-auto {

      &,
      &>div {
        background: inherit;
      }
    }

    .pdp-select-year,
    .pdp-select-month {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      font-size: 0.8rem;
      background: inherit;
      list-style: none;
      position: absolute;
      left: 0;
      right: 0;
      top: 3.5rem;
      bottom: 3.5rem;
      padding: 0;
      margin: 0;
      z-index: 1;
      animation: start 0.1s;
      overflow: auto;

      button {
        border: 0;
        background: inherit;
        cursor: pointer;

        &:focus {
          outline: 0;
        }
      }

      li {
        width: 5rem;
        height: 4rem;
        padding: 0.2rem;
        cursor: pointer;
        margin: 0.15rem;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        flex: 30% 0;

        &:not(.disabled):hover {
          border-radius: variable.$radius;
          border-radius: var(--radius);
          border: 2px solid variable.$primary-color;
          border: 2px solid var(--primary-color);
        }

        &.disabled {
          text-shadow: unset;
          box-shadow: unset;
          cursor: default !important;
          opacity: variable.$disabled-opacity;
          opacity: var(--disabled-opacity);
        }

        &.selected {
          border: 2px solid variable.$primary-color;
          border: 2px solid var(--primary-color);
          border-radius: variable.$radius;
          border-radius: var(--radius);
          background: variable.$primary-color !important;
          background: var(--primary-color) !important;
          color: variable.$background;
          color: var(--background);
        }
      }

      @include scrollbar();
    }

    .pdp-header {
      &>div:first-child {
        border-bottom: 1px solid variable.$border-color;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 0.5rem;
      }

      .top {
        padding: 0.75rem 0.3rem 1rem 0.3rem;
        display: flex;
        justify-content: space-between;
        font-size: 0.9rem;
        direction: rtl;

        button {
          border: 0;
          background: inherit;
          cursor: pointer;
          color: variable.$primary-color;
          color: var(--primary-color);
          padding: 0 0.5rem;
        }
      }

      .bottom {
        padding: 0.3rem;
        display: flex;
        align-items: center;
        height: 3rem;
        direction: rtl;

        &>div {
          display: flex;
          flex-grow: 1;
          justify-content: space-around;

          .pdp-month,
          .pdp-year {
            color: variable.$primary-color;
            color: var(--primary-color);
            font-size: 1rem;
          }
        }

        button {
          border: 0;
          background: inherit;
          cursor: pointer;

          &:focus {
            outline: 0;
          }
        }

        .pdp-arrow.disabled {
          opacity: variable.$disabled-opacity;
          opacity: var(--disabled-opacity);
        }

        .pdp-arrow:not(.disabled):hover {
          opacity: variable.$disabled-opacity;
          opacity: var(--disabled-opacity);
        }
      }
    }

    .pdp-main {
      position: relative;

      .pdp-date {
        display: flex;
        justify-content: center;

        .pdp-column {
          margin: 0 1rem;

          .pdp-week {
            background: inherit;
            margin-bottom: 0.3rem;
            display: flex;
            justify-content: space-around;

            .pdp-weekday {
              width: variable.$day-dimensions;
              width: var(--day-dimensions);
              height: variable.$day-dimensions;
              height: var(--day-dimensions);
              line-height: variable.$day-dimensions;
              line-height: var(--day-dimensions);
              font-size: 0.8rem;
              text-align: center;
            }
          }

          .pdp-days {
            background: inherit;

            .pdp-day {
              display: inline-flex;
              justify-content: center;
              align-items: center;
              margin: 0.1rem 0;
              font-size: 0.8rem;
              width: variable.$day-dimensions;
              width: var(--day-dimensions);
              height: variable.$day-dimensions;
              height: var(--day-dimensions);
              border-radius: variable.$radius;
              border-radius: var(--radius);
              padding: 0;
              cursor: pointer;
              transition-property: background-color, box-shadow;
              transition-duration: 0.1s;
              contain: content;

              &.friday {
                color: variable.$primary-color;
                color: var(--primary-color);
              }

              &.empty {
                visibility: hidden;
              }

              &.start-range,
              &.end-range {
                background: variable.$primary-color;
                background: var(--primary-color);
                color: variable.$background;
                color: var(--background);
              }

              &.disabled {
                box-shadow: unset;
                text-shadow: unset;
                cursor: default !important;
                border-color: transparent;
                opacity: variable.$disabled-opacity;
                opacity: var(--disabled-opacity);
              }

              &.hover {
                background: variable.$primary-color;
                background: var(--primary-color);
                color: variable.$background;
                color: var(--background);
                // background: variable.$secondary-color !important;
                // background: var(--secondary-color) !important;
                // color: variable.$hover-color;
                // color: var(--hover-color);
              }

              &.in-range {
                background: variable.$in-range-background;
                background: var(--in-range-background);
                color: variable.$hover-color;
                color: var(--hover-color);
                border-radius: 0 !important;
              }

              &:not(.disabled):hover,
              &.today {
                border: 2px solid variable.$primary-color;
                border: 2px solid var(--primary-color);
              }

              &.tada {
                animation: tada 1s;
                background: variable.$secondary-color;
                background: var(--secondary-color);
                box-shadow: inset 0 4px 9px rgba(0, 0, 0, 0.24);
                color: #000;
                position: relative;
                z-index: 1;
              }
            }
          }
        }
      }

      .pdp-time {
        background: inherit;

        &:not(.inline) {
          position: absolute;
          top: 0;
          bottom: 0;
          right: 0;
          left: 0;
        }

        .pdp-column {
          display: flex;

          div {
            width: 16.6rem;
          }
        }

        .pdp-moment {
          margin-bottom: 1rem;
          font-size: calc(2rem * variable.$time-scale);
          font-size: calc(2rem * var(--time-scale));
          display: flex;
          justify-content: space-around;
          height: 100%;

          &.column-direction {
            flex-direction: column;
          }

          >div {
            display: flex;
            justify-content: center;
            align-items: center;
            direction: ltr;
            width: 100%;
            padding: 1rem 0;

            &.disabled {
              opacity: variable.$disabled-opacity;
              opacity: var(--disabled-opacity);
            }

            div {
              display: flex;
              flex-direction: column;
              align-items: center;
              padding: 0 0.8rem;

              button {
                border: none;
                background: none;
                cursor: pointer;

                svg {
                  width: calc(8px * variable.$time-scale);
                  width: calc(8px * var(--time-scale));
                }
              }
            }
          }
        }
      }
    }

    .pdp-footer {
      text-align: center;
      min-height: 3rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-top: 1px solid variable.$border-color;
      border-top: 1px solid var(--border-color);
      padding: 0.3rem;

      .pdp-today,
      .pdp-submit {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
        margin: 0 0.3rem;
        line-height: 1.5;
        color: variable.$background;
        color: var(--background);
        text-decoration: none;
        border: none;
        border-radius: variable.$radius;
        border-radius: var(--radius);
        background: variable.$primary-color;
        background: var(--primary-color);
        cursor: pointer;

        &:hover {
          filter: brightness(0.9);
        }
      }

      >div {
        display: flex;
      }
    }

    .pdp-shortcut {
      margin: 0;
      padding: 0.5rem;
      list-style: none;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      border-right: 1px solid variable.$border-color;
      border-right: 1px solid var(--border-color);

      li {
        margin: 0;
        padding: 0.5rem 1rem;
        text-align: center;
        cursor: pointer;
        border-radius: variable.$radius;
        border-radius: var(--radius);
        margin: 0.25rem 0;
        color: variable.$hover-color;
        color: var(--hover-color);
        font-weight: 500;

        &:hover {
          background: variable.$in-range-background;
          background: var(--in-range-background);
        }

        &.selected {
          background: variable.$primary-color;
          background: var(--primary-color);
          color: variable.$background;
          color: var(--background);
        }
      }
    }
  }

  .pdp-pointer {
    cursor: pointer;
  }

  .pdp-auto {
    margin: auto;
    position: relative;
  }
}