@use "base";
@use "../mixins";
@use "../variables" as vars;

:root {
  --sitemap-line-height: 32px;
  --sitemap-url-width: 420px;
  --sitemap-url-header-offset: 0;
  --sitemap-status-width-base: 90px;
  --sitemap-status-length: 2;

  @media screen and (min-width: vars.$large-screen-break-point) {
    --sitemap-url-width: 520px;
  }

  @media screen and (min-width: vars.$xlarge-screen-break-point) {
    --sitemap-url-width: 620px;
  }

  @media screen and (min-width: vars.$xxlarge-screen-break-point) {
    --sitemap-url-width: 820px;
  }
}

#sitemap_heading {
  display: flex;
  padding: 0;
  line-height: 28px;

  .page_name {
    margin-left: 43px;
  }

  .page_urlname {
    display: none;
    margin-left: auto;
    padding-left: var(--spacing-1);
    width: calc(var(--sitemap-url-width) - 60px);

    @media screen and (min-width: vars.$large-screen-break-point) {
      display: block;
    }
  }

  .page_status {
    display: none;
    padding-left: var(--spacing-2);
    margin-right: 190px;
    margin-left: auto;

    @media screen and (min-width: vars.$medium-screen-break-point) {
      display: block;
    }

    @media screen and (min-width: vars.$large-screen-break-point) {
      margin-left: initial;
    }
  }
}

#sitemap-wrapper {
  position: relative;
  min-height: calc(100vh - 148px);
}

#sitemap {
  padding: 0 0 104px 0;

  .page-icon {
    display: inline-flex;
  }

  .handle {
    cursor: move;
  }

  .page_folder {
    position: absolute;
    left: calc(-1 * var(--spacing-8));
    top: 0;
    width: var(--sitemap-line-height);
    height: var(--sitemap-line-height);
  }

  .placeholder {
    background-color: var(--color-grey_light);
    margin-bottom: 0px;
    margin-left: 22px;
  }

  ul {
    margin: 0;
    padding: 0;
  }

  li {
    padding-left: 0;

    li {
      padding-left: var(--sitemap-line-height);
      padding-right: 0;
    }
  }
}

.sitemap_page {
  display: flex;
  align-items: center;
  height: var(--sitemap-line-height);
  margin: var(--spacing-3) 0;
  position: relative;
  transition: background-color var(--transition-duration);
  --sitemap-status-width: calc(
    var(--sitemap-status-width-base) * var(--sitemap-status-length)
  );

  &.highlight {
    background-color: var(--sitemap-highlight-color);
  }

  &.no-match .sitemap_pagename_link {
    color: var(--color-grey_light);
  }

  &:hover {
    background-color: var(--sitemap-page-hover-color);
    border-radius: var(--border-radius_medium);
  }

  &:has(.page_infos :nth-child(3)) {
    --sitemap-status-length: 3;
  }
}

.sitemap_left_images {
  position: relative;
  justify-content: center;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
  height: var(--sitemap-line-height);
}

.sitemap_sitename {
  flex-grow: 1;
  @include mixins.border-left-radius(var(--border-radius_medium));
  line-height: calc(var(--sitemap-line-height) - 4px);
  overflow: hidden;
  background-color: var(--sitemap-page-background-color);

  &.without-status {
    @include mixins.border-right-radius(var(--border-radius_medium));
  }

  .sitemap_pagename_link {
    display: block;
    padding: 0 10px;
    margin: 2px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;

    &.inactive {
      color: #656565;
    }
  }
}

.sitemap_url {
  display: none;
  background-color: var(--sitemap-info-background-color);
  line-height: calc(var(--sitemap-line-height) - 2px);
  font-size: var(--font-size_small);
  padding: 0 var(--spacing-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--sitemap-page-background-color);
  width: calc(var(--sitemap-url-width) - var(--sitemap-status-width));

  @media screen and (min-width: vars.$large-screen-break-point) {
    display: block;
  }
}

.page_infos {
  @extend .right-rounded-border;
  background-color: var(--sitemap-page-background-color);
  border-left: 1px solid var(--body-background-color);
  display: none;
  justify-content: end;
  width: var(--sitemap-status-width);
  height: var(--sitemap-line-height);
  line-height: var(--sitemap-line-height);

  .page_status {
    margin: 0 var(--spacing-1);
    padding: 0 var(--spacing-1);
    white-space: nowrap;
  }

  @media screen and (min-width: vars.$medium-screen-break-point) {
    display: flex;
  }
}

.sitemap_right_tools {
  display: none;
  align-items: center;
  gap: var(--spacing-1);
  height: var(--sitemap-line-height);
  padding: 0 var(--spacing-2);

  @media screen and (min-width: vars.$small-screen-break-point) {
    display: flex;
  }

  .sitemap_tool {
    width: var(--spacing-8);
    height: var(--spacing-8);
    line-height: var(--sitemap-line-height);
    text-align: center;
    margin: 0;

    &.disabled .icon {
      opacity: 0.25;
      filter: grayscale(100%);
    }
  }
}

.page_status_and_name .page_status {
  margin-left: var(--spacing-1);
  margin-bottom: -1px;

  // The lock icon is a bit too high, so we need to adjust it
  &:last-child {
    margin-bottom: 0;
  }
}

.page_status {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-1);
}

#page_filter_result {
  display: none;
  margin-left: var(--spacing-2);
}

.alchemy-dialog {
  #sitemap-wrapper {
    min-height: 0;
  }

  #sitemap {
    margin: 0;
    padding: 0 var(--spacing-6) var(--spacing-2) var(--spacing-2);

    .page_icon {
      cursor: default;
    }
  }
}

#search_field_clear {
  cursor: pointer;
}
