@use "@coreui/coreui/scss/mixins/border-radius" as *;
@use "@coreui/coreui/scss/mixins/breakpoints" as *;
@use "@coreui/coreui/scss/mixins/clearfix" as *;
@use "@coreui/coreui/scss/mixins/container" as *;
@use "@coreui/coreui/scss/mixins/grid" as *;
@use "@coreui/coreui/scss/vendor/rfs" as *;
@use "@coreui/coreui/scss/variables" as *;
@use "variables" as *;

//
// Docs examples
//

.docs-code-tabs {
  padding: 0 ($cd-gutter-x * .5);
  margin: 0 ($cd-gutter-x * -.5);

  @include media-breakpoint-up(md) {
    padding: 0;
    margin: 0;
  }
}

.docs-code-tab-content {
  .tab-pane > .docs-code-snippet,
  .tab-pane > .highlight {
    border-top: 0;
    @include border-top-radius(0);

    .highlight {
      @include border-top-radius(0);
    }
  }
}

.docs-example-snippet {
  border: solid var(--cui-border-color);
  border-width: 1px 0;
  margin: 0 ($cd-gutter-x * -.5) 1rem ($cd-gutter-x * -.5);
  padding: 0;
  @include border-radius(0);

  .docs-example {
    margin: 0;
    padding: 1rem;
    border-width: 0 1px 0 0;
  }

  .highlight-toolbar {
    border-top: 1px solid var(--cui-border-color);
  }

  .highlight {
    margin: 0;
    padding: 1rem;
  }

  .docs-example,
  .highlight {
    border: 0
  }

  .highlight {
    margin-bottom: 0;
    @include border-top-radius(0);
  }

  @include media-breakpoint-up(sm) {
    margin: 0 0 1rem 0;
    border-width: 1px;
    @include border-radius(var(--cui-border-radius));
  }
}

.docs-example {
  --cd-example-padding: 1rem;

  position: relative;
  padding: var(--cd-example-padding);
  margin: 0 ($cd-gutter-x * -.5);
  border: solid var(--cui-border-color);
  border-width: 1px 0;
  @include clearfix();

  @include media-breakpoint-up(md) {
    --cd-example-padding: 1.5rem;

    margin-right: 0;
    margin-left: 0;
    border-width: 1px;
    @include border-top-radius(var(--cui-border-radius));
  }

  + .docs-code-snippet {
    @include border-top-radius(0);
    border: solid var(--cui-border-color);
    border-width: 0 1px 1px;
  }

  + p {
    margin-top: 2rem;
  }

  > .form-control {
    + .form-control {
      margin-top: .5rem;
    }
  }

  > .nav + .nav,
  > .alert + .alert,
  > .navbar + .navbar,
  > .progress + .progress {
    margin-top: $spacer;
  }

  > .dropdown-menu {
    position: static;
    display: block;
  }

  > :last-child,
  > nav:last-child .breadcrumb {
    margin-bottom: 0;
  }

  > hr:last-child {
    margin-bottom: $spacer;
  }

  // Images
  > svg + svg,
  > img + img {
    margin-left: .5rem;
  }

  // Avatars
  > .avatar + .avatar {
    margin-left: .25rem;
  }

  // Badges
  > .badge + .badge {
    margin-left: .25rem;
  }

  // Buttons
  > .btn,
  > .btn-group {
    margin: .25rem .125rem;
  }
  > .btn-toolbar + .btn-toolbar {
    margin-top: .5rem;
  }

  // List groups
  > .list-group {
    max-width: 400px;
  }

  > [class*="list-group-horizontal"] {
    max-width: 100%;
  }

  // Navbars
  .fixed-top,
  .sticky-top {
    position: static;
    margin: calc(var(--cd-example-padding) * -1) calc(var(--cd-example-padding) * -1) var(--cd-example-padding); // stylelint-disable-line function-disallowed-list
  }

  .fixed-bottom,
  .sticky-bottom {
    position: static;
    margin: var(--cd-example-padding) calc(var(--cd-example-padding) * -1) calc(var(--cd-example-padding) * -1); // stylelint-disable-line function-disallowed-list

  }

  // Pagination
  .pagination {
    margin-bottom: 0;
  }

  // Spinners
  > .spinner-grow + .spinner-border,
  > .spinner-border + .spinner-grow,
  > .spinner-border + .spinner-border,
  > .spinner-grow + .spinner-grow {
    margin-left: .25rem;
  }

  // Sidebar
  .sidebar-narrow,
  .sidebar-narrow-unfoldable {
    position: static;
  }

  .sidebar-narrow-unfoldable {
    min-height: 550px;
  }
}

//
// Grid examples
//

.docs-example-row [class^="col"],
.docs-example-cols [class^="col"] > *,
.docs-example-cssgrid [class*="grid"] > * {
  padding-top: .75rem;
  padding-bottom: .75rem;
  background-color: rgba(var(--cd-violet-rgb), .15);
  border: 1px solid rgba(var(--cd-violet-rgb), .3);
}

.docs-example-row .row + .row,
.docs-example-cssgrid .grid + .grid {
  margin-top: 1rem;
}

.docs-example-row-flex-cols .row {
  min-height: 10rem;
  background-color: rgba(var(--cd-violet-rgb), .15);
}

.docs-example-flex div:not(.vr) {
  background-color: rgba(var(--cd-violet-rgb), .15);
  border: 1px solid rgba(var(--cd-violet-rgb), .3);
}

// Grid mixins
.example-container {
  width: 800px;
  @include make-container();
}

