/*
Copyright 2019-2026 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

@use '@carbon/react/scss/config' as *;
@use '@carbon/react/scss/theme' as *;

.#{$prefix}--tabs__nav-item.tkn--task {
  .#{$prefix}--tabs__nav-item-label-wrapper {
    display: block;
  }

  .tkn--task-title {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-block-end: 0.25rem;

    .tkn--status-icon {
      flex-shrink: 0;
      inline-size: 17px;
      block-size: 17px;
    }

    .tkn--task-title--name {
      color: $text-primary;
      flex-grow: 1;
    }
  };

  .tkn--task-duration {
    color: $text-helper;
    margin-inline-start: 1.5625rem; // 17px icon + 0.5rem gap
  }
}

.tkn--tasks > .#{$prefix}--tabs {
  .tkn--task-title {
    margin-block-start: 0.25rem;
    margin-block-end: 0;
    line-height: 1.75;
  }

  .tkn--task-duration {
    margin-block-end: 0.25rem;
  }
}

// 'tab layout' styles for: PipelineRun vertical tabs, PipelineRun horizontal tabs, TaskRun
.tkn--tasks:has(> .#{$prefix}--tabs, .#{$prefix}--tabs.tkn--task-list, > .tkn--step-details:first-child) {
  > .#{$prefix}--css-grid {
    max-inline-size: 100%;

    > .#{$prefix}--tab-content {
      // we don't want 2 scrollbars, prefer the one on body
      overflow-y: visible;
      // to stop log content bleeding through the sticky header
      padding-block-start: 0;
    }
  }

  > .#{$prefix}--tab-content {
    // to stop log content bleeding through the sticky header
    padding-block-start: 0;
    padding-inline: 0;
  }

  header.tkn--step-details-header {
    padding: 1rem 0 0 0;
    position: sticky;
    inset-block-start: var(--tkn-global-header-offset);
    z-index: 4997;
  }

  .tkn--step-details {
    > .#{$prefix}--tabs {
      position: sticky;
      inset-block-start: calc(var(--tkn-global-header-offset) + 4.4rem);
      z-index: 4996;
      background-color: $layer;
    }

    &:not(.tkn--taskrun--maximized) {
      overflow: initial;
    }

    .#{$prefix}--snippet--multi {
      max-inline-size: none;
    }
  }
}

.#{$prefix}--tabs.#{$prefix}--tabs--vertical.tkn--task-list {
  position: sticky;
  inset-block-start: var(--tkn-global-header-offset);
  max-block-size: calc(100vb - var(--tkn-global-header-offset));
}
