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

.devices-filters {
  width: var(--devices-filters-width, 292px);
  min-width: var(--devices-filters-width, 292px);
  margin-left: var(--devices-filters-gap, 20px);
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  overflow: visible;
  pointer-events: none;
  transform: translateX(6px);
  will-change: opacity, transform;

  transition:
    opacity 0.2s ease,
    transform var(
      --devices-filters-duration,
      360ms
    ) var(--devices-filters-easing, cubic-bezier(0.22, 1, 0.36, 1)),
    visibility 0s linear var(--devices-filters-duration, 360ms);
}

.devices-filters--open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition:
    opacity 0.2s ease,
    transform var(
      --devices-filters-duration,
      360ms
    ) var(--devices-filters-easing, cubic-bezier(0.22, 1, 0.36, 1)),
    visibility 0s;
}

.devices-filters__accordion {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.devices-filter-item {
  border-radius: 14px;
  background: $color-surface;
  overflow: hidden;
  box-shadow: 2px 2px 30px -10px rgba($gray50-rgb, .2);
  &:nth-child(1)[data-state=open]{
    overflow: visible;
  }
}

.devices-filter-item__header {
  margin: 0;
}

.devices-filter-item__trigger {
  width: calc(100% - 32px);
  min-height: 44px;
  margin: 0 16px;

  border: none;
  border-bottom: 1px solid $transparent;
  background: $transparent;

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

  color: $color-text-strong;
  font-size: $font-size-18;
  font-weight: 500;
  cursor: pointer;

  &[data-state='open'] {
    //color: $blue;
    border-bottom-color: $gray20;
  }
}

.devices-filter-item__chevron {
  flex: 0 0 auto;
  transition: transform 0.2s ease;
}

.devices-filter-item__trigger[data-state='open'] .devices-filter-item__chevron {
  transform: rotate(180deg);
}

.devices-filter-item__content {
  //overflow: hidden;

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

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

.devices-filter-item__inner {
  padding: 12px 16px 16px;
}

.devices-period {
  display: flex;
  align-items: center;
  gap: 6px;
}

.devices-period__divider {
  width: 12px;
  height: 1px;
  background: $gray50;
  flex: 0 0 12px;
}

.devices-period__input {
  width: 126px;
  min-height: 28px;
  padding: 0 10px;

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

  color: $gray50;
  font-size: $font-size-16;
  font-weight: 400;
  cursor: pointer;
}

.devices-filter-reset {
  margin: 12px 0 0 auto;
  padding: 0;

  display: block;

  border: none;
  background: $transparent;

  color: $blue;
  font-size: $font-size-14;
  font-weight: 400;
  text-decoration: underline;
  cursor: pointer;
}

.devices-filter-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;

  min-height: 28px;

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

  & + & {
    margin-top: 12px;
  }
}

.devices-filter-row__label {
  color: $gray50;
  font-size: $font-size-16;
  font-weight: 500;
  text-align: left;
}

.devices-checkbox-list{
  display: flex;
  flex-direction: column;
}

.devices-radio,
.devices-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  color: $color-text-heading;
  font-size: $font-size-16;
  font-weight: 500;
  cursor: pointer;
  user-select: none;

  input {
    display: none;
  }
}

.devices-radio__control {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid $color-border-strong;
  background: $color-surface-muted;
  position: relative;
  flex: 0 0 18px;
}

.devices-radio input:checked + .devices-radio__control {
  border-color: $color-primary;
  background: $color-primary;
}

.devices-radio input:checked + .devices-radio__control::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: $color-surface;
}

.devices-radio__label {
  white-space: nowrap;
}

.devices-checkbox {
  min-height: 28px;

  & + & {
    margin-top: 8px;
  }
}

.devices-checkbox__control {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid $color-border-strong;
  background: $color-surface-muted;
  position: relative;
  flex: 0 0 18px;
  transition: .2s ease;
}

.devices-checkbox input:checked + .devices-checkbox__control {
  border-color: $color-primary;
  background: $color-primary;
  box-shadow: 0 2px 8px -2px rgba(var(--color-primary-rgb), 0.8);
}

.devices-checkbox input:checked + .devices-checkbox__control::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

@keyframes filterSlideDown {
  from {
    height: 0;
  }

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

@keyframes filterSlideUp {
  from {
    height: var(--radix-accordion-content-height);
  }

  to {
    height: 0;
  }
}

[data-theme='dark'] {
  .devices-filter-item {
    box-shadow: none;
    outline: 1px solid rgba($gray50-rgb, 0.08);
  }

  .devices-filter-item__trigger:hover {
    color: $color-primary-hover;
  }
}
