@use "@/styles/variables";

$borderLeftColor: var(--cmm-color-border-base);
$borderLeftWidth: 2px;
$marginBottom: 0.5rem;

.rootList {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: var(--cmm-font-size-sm);
}

details.collapsible {
  &[open] {
    > summary .chevronIcon {
      rotate: 90deg;
    }
  }

  summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    user-select: none;
    border-radius: var(--cmm-radius-sm);
    background-color: var(--cmm-color-surface-0);
    position: relative;
    padding: 0 0.5rem;
    font-weight: var(--cmm-font-weight-medium);
    cursor: pointer;
    width: 100%;
    height: 2rem;

    .content {
      display: flex;
      gap: 0.5rem;
      align-items: center;

      svg {
        width: 1rem;
        height: 1rem;
        color: var(--cmm-color-primary-emphasis);
        stroke-width: 2;
      }
    }

    .chevronIcon {
      width: 0.8rem;
      height: 0.8rem;
      color: var(--cmm-color-font-subtle);
      stroke-width: 2.5;
    }

    &:hover:not([aria-current="page"]) {
      background-color: var(--cmm-color-surface-1);
    }
  }

  summary::-webkit-details-marker {
    display: none;
  }

  > .children {
    margin-top: 0.25rem;
    margin-left: 1rem;
    border-left: 1px solid var(--cmm-color-border-base);

    > li {
      margin-left: 0.5rem;
    }
  }
}

.children {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

%item {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  width: 100%;
  height: 1.8rem;
  border-radius: var(--cmm-radius-sm);
}

.section {
  &:not(:first-child) {
    margin-top: 1rem;
  }

  .sectionLabel {
    @extend %item;

    color: var(--cmm-color-font-muted);
    background-color: var(--cmm-color-surface-1);
    font-weight: var(--cmm-font-weight-semibold);
    margin-bottom: $marginBottom;
    position: relative;
    border: none;
  }
}

.link {
  @extend %item;

  color: var(--cmm-color-font-muted);
  font-weight: var(--cmm-font-weight-normal);
  background-color: var(--cmm-color-surface-0);
  outline-offset: 0;

  &:hover {
    background-color: var(--cmm-color-surface-1);
  }

  &--active,
  &[aria-current="page"] {
    font-weight: var(--cmm-font-weight-semibold);
    border-color: var(--cmm-color-primary-emphasis);
    color: var(--cmm-color-primary-emphasis);
    background-color: var(--cmm-color-primary-subtle);
  }
}