.example-row {
  @include make-row();
}

.example-content-main {
  @include make-col-ready();

  @include media-breakpoint-up(sm) {
    @include make-col(6);
  }

  @include media-breakpoint-up(lg) {
    @include make-col(8);
  }
}

.example-content-secondary {
  @include make-col-ready();

  @include media-breakpoint-up(sm) {
    @include make-col(6);
  }

  @include media-breakpoint-up(lg) {
    @include make-col(4);
  }
}

// Ratio helpers
.docs-example-ratios {
  .ratio {
    display: inline-block;
    width: 10rem;
    color: var(--cui-secondary-color);
    background-color: var(--cui-tertiary-bg);
    border: var(--cui-border-width) solid var(--cui-border-color);

    > div {
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
.docs-example-ratios-breakpoint {
  .ratio-4x3 {
    width: 16rem;

    @include media-breakpoint-up(md) {
      --cui-aspect-ratio: 50%; // 2x1
    }
  }
}

.docs-example-offcanvas {
  .offcanvas {
    position: static;
    display: block;
    height: 200px;
    visibility: visible;
    transform: translate(0);
  }
}

// Tooltips
.tooltip-demo {
  a {
    white-space: nowrap;
  }

  .btn {
    margin: .25rem .125rem;
  }
}

// scss-docs-start custom-tooltip
.custom-tooltip {
  --cui-tooltip-bg: var(--cui-primary);
}
// scss-docs-end custom-tooltip

// scss-docs-start custom-popovers
.custom-popover {
  --cui-popover-max-width: 200px;
  --cui-popover-border-color: var(--cui-primary);
  --cui-popover-header-bg: var(--cui-primary);
  --cui-popover-header-color: var(--cui-white);
  --cui-popover-body-padding-x: 1rem;
  --cui-popover-body-padding-y: .5rem;
}
// scss-docs-end custom-popovers

// Scrollspy demo on fixed height div
.scrollspy-example {
  height: 200px;
  margin-top: .5rem;
  overflow: auto;
}

.scrollspy-example-2 {
  height: 350px;
  overflow: auto;
}

.simple-list-example-scrollspy {
  .active {
    background-color: rgba(var(--cd-violet-rgb), .15);
  }
}

.docs-example-border-utils {
  [class^="border"] {
    display: inline-block;
    width: 5rem;
    height: 5rem;
    margin: .25rem;
    background-color: var(--cui-tertiary-bg);
  }
}

.docs-example-rounded-utils {
  [class*="rounded"] {
    margin: .25rem;
  }
}

.docs-example-position-utils {
  position: relative;
  padding: 2rem;

  .position-relative {
    height: 200px;
    background-color: var(--cui-tertiary-bg);
  }

  .position-absolute {
    width: 2rem;
    height: 2rem;
    background-color: var(--cui-body-color);
    @include border-radius();
  }
}

.docs-example-position-examples {
  &::after {
    content: none;
  }
}

// Placeholders
.docs-example-placeholder-cards {
  &::after {
    display: none;
  }

  .card {
    width: 18rem;
  }
}

// Toasts
.docs-example-toasts {
  min-height: 240px;
}

.docs-example-zindex-levels {
  min-height: 15rem;

  > div {
    color: var(--cui-body-bg);
    background-color: var(--cd-violet);
    border: 1px solid var(--cd-purple);

    > span {
      position: absolute;
      right: 5px;
      bottom: 0;
    }
  }

  > :nth-child(2) {
    top: 3rem;
    left: 3rem;
  }
  > :nth-child(3) {
    top: 4.5rem;
    left: 4.5rem;
  }
  > :nth-child(4) {
    top: 6rem;
    left: 6rem;
  }
  > :nth-child(5) {
    top: 7.5rem;
    left: 7.5rem;
  }
}

//
// Code snippets
//

.highlight {
  position: relative;
  padding: .75rem ($cd-gutter-x * .5);
  margin: 0 ($cd-gutter-x * -.5) 1rem ($cd-gutter-x * -.5) ;
  border: 1px solid var(--cui-border-color);
  background-color: var(--cd-pre-bg);

  @include media-breakpoint-up(md) {
    padding: .75rem 1.25rem;
    margin-right: 0;
    margin-left: 0;
    @include border-radius(var(--cui-border-radius));
  }

  pre {
    padding: .25rem 0 .875rem;
    margin-top: .8125rem;
    margin-bottom: 0;
    overflow: overlay;
    white-space: pre;
    background-color: transparent;
    border: 0;
  }

  pre code {
    @include font-size(inherit);
    color: var(--cui-body-color); // Effectively the base text color
    word-wrap: normal;
  }
}

.docs-code-snippet {
  margin: 0 ($cd-gutter-x * -.5) $spacer;

  .highlight {
    margin: 0;
  }

  .docs-example ~ .highlight {
    border: solid var(--cui-border-color);
    border-width: 1px 0 0;
    @include border-top-radius(0);
  }

  .docs-example {
    margin: 0;
    border: 0;
  }

  @include media-breakpoint-up(md) {
    margin-right: 0;
    margin-left: 0;
    @include border-radius($border-radius);
  }
}

.highlight-toolbar {
  background-color: var(--cd-pre-bg);
}

.docs-scss-docs {
  .highlight-toolbar {
    @include border-top-radius(calc(var(--cui-border-radius) + 1px));
  }
}

.docs-example + .highlight {
  border-top-width: 0;
  @include border-top-radius(0);
}
