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

.sidebar {
  width: $layout-sidebar-width;
  min-height: calc(100vh - 56px);
  max-height: 100vh;
  padding:
    $layout-sidebar-padding-y
    0
    $layout-page-padding-bottom
    $layout-sidebar-padding-x;
  background: $transparent;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;

  overflow: hidden;
  transition:
    width 0.25s ease,
    padding 0.25s ease;

  .wrap-btn {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;

    border-radius: 12px;
    padding: 12px;
    font-size: $font-size-20;
    line-height: 1;
    cursor: pointer;

    background-color: $transparent;
    color: $gray50;
    font-weight: 500;
    border: none;

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

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

    svg {
      height: 20px;
      width: 20px;
      flex: 0 0 20px;
    }
  }
}

.sidebar__top {
  display: flex;
  flex-direction: column;
}

.sidebar__logo {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding-left: 8px;

  img {
    height: 32px;
    width: auto;
    display: block;
  }
}

.sidebar__brand {
  overflow: hidden;
  color: $color-text-heading;
  font-size: $font-size-18;
  font-weight: 700;
  line-height: 1.05;
  white-space: nowrap;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar__link {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;

  gap: 8px;
  padding: 12px;
  border-radius: 12px;

  color: $color-text-soft;
  text-decoration: none;
  font-size: $font-size-20;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  font-weight: 500;
  line-height: 1;

  svg {
    height: 20px;
    width: 20px;
    flex: 0 0 20px;
  }

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

.sidebar__icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;

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

.sidebar__label {
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.0;
  transition:
    width 0.2s ease,
    opacity 0.2s ease;
}

.sidebar__link--active {
  background: $color-surface;
  color: $color-primary;
  box-shadow: var(--shadow-card-soft);

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

.wrap-btn__arrow {
  transition: transform 0.25s ease;
}

.wrap-btn__text {
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.1;
  transition:
    width 0.2s ease,
    opacity 0.2s ease;
}

/* Свернутое состояние */

.sidebar--collapsed {
  width: $layout-sidebar-collapsed-width;
  padding:
    $layout-sidebar-padding-y
    $layout-sidebar-padding-x
    $layout-page-padding-bottom
    $layout-sidebar-padding-x;

  .sidebar__logo {
    justify-content: center;
    padding-left: 0;
  }

  .sidebar__nav {
    //align-items: center;
  }

  .sidebar__link {
    //width: 44px;
    //height: 44px;
    justify-content: center;
    padding: 12px;
    gap: 0;
  }

  .sidebar__label {
    width: 0;
    opacity: 0;
  }

  .wrap-btn {
    width: 44px;
    height: 44px;
    justify-content: center;
    padding: 12px;
    gap: 0;
  }

  .wrap-btn__text {
    width: 0;
    opacity: 0;
  }

  .wrap-btn__arrow {
    transform: rotate(180deg);
  }
}

.sidebar--drawer {
  width: calc(100% - 40px);
  min-height: calc(100vh - 64px);
  max-height: none;
  padding: 20px 20px 24px;
  background: $color-bg;
  border-radius: 20px;
  overflow: visible;
  box-shadow: inset 0 0 .5px 1px rgba(var(--gray50-rgb), .2);

  .sidebar__logo {
    padding-left: 6px;
  }

  .sidebar__link {
    padding: 13px 12px;
  }
}

@include tablet-down {
  .sidebar:not(.sidebar--drawer) {
    display: none;
  }
}

[data-theme='dark'] {
  .sidebar__link:hover,
  .sidebar .wrap-btn:hover {
    background-color: $color-surface-hover;
    color: $color-primary-hover;
  }

  .sidebar__link--active {
    background: $color-surface-active;
    color: $color-text-heading;

    &:hover {
      background: $color-surface-active;
      color: $color-text-heading;
    }
  }
}
