@use "@beeline/design-tokens/scss/tokens/globals/colors";
@use "@beeline/design-tokens/scss/tokens/themes";
@use '@beeline/design-tokens/scss/tokens/themes/theme-variables' as *;

@mixin font_style($fontSize, $fontWeight, $lineHeight, $letterSpacing) {
  font-size: $fontSize;
  font-weight: $fontWeight;
  line-height: $lineHeight;
  letter-spacing: $letterSpacing;
}

@mixin generate-numbered-list-styles($start, $end) {
  @for $counter from $start through $end {
    $counter-name: list + ' ' + ($counter - 1);
    ol[start*="#{$counter}"] {
      list-style-type: none;
      counter-reset: $counter-name;
    }
  }
}

.vp-doc {
  font-size: 17px;

  // Titles
  h1 {
    @include font_style(44px, 500, 56px, 0.3px);
    margin-bottom: 24px;
  }

  h2 {
    @include font_style(26px, 500, 32px, 0.2px);
    margin: 40px 0 24px;
  }

  h3 {
    @include font_style(26px, 500, 32px, 0.2px);
    margin-bottom: 12px;
  }

  h4 {
    @include font_style(20px, 700, 28px, 0.2px);
    margin-bottom: 12px;
  }

  h5 {
    @include font_style(17px, 500, 22px, 0.2px);
    margin-bottom: 12px;
  }

  // Text
  ol {
    list-style-type: none;
    counter-reset: list;
    margin: 0 0 0 50px;
    padding: 0;
    font-size: 15px;
  
    & > * + * {
      margin-top: 50px;
    }
  }

  @include generate-numbered-list-styles(2, 50);

  ol li {
    position: relative;
    padding: 8px 0 0 0;
    line-height: 18px;
  }

  li + li {
    margin-top: 30px;
  }

  ul li {
    padding-bottom: 0;
    padding-top: 0;
    margin-top: 8px;
    @include font_style(15px, 400, 18px, 0.2px);
  }
  
  ol li:nth-last-of-type(n+2)::after {
    content: '';
    border-left: 1px solid rgb(201, 197, 197);
    position: absolute;
    line-height: 100%;
    left: -30px;
    top: 43px;
    bottom: -25px;
  }

  ol li::before {
    content: counter(list);
    counter-increment: list;
    display: inline-flex;
    position: absolute;
    top: 0;
    left: -48px;
    width: 35px;
    height: 35px;
    background-color: colors.$color-background-brand;
    color: themes.$color-text-active;
    @include font_style(15px, 400, 18px, 0.2px);
    border-radius: 50%;
    justify-content: center;
    align-items: center;
  }

  ul li:nth-last-of-type(n):after {
    content: none;
  }

  ol ul li::before {
    counter-increment: list;
    content: none;
    margin: 0;
    padding: 0;
  }

  ol li:last-child {
    margin-bottom: 40px;
  }

  ul li:last-child {
    margin-bottom: 20px;
  }

  ol li p {
    margin-top: 0;
  }

  p {
    @include font_style(15px, 400, 18px, 0.2px);
    margin: 24px 0;
  }

  // Links
  a {
    color: #1a73e8;
    text-decoration: none;

    &:hover, &:focus-visible, &:focus, &:active {
      color: #1a73e8;
    }

    &:visited {
      color: #7e00ed;
    }
  }
}

// Tabs
.plugin-tabs {
  border-radius: 12px;
  border: 1px solid $color-border;
  background-color: revert-layer !important;

  &--tab {
    border-bottom: 1px solid transparent;
  }

  &--content { 
    padding: 24px !important;
  
    .language- {
      border: none;
      padding: 0px !important;
      overflow-y: hidden !important;
      overflow-x: hidden !important;
    }
  }
}

// Code
.vp-doc :not(pre, h1, h2, h3, h4, h5, h6) > code {
  font-size: var(--vp-code-font-size);
  color: var(--vp-code-color);
}

.vp-doc :not(pre) > code {
  border-radius: 4px;
  padding: 3px 6px;
  background-color: var(--vp-code-bg);
  transition:
    color 0.25s,
    background-color 0.5s;
}

.vp-doc a > code {
  color: var(--vp-code-link-color);
}

.vp-doc a:hover > code {
  color: var(--vp-code-link-hover-color);
}

