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

.device-history-chart {
  position: relative;
  width: 100%;
  min-height: 0;
  margin-top: 200px;
}

.device-history-chart .echarts-for-react {
  width: 100%;
  height: 100% !important;
}

.device-history-chart__events-title {
  position: absolute;
  left: 90px;
  top: 60px;
  z-index: 2;
  pointer-events: none;

  h3 {
    margin: 0;
    color: $color-text-heading;
    font-size: $font-size-18;
    font-weight: 650;
  }

  p {
    margin: 0;
    color: $color-text-muted;
    font-size: $font-size-14;
    font-weight: 450;
    line-height: 1.3;
  }
}

.device-history-events-legend {
  position: absolute;
  left: 90px;
  right: 0;
  top: 340px;
  z-index: 3;

  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.device-history-events-legend__item {
  border: none;
  background: $transparent;
  padding: 0;

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

  color: $color-text-heading;
  font-family: inherit;
  font-size: $font-size-14;
  font-weight: 500;

  cursor: pointer;
  opacity: 0.55;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;

  &:hover {
    opacity: 0.85;
  }

  &.is-active {
    opacity: 1;
  }
}

.device-history-events-legend__checkbox {
  width: 16px;
  height: 16px;

  border: 1.5px solid $color-border-accent;
  border-radius: 5px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.device-history-events-legend__check {
  width: 18px;
  height: 18px;

  color: $color-text-inverse;
}

.device-history-chart__battery-title,
.device-history-chart__temperature-title,
.device-history-chart__apps-title {
  position: absolute;
  left: 90px;
  z-index: 2;
  pointer-events: none;

  h3 {
    margin: 0;
    color: $color-text-heading;
    font-size: $font-size-18;
    font-weight: 650;
  }

  p {
    margin: 0;
    color: $color-text-muted;
    font-size: $font-size-14;
    font-weight: 450;
    line-height: 1.2;
  }
}

.device-history-chart__battery-title {
  top: 680px;
}

.device-history-chart__temperature-title {
  top: 400px;
}

.device-history-chart__state {
  position: absolute;
  top: 52px;
  right: 0;
  z-index: 10;

  padding: 8px 12px;
  border-radius: 999px;
  background: $color-surface-subtle;

  color: $color-text-muted;
  font-size: $font-size-13;
  font-weight: 600;
}

.device-history-chart__state--error {
  background: $color-danger-tint;
  color: $red;
}

.device-history-app-events-legend {
  position: absolute;
  left: 270px;
  z-index: 3;

  display: flex;
  flex-wrap: wrap;
  gap: 12px;

  color: $color-text-muted;
  font-size: $font-size-13;
  font-weight: 600;

  span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
  }

  i {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
  }
}

.device-history-app-legend__item {
  position: absolute;
  left: 90px;
  z-index: 4;

  width: 164px;
  border: none;
  background: $transparent;
  padding: 0;

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

  color: $color-text-heading;
  font-family: inherit;
  text-align: left;

  cursor: pointer;
  opacity: 0.48;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;

  &:hover {
    opacity: 0.82;
  }

  &.is-active {
    opacity: 1;
  }
}

.device-history-app-legend__image{
  width: 30px;
  height: 30px;
  box-shadow: 0 0 16px -4px rgba($black, 0.4);
  border-radius: 8px;
}
.device-history-app-legend__icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;

  color: $color-text-inverse;
  background: $blue;
  img{
    width: 24px;
    height: auto;
  }

  &.is-radio {
    background: $accent-purple;
  }

  &.is-message {
    background: $accent-sky;
  }

  &.is-health {
    background: $accent-teal;
  }

  &.is-home {
    background: $blue;
  }

  &.is-security {
    background: $color-danger-strong;
  }

  &.is-system {
    background: $color-text-heading;
  }
}

.device-history-app-legend__text {
  min-width: 0;

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

  strong {
    color: $color-text-heading;
    font-size: $font-size-13;
    font-weight: 650;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  small {
    color: $color-text-muted;
    font-size: $font-size-11;
    font-weight: 550;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.device-history-apps-empty {
  position: absolute;
  left: 270px;
  right: 90px;
  z-index: 3;

  width: auto;
  min-width: 0;
  box-sizing: border-box;
  padding: 18px 24px;
  //border-radius: 18px;
  //background: rgba($color-surface-rgb, 0.1);
  box-shadow: inset 0 0 0 1px $color-border-muted;
  backdrop-filter: blur(8px);

  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;

  text-align: center;
  pointer-events: none;

  strong {
    color: $color-text-heading;
    font-size: $font-size-15;
    font-weight: 700;
    line-height: 1.2;
  }

  span {
    max-width: 320px;
    color: $color-text-muted;
    font-size: $font-size-12;
    font-weight: 550;
    line-height: 1.35;
  }
}

.device-history-app-selector {
  position: absolute;
  left: 90px;
  right: 90px;
  z-index: 4;
  height: fit-content;
  padding-top: 10px;

  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.device-history-app-selector__count {
  color: $gray50;
  font-size: $font-size-13;
  font-weight: 650;
  text-align: left;
  height: 30px;
  display: flex;
  align-items: center;
}

.device-history-app-selector__count {
  line-height: 1.2;
}

.device-history-app-selector__scroll {
  height: fit-content;
  min-width: 0;

  .simplebar-track.simplebar-vertical {
    right: -10px;
    width: 6px;
  }

  .simplebar-scrollbar::before {
    background: $gray50;
    border-radius: 4px;
    opacity: 1;
  }
}

.device-history-app-selector__list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0px 6px 0px 0;
}

.device-history-app-selector__item {
  max-width: 230px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 10px;
  background: $color-surface;

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

  color: $gray50;
  font-family: inherit;
  font-size: $font-size-12;
  font-weight: 650;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;

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

  small {
    flex: 0 0 auto;
    color: inherit;
    opacity: 0.72;
    font-size: $font-size-11;
    font-weight: 650;
  }

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

  &.is-active {
    color: $blue;
    background: $blue20;
    box-shadow: inset 0 0 0 1px rgba($color-primary-rgb, 0.12);
  }
}
