import { css } from 'lit';
import componentStyles from '../../styles/component.styles.mjs';

const styles = css`
  ${componentStyles}

  :host {
    --indicator-color: var(--flow-ui-color-primary-500);
    --track-color: var(--flow-ui-divider-color);
    --track-width: 2px;
    display: flex;
  }

  .tab-group {
    display: flex;
    flex: 1;
    justify-content: start;
    border-radius: 0;
    overflow: hidden;
  }

  /* Ensure nav is positioned when tab-group is placed in a split panel and the panel is closed */
  .tab-group--end,
  .tab-group--bottom {
    justify-content: end;
  }

  .tab-group__nav-container {
    display: flex;
    flex: 0 0 auto;
    position: relative;
  }

  .tab-group__nav {
    flex: 1;
    /* Hide scrollbar in Firefox */
    scrollbar-width: none;
  }

  .tab-group__nav::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  .tab-group__nav-accessories {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
  }

  .tab-group__accessory-divider {
    --spacing: var(--flow-ui-spacing-x-small);
    --inset: var(--flow-ui-spacing-x-small);
  }

  .tab-group__tabs {
    display: flex;
    position: relative;
    align-items: end;
  }

  .tab-group__track {
    position: absolute;
  }

  .tab-group__indicator {
    position: absolute;
    transition:
      var(--flow-ui-transition-fast) translate ease,
      var(--flow-ui-transition-fast) width ease;
  }

  .tab-group__body-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .tab-group__body {
    display: block;
    flex: 1;
    overflow: auto;
  }

  .tab-group__scroll-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--flow-ui-spacing-x-large);
  }

  /* Make tab panels take up full height */
  ::slotted(flow-ui-tab-panel) {
    height: 100%;
  }

  /*
   * Top
   */

  .tab-group--top {
    flex-direction: column;

    /* Prevent horizontal tabs from wrapping label */
    --flow-ui-tab-max-width: 100%;
  }

  .tab-group--top .tab-group__nav-container {
    order: 1;
  }

  .tab-group--top .tab-group__track {
    width: 100%;
    bottom: 0;
    border-bottom: solid var(--track-width) var(--track-color);
  }

  .tab-group--top .tab-group__nav-accessories {
    padding-bottom: var(--track-width);
  }

  .tab-group--top .tab-group__nav-accessories--start {
    padding-inline-start: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--top .tab-group__nav-accessories--end {
    padding-inline-end: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--top .tab-group__nav {
    display: flex;
    overflow-x: auto;
  }

  .tab-group--top .tab-group__tabs {
    flex: 1 1 auto;
    position: relative;
    flex-direction: row;
    border-bottom: solid var(--track-width) var(--track-color);
  }

  .tab-group--top .tab-group__scroll-button {
    border-bottom: solid var(--track-width) var(--track-color);
  }

  .tab-group--top .tab-group__indicator {
    bottom: calc(-1 * var(--track-width));
    border-bottom: solid var(--track-width) var(--indicator-color);
  }

  .tab-group--top .tab-group__body-wrapper {
    order: 2;
  }

  .tab-group--top ::slotted(flow-ui-tab-panel) {
    --padding: var(--flow-ui-spacing-medium) 0;
  }

  /*
   * Bottom
   */

  .tab-group--bottom {
    flex-direction: column;

    /* Prevent horizontal tabs from wrapping label */
    --flow-ui-tab-max-width: 100%;
  }

  .tab-group--bottom .tab-group__nav-container {
    order: 2;
  }

  .tab-group--bottom .tab-group__track {
    width: 100%;
    top: 0;
    border-top: solid var(--track-width) var(--track-color);
  }

  .tab-group--bottom .tab-group__nav-accessories {
    padding-top: var(--track-width);
  }

  .tab-group--bottom .tab-group__nav-accessories--start {
    padding-inline-start: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--bottom .tab-group__nav-accessories--end {
    padding-inline-end: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--bottom .tab-group__nav {
    overflow-x: auto;
  }

  .tab-group--bottom .tab-group__tabs {
    flex: 1 1 auto;
    position: relative;
    flex-direction: row;
    border-top: solid var(--track-width) var(--track-color);
  }

  .tab-group--bottom .tab-group__scroll-button {
    border-top: solid var(--track-width) var(--track-color);
  }

  .tab-group--bottom .tab-group__indicator {
    top: calc(-1 * var(--track-width));
    border-top: solid var(--track-width) var(--indicator-color);
  }

  .tab-group--bottom .tab-group__body-wrapper {
    order: 1;
  }

  .tab-group--bottom ::slotted(flow-ui-tab-panel) {
    --padding: var(--flow-ui-spacing-medium) 0;
  }

  /*
   * Start
   */

  .tab-group--start {
    flex-direction: row;
  }

  .tab-group--start .tab-group__nav-container {
    order: 1;
    flex-direction: column;
  }

  .tab-group--start .tab-group__track {
    height: 100%;
    right: 0;
    border-right: solid var(--track-width) var(--track-color);
  }

  .tab-group--start .tab-group__nav-accessories {
    flex-direction: column;
    padding-right: var(--track-width);
  }

  .tab-group--start .tab-group__nav-accessories--start {
    padding-top: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--start .tab-group__nav-accessories--end {
    padding-bottom: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--start .tab-group__nav {
    overflow-y: auto;
  }

  .tab-group--start .tab-group__tabs {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
  }

  .tab-group--start .tab-group__indicator {
    right: 0;
    border-right: solid var(--track-width) var(--indicator-color);
  }

  .tab-group--start.tab-group--rtl .tab-group__indicator {
    right: auto;
    left: calc(-1 * var(--track-width));
  }

  .tab-group--start .tab-group__body-wrapper {
    flex: 1 1 auto;
    order: 2;
  }

  .tab-group--start ::slotted(flow-ui-tab-panel) {
    --padding: 0 var(--flow-ui-spacing-medium);
  }

  .tab-group--start .tab-group__scroll-button {
    left: 0;
    right: 0;
    width: unset;
    height: var(--flow-ui-spacing-x-large);
  }

  .tab-group--start .tab-group__scroll-button--start {
    top: 0;
    bottom: auto;
  }

  .tab-group--start .tab-group__scroll-button--end {
    top: auto;
    bottom: 0;
  }

  /*
   * End
   */

  .tab-group--end {
    flex-direction: row;
  }

  .tab-group--end .tab-group__nav-container {
    order: 2;
    flex-direction: column;
  }

  .tab-group--end .tab-group__track {
    height: 100%;
    left: 0;
    border-left: solid var(--track-width) var(--track-color);
  }

  .tab-group--end .tab-group__nav-accessories {
    flex-direction: column;
    padding-left: var(--track-width);
  }

  .tab-group--end .tab-group__nav-accessories--start {
    padding-top: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--end .tab-group__nav-accessories--end {
    padding-bottom: var(--flow-ui-spacing-2x-small);
  }

  .tab-group--end .tab-group__nav {
    overflow-y: auto;
  }

  .tab-group--end .tab-group__tabs {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
  }

  .tab-group--end .tab-group__indicator {
    left: 0;
    border-left: solid var(--track-width) var(--indicator-color);
  }

  .tab-group--end.tab-group--rtl .tab-group__indicator {
    right: calc(-1 * var(--track-width));
    left: auto;
  }

  .tab-group--end .tab-group__body-wrapper {
    flex: 1 1 auto;
    order: 1;
  }

  .tab-group--end ::slotted(flow-ui-tab-panel) {
    --padding: 0 var(--flow-ui-spacing-medium);
  }

  .tab-group--end .tab-group__scroll-button {
    left: 0;
    right: 0;
    width: unset;
    height: var(--flow-ui-spacing-x-large);
    border-left: solid var(--track-width) var(--track-color);
  }

  .tab-group--end .tab-group__scroll-button--start {
    top: 0;
    bottom: auto;
  }

  .tab-group--end .tab-group__scroll-button--end {
    top: auto;
    bottom: 0;
  }
`;

export { styles as default };