.vp-doc h1 > code,
.vp-doc h2 > code,
.vp-doc h3 > code {
  font-size: 0.9em;
}

.vp-doc div[class*='language-'],
.vp-block {
  position: relative;
  margin: 16px -24px;
  background-color: transparent;
  overflow-x: auto;
  transition: background-color 0.5s;
}

@media (min-width: 640px) {
  .vp-doc div[class*='language-'],
  .vp-block {
    border-radius: 12px;
    margin: 16px 0;
  }
}

@media (max-width: 639px) {
  .vp-doc li div[class*='language-'] {
    border-radius: 8px 0 0 8px;
  }
}

.vp-doc div[class*='language-'] + div[class*='language-'],
.vp-doc div[class$='-api'] + div[class*='language-'],
.vp-doc div[class*='language-'] + div[class$='-api'] > div[class*='language-'] {
  margin-top: -8px;
}

.vp-doc [class*='language-'] pre,
.vp-doc [class*='language-'] code {
  /*rtl:ignore*/
  direction: ltr;
  /*rtl:ignore*/
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  -moz-tab-size: 4;
  -o-tab-size: 4;
  tab-size: 4;
  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

.vp-doc [class*='language-'] pre {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 24px;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid $color-border;
}

.vp-doc [class*='language-'] code {
  display: block;
  padding: 0px;
  width: fit-content;
  min-width: 100%;
  line-height: var(--vp-code-line-height);
  font-size: var(--vp-code-font-size);
  color: var(--vp-code-color);
  transition: color 0.5s;
}

.vp-doc [class*='language-'] code .highlighted {
  background-color: var(--vp-code-line-highlight-color);
  transition: background-color 0.5s;
  margin: 0 -24px;
  padding: 0 24px;
  width: calc(100% + 2 * 24px);
  display: inline-block;
}

.vp-doc [class*='language-'] code .highlighted.error {
  background-color: var(--vp-code-line-error-color);
}

.vp-doc [class*='language-'] code .highlighted.warning {
  background-color: var(--vp-code-line-warning-color);
}

.vp-doc [class*='language-'] code .diff {
  transition: background-color 0.5s;
  margin: 0 -24px;
  padding: 0 24px;
  width: calc(100% + 2 * 24px);
  display: inline-block;
}

.vp-doc [class*='language-'] code .diff::before {
  position: absolute;
  left: 10px;
}

.vp-doc [class*='language-'] .has-focused-lines .line:not(.has-focus) {
  filter: blur(0.095rem);
  opacity: 0.4;
  transition:
    filter 0.35s,
    opacity 0.35s;
}

.vp-doc [class*='language-'] .has-focused-lines .line:not(.has-focus) {
  opacity: 0.7;
  transition:
    filter 0.35s,
    opacity 0.35s;
}

.vp-doc [class*='language-']:hover .has-focused-lines .line:not(.has-focus) {
  filter: blur(0);
  opacity: 1;
}

.vp-doc [class*='language-'] code .diff.remove {
  background-color: var(--vp-code-line-diff-remove-color);
  opacity: 0.7;
}

.vp-doc [class*='language-'] code .diff.remove::before {
  content: '-';
  color: var(--vp-code-line-diff-remove-symbol-color);
}

.vp-doc [class*='language-'] code .diff.add {
  background-color: var(--vp-code-line-diff-add-color);
}

.vp-doc [class*='language-'] code .diff.add::before {
  content: '+';
  color: var(--vp-code-line-diff-add-symbol-color);
}

.vp-doc div[class*='language-'].line-numbers-mode {
  /*rtl:ignore*/
  padding-left: 32px;
}

.vp-doc .line-numbers-wrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  /*rtl:ignore*/
  left: 0;
  z-index: 3;
  /*rtl:ignore*/
  border-right: 1px solid var(--vp-code-block-divider-color);
  padding-top: 20px;
  width: 32px;
  text-align: center;
  font-family: var(--vp-font-family-mono);
  line-height: var(--vp-code-line-height);
  font-size: var(--vp-code-font-size);
  color: var(--vp-code-line-number-color);
  transition:
    border-color 0.5s,
    color 0.5s;
}

