@import '../variables';

:root {
  --itf-tabs-active-bg: #fff;
  --itf-tabs-active-color: #222;
  --itf-tabs-active-border-color: #{$primary};
  --itf-tabs-inactive-bg: #fafafa;
  --itf-tabs-inactive-color: #222;
  --itf-tabs-inactive-border-color: rgba(0, 0, 0, .1);
  --itf-tabs-hover-bg: #F4F7F9;
  --itf-tabs-hover-color: #222;
  --itf-tabs-hover-border-color: rgba(0, 0, 0, .5);
  --itf-tabs-tab-padding: 10px;

  --itf-tabs-content-bg: #fff;
  --itf-tabs-panel-width: 300px;
}

.itf-tabs {

  &.itf-tabs__simple > .itf-tabs-panel {
    padding-left: 0 !important;
    border-bottom: 1px solid var(--itf-tabs-inactive-border-color);
  }
  .itf-tab__simple {
    text-decoration: none;
    color: var(--bs-gray-500);
    border-bottom: 0px solid transparent;
    position: relative;
    padding: 0.5rem 1rem;

    &:after {
      content: "";
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 0px;
      background-color: var(--bs-body-color);
      transition: height 0.3s ease;
    }

    [data-theme="dark"] & {
      color: var(--bs-gray-700);
    }

    &.active {
      color: var(--bs-body-color);
      &:after {
        height: 4px;
      }
    }
  }
  &.itf-tabs__vertical {
    display: flex;
    flex-direction: row-reverse;

    & > .itf-tabs-panel {
      flex-direction: column;
      width: var(--itf-tabs-panel-width);
      padding-top: 12px;
      padding-left: 0;
      margin-right: 0;
      padding-bottom: calc(var(--itf-tabs-tab-padding) * 3);

      & > .itf-tab {
        padding: var(--itf-tabs-tab-padding) 10px 0;
        width: calc(100% - 2px);
        margin-bottom: calc(var(--itf-tabs-tab-padding) * 1.5);

        &, &:before, &:after {
          border-top: 0 none;
          border-right: 1px solid var(--itf-tabs-inactive-border-color);
        }
        &:after {
          border-radius: 0 8px 0 0;
          top: -5px;
          box-shadow: rgb(0,0,0,.05) 1px -2px 1px, inset rgb(255 255 255 / 9%) 0 1px;
        }
        &:before {
          border-radius: 0 0 8px 0;
          transform: skew(0deg, -1deg);
          top: auto;
          bottom: -12px;
          box-shadow: rgba(0,0,0,.05) 1px 2px 1px, inset rgba(255,255,255,.09) 0 -1px;
        }
        &:before, &:after {
          height: calc(var(--itf-tabs-tab-padding) * 4);
          width: calc(100% + 2px);
          left: -1px;
          border-top: 0 none;
          border-right: 1px solid var(--itf-tabs-inactive-border-color);
        }
        &.active {
          &, &:before, &:after {
            border-top: 0 none;
            border-right: 1px solid var(--itf-tabs-active-border-color);
          }
          &:after {
            box-shadow: rgb(0 0 0 / 10%) 2px -3px 5px, inset rgb(255 255 255 / 9%) 0 1px;
          }
          &:before {
            box-shadow: rgba(0,0,0,.1) 2px 3px 5px, inset rgba(255,255,255,.09) 0 -1px;
          }
        }
        &:hover, &:hover:before, &:hover:after,
        &:focus, &:focus:before, &:focus:after {
          border-top: 0 none;
          border-right: 1px solid var(--itf-tabs-hover-border-color);
        }
      }
    }
    & > .itf-tabs-content {
      flex-grow: 1;
      z-index: 1;
      margin-right: -1px;

      @include media-breakpoint-up(lg) {
        max-width: calc(100% - var(--itf-tabs-panel-width));
      }
    }
  }

  & > .itf-tabs-panel {
    margin: 0;
    padding: 0;
    overflow: hidden;
    padding-left: calc(var(--itf-tabs-tab-padding) * 2.1);
    display: flex;
    flex-direction: row-reverse;
    justify-content: start;
    flex-wrap: wrap;

    & > .itf-tab {
      white-space: nowrap;
      display: block;
      //float: right;
      padding: 10px var(--itf-tabs-tab-padding) 8px;
      margin-right: calc(var(--itf-tabs-tab-padding) * 3);
      z-index: 2;
      position: relative;
      cursor: pointer;
      transition: all 250ms ease;
      border-radius: 8px 8px 0 0;
      background-color: var(--itf-tabs-inactive-bg);
      color: var(--itf-tabs-inactive-color);
      border-top: 1px solid var(--itf-tabs-inactive-border-color);
      tab-index: 0;
      text-decoration: none;
      outline: 0 none;

      & > span {
        position: relative;
        z-index: 4;
        opacity: .75;
        display: block;
      }
      &:before, &:after {
        display: block;
        content: " ";
        position: absolute;
        top: -1px;
        height: calc(100% + 1px);
        width: calc(var(--itf-tabs-tab-padding) * 5);
        background-color: var(--itf-tabs-inactive-bg);
        color: var(--itf-tabs-inactive-color);
        border-top: 1px solid var(--itf-tabs-inactive-border-color);
        transition: all 250ms ease;
      }
      &:before {
        right: calc(var(--itf-tabs-tab-padding) * -2);
        border-radius: 0 8px 0 0;
        transform: skew(30deg, 0deg);
        box-shadow: rgba(0,0,0,.1) 3px 2px 5px, inset rgba(255,255,255,.09) -1px 0;
      }
      &:after {
        left: calc(var(--itf-tabs-tab-padding) * -2);
        border-radius: 8px 0 0 0;
        //transform: skew(-30deg, 0deg);
        box-shadow: rgba(0,0,0,.1) -3px 2px 5px, inset rgba(255,255,255,.09) 1px 0;
      }
      &:hover, &:hover:before, &:hover:after,
      &:focus, &:focus:before, &:focus:after {
        background-color: var(--itf-tabs-hover-bg);
        color: var(--itf-tabs-hover-color);
        border-top: 1px solid var(--itf-tabs-hover-border-color);

        & > span {
          opacity: 1;
        }
      }
      &.active {
        z-index: 3;

        & > span {
          opacity: 1;
        }
        &, &:before, &:after {
          background-color: var(--itf-tabs-active-bg);
          color: var(--itf-tabs-active-color);
          border-top: 1px solid var(--itf-tabs-active-border-color);
        }
      }
    }
  }
  .itf-tabs-content {
    & > .itf-tab-content {
      height: 100%;

      &.filled {
        background: var(--itf-tabs-content-bg);
        border: 1px solid var(--itf-tabs-inactive-border-color);
        margin-top: -1px;
        border-bottom-left-radius: $border-radius;
        border-bottom-right-radius: $border-radius;
      }
    }
  }
}
