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

.device-apps {
  margin-top: 34px;
  padding: 0 90px;
  border-radius: 22px;
}

.device-apps__header {
  margin-bottom: 16px;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;

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

  p {
    margin: 4px 0 0;
    color: $gray50;
    font-size: $font-size-14;
    font-weight: 500;
  }

  span {
    padding: 8px 12px;
    border-radius: 999px;
    background: $color-surface;
    color: $gray50;
    font-size: $font-size-13;
    font-weight: 600;

    &.is-error {
      background: $color-danger-tint;
      color: $red;
    }
  }
}

.device-apps__empty {
  min-height: 240px;
  padding: 24px 18px;
}

.device-apps__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-app-item {
  border: 1px solid $gray20;
  border-radius: 18px;
  background: $color-surface;
  overflow: hidden;
}

.device-app-item__header {
  margin: 0;
}

.device-app-item__trigger {
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: $transparent;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;

  font-family: inherit;
  cursor: pointer;
  text-align: left;

  transition: background-color 0.2s ease;

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

  &[data-state='open'] {
    &:hover{
        background-color: $color-surface;
    }
    .device-app-item__chevron {
      transform: rotate(180deg);
    }
  }
}

.device-app-item__main {
  min-width: 0;

  display: flex;
  align-items: center;
  gap: 12px;
}

.device-app-item__icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;

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

  color: $color-text-inverse;
  background: $blue;
  flex: 0 0 auto;

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

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

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

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

  &.is-package {
    background: $color-warning;
  }
}

.device-app-item__info {
  min-width: 0;

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

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

  small {
    color: $gray50;
    font-size: $font-size-13;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.device-app-item__right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 0 0 auto;
}

.device-app-item__usage {
  min-width: 84px;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;

  strong {
    color: $color-text-heading;
    font-size: $font-size-20;
    font-weight: 600;
    line-height: 1;
  }

  span {
    color: $gray50;
    font-size: $font-size-12;
    font-weight: 500;
  }
}

.device-app-item__chevron {
  color: $gray50;
  transition: transform 0.2s ease;
}

.device-app-item__content {
  overflow: hidden;

  &[data-state='open'] {
    animation: deviceAppAccordionDown 0.2s ease;
  }

  &[data-state='closed'] {
    animation: deviceAppAccordionUp 0.2s ease;
  }
}

.device-app-item__body {
  padding: 0 16px 16px;
}

.device-app-item__meta {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;

  color: $gray50;
  font-size: $font-size-13;
  font-weight: 500;

  b {
    color: $color-text-heading;
    font-weight: 650;
  }
}

.device-app-chart {
  height: 220px;
  border-radius: 16px;
  background: $color-surface;
  border: 1px solid $gray20;

  .echarts-for-react {
    width: 100%;
    height: 220px !important;
  }
}

@keyframes deviceAppAccordionDown {
  from {
    height: 0;
    opacity: 0;
  }

  to {
    height: var(--radix-accordion-content-height);
    opacity: 1;
  }
}

@keyframes deviceAppAccordionUp {
  from {
    height: var(--radix-accordion-content-height);
    opacity: 1;
  }

  to {
    height: 0;
    opacity: 0;
  }
}
