@use '../../../../shared/styles/variables' as *;

.devices-date-range {
  position: relative;
  width: 100%;
}

.devices-date-range__trigger {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;

  border: none;
  border-radius: 999px;
  background: $color-surface-hover;

  display: flex;
  align-items: center;
  gap: 8px;

  color: $color-text-soft;
  font-size: $font-size-14;
  font-weight: 500;
  text-align: left;
  cursor: pointer;

  span {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &.is-open {
    box-shadow: 0 0 0 2px rgba($color-primary-rgb, 0.15);
  }
}

.devices-date-range__clear,
.devices-date-range__chevron {
  flex: 0 0 auto;
  color: $blue;
}

.devices-date-range__popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: -13px;

  width: 100%;
  padding: 12px;

  border-radius: 18px;
  background: $color-surface;
    border: 1.5px solid $gray20;
}

.devices-date-range__calendar {
  --rdp-accent-color: #{$blue};
  --rdp-accent-background-color: #{$color-primary-soft};
  --rdp-day_button-border-radius: 12px;
  --rdp-day_button-height: 34px;
  --rdp-day_button-width: 34px;
  --rdp-day-height: 36px;
  --rdp-day-width: 36px;

  margin: 0;
  font-family: inherit;

  .rdp-months {
    max-width: 100%;
  }

  .rdp-month {
    width: 100%;
  }

  .rdp-caption_label {
    font-size: $font-size-14;
    font-weight: 700;
    color: $color-text-strong;
  }

  .rdp-nav {
    gap: 4px;
  }

  .rdp-button_previous,
  .rdp-button_next {
    width: 28px;
    height: 28px;
    color: $blue;
    border-radius: 8px;

    &:hover {
      background: $color-surface-hover;
    }
  }

  .rdp-weekday {
    color: $color-text-muted;
    font-size: $font-size-12;
    font-weight: 600;
  }

  .rdp-day_button {
    color: $color-text-heading;
    font-size: $font-size-12;
    font-weight: 600;
  }

  .rdp-day_button:hover {
    background: $color-surface-hover;
  }

  .rdp-selected .rdp-day_button {
    background: $blue;
    color: $color-text-inverse;
  }

  .rdp-range_middle .rdp-day_button {
    background: $color-primary-soft;
    color: $blue;
    border-radius: 0;
  }

  .rdp-range_start .rdp-day_button,
  .rdp-range_end .rdp-day_button {
    background: $blue;
    color: $color-text-inverse;
    border-radius: 12px;
  }

  .rdp-outside {
    opacity: 0.35;
  }
}

.devices-date-range__time {
  margin-top: 12px;

  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;

  label {
    display: flex;
    flex-direction: column;
    gap: 5px;

    span {
      color: $color-text-muted;
      font-size: $font-size-11;
      font-weight: 600;
    }

    input {
      height: 32px;
      padding: 0 10px;

      border: none;
      outline: none;
      border-radius: 10px;
      background: $color-surface-hover;

      color: $color-text-heading;
      font-size: $font-size-13;
      font-weight: 600;
      font-family: inherit;
    }
  }
}

.devices-date-range__presets {
  margin-top: 10px;

  display: flex;
  gap: 6px;

  button {
    height: 28px;
    padding: 0 10px;

    border: none;
    border-radius: 999px;
    background: $color-surface-hover;

    color: $color-text-soft;
    font-size: $font-size-12;
    font-weight: 600;
    cursor: pointer;

    &:hover {
      background: $color-primary-soft;
      color: $blue;
    }
  }
}

.devices-date-range__footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid $color-border;

  display: flex;
  flex-direction: column;
  gap: 10px;

  p {
    margin: 0;
    color: $color-text-muted;
    font-size: $font-size-12;
    font-weight: 500;
  }
}

.devices-date-range__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.devices-date-range__reset,
.devices-date-range__apply {
  height: 32px;
  padding: 0 12px;

  border: none;
  border-radius: 10px;

  font-size: $font-size-12;
  font-weight: 700;
  cursor: pointer;
}

.devices-date-range__reset {
  background: $color-surface-hover;
  color: $color-text-soft;
}

.devices-date-range__apply {
  background: $blue;
  color: $color-text-inverse;
}
