// Variables for tab styling
$tab-border-color: rgba(0, 0, 0, 0.15);
$tab-active-color: $ddpurple;
$tab-hover-bg: rgba($ddpurple, 0.05);
$tab-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
$tab-active-shadow: 0 -4px 12px rgba(99, 44, 166, 0.08);

// Multi-code-lang tabs specific styles
.code-lang-list-container {
  background: #fff;
  z-index: 2;
  position: relative;
  border-bottom: none;
  margin-bottom: 0;
  padding: 0;
  padding-left: 0 !important;
  margin-left: 0 !important;

  ul, ol {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-top: 6px;
  }

  .nav-item {
    margin-right: 10px;
    padding-bottom: 6px;

    .nav-link {
      background: #fff;
      border: none;
      color: #444;
      font-size: 16px;
      font-weight: 600;
      padding: 6px 10px 7px 10px;
      border-radius: 3px;
      display: inline-block;
      margin-right: 0.625rem;
      transition: all 0.2s ease;

      &:hover {
        box-shadow: 2px 5px 12px rgba(0, 0, 0, 0.1);
        border: none;
        color: $tab-active-color;
        background: #fff;
      }

      &.active {
        background: $tab-active-color;
        color: #fff;
        box-shadow: 2px 5px 12px rgba(0, 0, 0, 0.1);
        border-radius: 3px;
        border: none;
      }
    }
  }

  .nav-item::before {
    content: none !important;
    display: none !important;
  }

  li::marker {
    content: none;
    display: none;
  }
}

// API docs response toggle specific styles
.nav-tabs.response-toggle {
  margin-bottom: 20px;
  border-bottom: none;

  .nav-item {
    margin-right: 10px;
    padding-bottom: 6px;

    .nav-link {
      background: #fff;
      border: none;
      color: #444;
      font-size: 16px;
      font-weight: 600;
      padding: 6px 10px 7px 10px;
      border-radius: 3px;
      display: inline-block;
      margin-right: 0.625rem;
      transition: all 0.2s ease;

      &:hover {
        box-shadow: 2px 5px 12px rgba(0, 0, 0, 0.1);
        border: none;
        color: $tab-active-color;
        background: #fff;
      }

      &[aria-expanded="true"], &.active {
        background: $tab-active-color;
        color: #fff;
        box-shadow: 2px 5px 12px rgba(0, 0, 0, 0.1);
        border-radius: 3px;
        border: none;
      }
    }
  }
}

// Fix for dashboard nav-tabs being affected by .main ul li:before rule
.nav-tabs.response-toggle {
  .nav-item {
    &::before {
      content: none !important;
      display: none !important;
    }
  }

  // Align Widget Model tab buttons with content in main pages
  .main & {
    padding-left: 0 !important;
    margin-left: 0 !important;
  }
}

