.lea-input-datepicker {
  position: relative;
  float: left;
  width: 100%;

  input {
    width: 100%;
    border-radius: $border-radius;
    box-shadow: none;
    border: $border-input;
    background-color: $background-input;
    font-family: $title;
    font-size: 1rem;
    padding: 1.2rem 1rem 0.5rem;
    margin: 1.1rem 0;
    color: $black;
    box-sizing: border-box;
    transition: border 0.5s;

    &:focus {
      outline: none;
      transition: border 0.5s;
      border: $border-focus;
    }

    &.input-error {
      transition: border 0.5s;
      border: $border-error;
      color: $red;
    }

    &:disabled {
      background-color: $bg-grey;
      border: $border-disabled;
      color: $dark-grey;
    }

    display: block;
    line-height: 1.3;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    background-color: $background-input;

    ::-ms-expand {
      display: none;
    }
  }

  label {
    position: absolute;
    top: 2.05rem;
    left: 1rem;
    font-size: 1rem;
    color: $dark-grey;

    &.label-focus {
      color: $accent;
      transition: color 0.5s;
    }

    &.label-float {
      transform: scale(0.7) translate(-1.5rem, -1rem);
      transition: transform 0.5s;
    }

    &.label-error {
      color: $red;
      transition: color 0.5s;
    }

    &.label-disabled {
      color: $dark-grey;
    }
  }

  .lea-datepicker-error {
    position: absolute;
    bottom: 0;
    font-size: 0.7rem;
    height: 0.7rem;
    overflow: hidden;
    left: 0;

    span {
      position: relative;
      float: left;
      color: $red;
      animation: 0.2s error ease-in-out;
    }
  }

  @keyframes error {
    from {
      margin-top: 0;
    }

    to {
      margin-top: -1rem;
    }
  }

  [type="date"]::-webkit-inner-spin-button {
    display: none;
  }

  [type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
  }

  [type="date"]::-webkit-clear-button {
    display: none;
  }

  .datepicker-icon {
    position: absolute;
    right: 1rem;
    top: 1.75rem;
    z-index: -1;
    transform: scale(0.8);
    z-index: 2;
  }

  .datepicker-dropdown-container {
    .datepicker-mobile-bg {
      display: none;
    }

    .datepicker-dropdown {
      position: absolute;
      width: 18rem;
      top: 4.4rem;
      right: 0;
      background-color: $white;
      z-index: 99;
      border: $border-input;
      border-radius: $border-radius-dropdown;
      overflow: auto;
      max-height: 23rem;

      .datepicker-header {
        padding: 1rem 1rem 0.8rem;
        color: $black;
        font-size: 1rem;
        border-bottom: $border-input;
        float: left;
        width: 100%;
        box-sizing: border-box;

        .current-time {
          float: left;
          width: calc(100% - 6.5rem);
          padding: 0.4rem 0;

          p {
            float: left;
            margin: 0;
          }
        }

        .back-arrow {
          float: left;
          margin-right: 0.5rem;
          transform: scale(0.8);
        }

        .time-controls {
          float: right;
          width: 4rem;

          .previous-arrow {
            transform: scale(0.8);
            float: left;
          }

          .next-arrow {
            transform: scale(0.8);
            float: right;
          }
        }
      }

      .datepicker-calendar {
        position: relative;
        float: left;
        width: 100%;

        .week-days {
          padding: 1rem 0.5rem 0 0.1rem;
          color: $accent;
          font-size: 0.8rem;
          position: relative;
          float: left;
          width: 100%;
          box-sizing: border-box;

          span {
            position: relative;
            float: left;
            width: 14.2857%;
            text-align: center;
          }
        }

        .month-days {
          padding: 1rem 0.5rem 0.8rem 0.1rem;
          color: $accent;
          font-size: 0.8rem;
          position: relative;
          float: left;
          width: 100%;
          box-sizing: border-box;

          div {
            position: relative;
            float: left;
            width: 14.2857%;
            height: 2.5rem;

            span {
              position: absolute;
              top: 5%;
              left: 5%;
              display: flex;
              align-items: center;
              justify-content: center;
              box-sizing: border-box;
              width: 90%;
              height: 90%;
              line-height: 1;
              cursor: pointer;
              color: $black;

              &.current {
                border: 0.05rem solid $accent;
                border-radius: 10rem;
              }

              &.selected {
                border: 0.05rem solid $accent;
                background-color: $accent;
                color: $white;
                border-radius: 10rem;
                box-shadow: 1px 1px 3px rgba($color: $accent, $alpha: 0.3);
                &:hover {
                  color: $white;
                  box-shadow: 1px 1px 1px rgba($color: $accent, $alpha: 0.3);
                }
              }

              &:hover {
                color: $accent;
                opacity: 0.8;
              }

              &.disabled {
                cursor: not-allowed;
                border: 0.05rem dashed $light-grey;
                background-color: $white;
                color: $light-grey;
                border-radius: 10rem;
                &:hover{
                  opacity: 1;
                  color: $light-grey;
                }
              }
              &.feriado {
                cursor: pointer;
                color: $red;
                &.disabled {
                  border: 0.05rem dashed $red;
                  cursor: not-allowed;
                  opacity: 0.7;
                }
              }
            }
          }
        }
      }

      .datepicker-years-container {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        padding: 0 1rem;
        box-sizing: border-box;

        .year-selector {
          width: 20%;
          text-align: center;
          padding: 0.5rem 0;
          margin: 1rem 0;
          box-sizing: border-box;
          cursor: pointer;
          font-size: 0.8rem;

          &:hover {
            color: $accent;
            opacity: 0.8;
          }

          &:focus {
            opacity: 1;
            color: $accent;
          }

          &.current {
            background-color: $accent;
            color: $white;
            border-radius: 4rem;
            box-shadow: 1px 1px 3px rgba($color: $accent, $alpha: 0.3);
          }

          &.disabled {
            cursor: not-allowed;
            color: $light-grey;
            border-radius: 10rem;
            opacity: 0.7;
            &:hover{
              opacity: 0.7;
              color: $light-grey;
            }
          }
        }
      }

      .datepicker-months-container {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        padding: 0 1rem;
        box-sizing: border-box;

        .month-selector {
          width: 25%;
          padding: 0.5rem 0;
          box-sizing: border-box;
          cursor: pointer;
          font-size: 0.8rem;

          p {
            margin: 0;
            padding: 0.5rem 1rem;
            box-sizing: border-box;
          }

          &:hover {
            color: $accent;
            opacity: 0.8;
          }

          &:focus {
            opacity: 1;
            color: $accent;
          }

          &.current {
            p {
              background-color: $accent;
              color: $white;
              border-radius: 4rem;
              float: left;
              box-shadow: 1px 1px 3px rgba($color: $accent, $alpha: 0.3);
            }
          }

          &.disabled {
            cursor: not-allowed;
            color: $light-grey;
            border-radius: 10rem;
            opacity: 0.1;
            &:hover {
              color: $light-grey;
              opacity: 0.1;
            }
          }
        }
      }
    }

    &.datepicker-mobile {
      .datepicker-mobile-bg {
        display: block;
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background-color: rgba($color: $black, $alpha: 0.7);
        width: 100vw;
        height: 100vh;
        z-index: 2;
      }

      .datepicker-dropdown {
        position: fixed;
        left: 50%;
        transform: translate(-50%, -50%);
        top: 50%;
        box-shadow: 5px 5px 5px rgba($color: $black, $alpha: 0.2);
        z-index: 3;
      }
    }
  }

  .hide {
    display: none;
  }
}

.dark-mode {
  .lea-input-datepicker {
    label {
      color: $light-grey;
    }
    input {
      color: $white;
      &:disabled {
          background-color: $dark-grey;
          border: $border-disabled;
          color: $grey;
      }
    }
    .datepicker-dropdown-container {
      .datepicker-dropdown {
        background-color: $black;
        .datepicker-calendar {
          .month-days{
            div{
              span{
                color: $light-grey;
                &.disabled{
                  background-color: rgba($color: $white, $alpha: 0.1);
                }
                &.selected{
                  color: $white;
                }
                &.feriado {
                  cursor: pointer;
                  color: $red;
                  &.disabled {
                    border: 0.05rem dashed $red;
                    cursor: not-allowed;
                    opacity: 0.7;
                  }
                }
              }
            } 
          } 
        }
      }
    }
  }
}