.vp-doc [class*='language-'] > button.copy {
  /*rtl:ignore*/
  direction: ltr;
  position: absolute;
  top: 12px;
  /*rtl:ignore*/
  right: 12px;
  z-index: 3;
  border: none;
  width: 40px;
  height: 40px;
  background-color: transparent;
  opacity: 1;
  cursor: pointer;
  background-image: var(--vp-icon-copy);
  background-position: 50%;
  background-size: 20px;
  background-repeat: no-repeat;
  transition:
    border-color 0.25s,
    background-color 0.25s,
    opacity 0.25s;
}

.vp-doc [class*='language-']:hover > button.copy,
.vp-doc [class*='language-'] > button.copy:focus {
  opacity: 1;
}

.vp-doc [class*='language-'] > button.copy:hover,
.vp-doc [class*='language-'] > button.copy.copied {
  border: none;
  background-color: transparent;
}

.vp-doc [class*='language-'] > button.copy.copied,
.vp-doc [class*='language-'] > button.copy:hover.copied {
  /*rtl:ignore*/
  background-color: transparent;
  background-image: none;
}

.vp-doc [class*='language-'] > button.copy.copied::before,
.vp-doc [class*='language-'] > button.copy:hover.copied::before {
  position: relative;
  top: -1px;
  /*rtl:ignore*/
  transform: translateX(calc(-100% - 1px));
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  /*rtl:ignore*/
  border-right: 0;
  padding: 0 10px;
  width: fit-content;
  height: 40px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--vp-code-copy-code-active-text);
  white-space: nowrap;
  content: '';
}

.vp-doc [class*='language-'] > span.lang {
  position: absolute;
  top: 2px;
  /*rtl:ignore*/
  right: 8px;
  z-index: 2;
  font-size: 12px;
  font-weight: 500;
  color: var(--vp-code-lang-color);
  transition:
    color 0.4s,
    opacity 0.4s;
}

.vp-doc [class*='language-']:hover > button.copy + span.lang,
.vp-doc [class*='language-'] > button.copy:focus + span.lang {
  opacity: 0;
}

// Banner
.vp-doc .custom-block {
  margin: 40px 0;
}

.vp-doc .custom-block p {
  margin: 8px 0;
  line-height: 18px;
}

.vp-doc .custom-block p:first-child {
  margin: 0;
}

.vp-doc .custom-block div[class*='language-'] {
  margin: 8px 0;
  border-radius: 12px;
}

.vp-doc .custom-block div[class*='language-'] code {
  font-weight: 400;
  background-color: transparent;
}

.vp-doc .custom-block .vp-code-group .tabs {
  margin: 0;
  border-radius: 8px 8px 0 0;
}

// Table
.vp-doc table {
  display: block;
  border-collapse: collapse;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid $color-border;
  // width: 100%;
  margin: 24px 0;
}

.vp-doc tr {
  border-top: hidden;
  transition: background-color 0.5s;
}

.vp-doc tr:nth-child(2n) {
  background-color: var(--vp-c-bg-soft);
}

.vp-doc th,
.vp-doc td {
  padding: 18px 16px;
  padding: 18px 16px;
  width: 100vh;
  background-color: var(--vp-c-bg);
  border: none;
}

.vp-doc tbody tr {
  border-top: 1px solid $color-border;

  &:last-child{
    border-bottom: hidden;
  }
}

.vp-doc th {
  @include font_style(15px, 500, 20px, 0.2px);
  color: $color-text-active;
  background-color: var(--vp-c-bg);
  border-top: 1px solid $color-border;
}

.vp-doc td {
  @include font_style(15px, 400, 18px, 0.2px);
  padding: 18px 16px;
  background-color: var(--vp-c-bg);
  border-right: hidden;
  border-left: hidden;
  color: $color-text-active;
}

// Block
.vp-doc .custom-block {
  margin: 16px 0;
}

.vp-doc .custom-block p {
  margin: 8px 0;
  line-height: 24px;
}

.vp-doc .custom-block p:first-child {
  margin: 0;
}

.vp-doc .custom-block div[class*='language-'] {
  margin: 40px 0;
  border-radius: 12px;

  &.vp-doc .custom-block {
    margin: 0;
    border: none;
  }
}

.vp-doc .custom-block div[class*='language-'] code {
  font-weight: 400;
  background-color: transparent;
}

.vp-doc .custom-block .vp-code-group .tabs {
  margin: 0;
  border-radius: 8px 8px 0 0;
}