// Common tab styles
.code-tabs {
  position: relative;
  min-height: 200px;
  padding-top: 8px;

  // Base styles for all tab links - provides consistent padding, font, and positioning
  %tab-link-base {
    background: transparent;
    border: 1px solid transparent;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 16px;
    display: inline-block;
    position: relative;
    color: rgba(0, 0, 0, 0.6);
    outline: none !important;
    transition: none;

    &:focus {
      outline: none !important;
      box-shadow: none !important;
    }
  }

  // Styles for the currently active tab - includes white background, purple text, and subtle shadow
  %active-tab-base {
    background: #FFFFFF;
    color: $tab-active-color;
    box-shadow: $tab-active-shadow;
    border: 1px solid $tab-border-color;
    border-bottom-color: #FFFFFF;
    font-weight: 600;
    position: relative;
    z-index: 3;
    margin-bottom: -1px;
    padding-bottom: 9px;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    outline: none !important;
    transition: none;

    &:focus {
      outline: none !important;
      box-shadow: $tab-active-shadow !important;
    }
  }

  // Container for tab content - white background with border and shadow
  .tab-content {
    background: #FFFFFF;
    border: 1px solid $tab-border-color;
    padding: 24px;
    z-index: 0;
    position: relative;
    margin: -1px 0 32px 0;
    box-shadow: $tab-shadow;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    border-top: 1px solid $tab-border-color;

    dl {
      background-color: transparent;
    }

    h2 > a,
    h3 > a,
    h4 > a,
    h5 > a {
      color: #000;
      border-bottom: 1px solid transparent;
      &:hover {
        color: #000;
        border-bottom: 1px solid #000;
      }
    }

    .text-center img {
      border: 1px solid $ddgray;
      border-radius: 8px;
    }

    .card-body img {
      border: 0px solid $ddgray;
    } 
  }

  // Horizontal tab navigation container
  .nav-tabs {
    list-style-type: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 0;
    position: relative;
    z-index: 2;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    border-bottom: none;
    padding-left: 0 !important;
    overflow-y: hidden;

    &::-webkit-scrollbar {
      height: 4px;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.2);
      border-radius: 4px;
    }

    li {
      padding: 0;
      position: relative;
      flex: 0 0 auto;
      white-space: nowrap;
      box-sizing: border-box;

      &:before {
        content: '' !important;
        margin: 0 !important;
        float: none !important;
      }

      &:lang(ja) {
        font-style: normal;
        font-weight: bold;
        font-size: 14px;
        line-height: 24px;
      }

      &.active {
        z-index: 3;

        a {
          @extend %active-tab-base;
          transition: none;
          box-sizing: border-box;

          // Gradient line indicator for active tab
          &:after {
            content: '';
            position: absolute;
            top: -1px;
            left: -1px;
            width: calc(100% + 2px);
            height: 3px;
            background: linear-gradient(90deg, $tab-active-color, lighten($tab-active-color, 20%));
            border-radius: 3px 3px 0 0;
          }

          &:hover {
            color: $tab-active-color;
            transition: none;
          }

          &::before {
            display: none;
          }
        }
      }

      &:not(.active) {
        a {
          transition: none;
          box-sizing: border-box;

          &:hover {
            color: $tab-active-color;
            background: $tab-hover-bg;
            border-color: transparent;
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            transition: color 0.2s ease, background-color 0.2s ease;
          }
        }
      }

      a {
        @extend %tab-link-base;
        box-sizing: border-box;

        // Subtle gradient overlay effect on hover
        &::before {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background: linear-gradient(45deg, rgba(255,255,255,0.2), rgba(255,255,255,0));
          opacity: 0;
          transition: opacity 0.3s ease;
        }

        &:active {
          box-shadow: 0 -2px 8px rgba(99, 44, 166, 0.15);
        }
      }
    }
  }

  // Mobile tabs
  .nav-tabs-mobile {
    .dropdown-item:hover {
      color: $tab-active-color;
    }
  }

  // Wrapped tabs layout - Matches customizable docs style
  &.tabs-wrap-layout {
    .nav-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      border-bottom: none;
      margin-bottom: 16px;
      padding-top: 10px;
      min-height: 40px;
      overflow-x: visible;
      overflow-y: hidden;

      li {
        margin-bottom: 6px;
        flex: 0 0 auto;
        box-sizing: border-box;

        &.active a {
          color: white;
          background-color: $tab-active-color;
          border: 1px solid $tab-active-color;
          box-shadow: none;
          border-radius: 4px;
          padding: 0 10px;
          font-weight: 400;
          font-size: 16px;
          height: 31px;
          display: inline-flex;
          align-items: center;
          transition: none;
          box-sizing: border-box;

          // Remove gradient line for wrapped tabs
          &:after {
            display: none;
          }

          &:hover {
            transition: none;
          }
        }

        &:not(.active) a {
          color: black;
          background-color: white;
          border: 1px solid rgb(199, 199, 199);
          border-radius: 4px;
          display: inline-flex;
          align-items: center;
          margin-right: 0;
          cursor: pointer;
          font-weight: 400;
          font-size: 16px;
          height: 31px;
          padding: 0 10px;
          position: relative;
          overflow: visible;
          transition: none;
          box-sizing: border-box;

          &:hover {
            color: $tab-active-color;
            transition: color 0.2s ease;
          }

          &:active {
            box-shadow: none;
          }
        }

        &::before {
          content: "";
        }
      }
    }

    .tab-content {
      margin-top: 0;
      border-radius: 4px;
    }
  }
}

.code-tabs .nav-tabs,
.code-tabs .code-lang-list-container {
  position: relative;
  border-bottom: none;
  background: #fff;
  z-index: 2;
}

.code-tabs .nav-tabs::after,
.code-tabs .code-lang-list-container::after {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  border-bottom: 1px solid $tab-border-color;
  z-index: 1;
  pointer-events: none;
}

.code-tabs .nav-tabs li,
.code-tabs .code-lang-list-container li {
  border-bottom: none;
}

.code-tabs .nav-tabs li.active,
.code-tabs .code-lang-list-container li.active {
  border-bottom: none;
}

.code-tabs .nav-tabs li.active a {
  background: #fff;
  margin-bottom: -1px;
  position: relative;
  z-index: 3;
  display: block;
  border-bottom: 1px solid #fff;
}

.code-tabs .nav-tabs li {
  height: 100%;
}

// Hide the bottom border line under the tabs when wrapped
.code-tabs.tabs-wrap-layout .nav-tabs::after,
.code-tabs.tabs-wrap-layout .code-lang-list-container::after {
  display: none;
}

// API pages specific to keep tabs under left nav search window
.code-tabs.api-reference {
  .nav-tabs {
    z-index: 1;
  }
}