// Copyright (C) 2025 The Android Open Source Project
//
// 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.

@import "../theme";

.pf-drawer-panel {
  height: 100%;
  display: flex;
  flex-direction: column;

  &__main {
    flex: 1; // Fill the remaining space
    overflow: auto;

    // Making this a flex element allows multiple individually overflowing
    // sections to be added to the main content area.
    display: flex;
    flex-direction: column; // Users normally expect content to stack vertically
  }

  &__handle {
    gap: 2px;
    background-color: var(--pf-color-background-secondary);
    border-top: 1px solid var(--pf-color-border);
    cursor: row-resize;
    display: flex;
    align-items: baseline;
    padding-inline: 2px;
    align-items: center;
    touch-action: none;
  }

  &__tabs {
    padding-inline: 3px; // Leave some space for the drop shadow
    display: flex;
    overflow: hidden;

    // Align tabs to the bottom of the handle & overlap the drawer border so
    // that the active tab looks like it is part of the drawer.
    align-self: flex-end;
    margin-bottom: -1px;
    cursor: default; // Tabs container itself is not clickable
  }

  &__spacer {
    flex: 1;
    align-self: stretch;
    min-width: 30px; // Leave some room for the user to grab the handle even if there are many tabs
  }

  &__tab {
    display: flex;
    align-items: baseline;
    gap: 2px;

    font-family: var(--pf-font-compact);
    font-size: 14px;

    padding: 5px; // Space around the tab content
    margin-top: 2px; // Space between tab and top of handle
    cursor: pointer; // Active tab is not clickable

    border-radius: 3px 3px 0 0; // Rounded top corners only
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-style: solid;
    border-color: var(--pf-color-border-secondary);
    border-width: 1px 1px 0 1px;

    &:not(:first-child) {
      // Merge borders
      margin-left: -1px;
    }

    &:hover {
      background: color_hover(transparent);
    }

    &.pf-drawer-panel__tab--active {
      cursor: default;
      background-color: var(--pf-color-background);
      box-shadow: var(--pf-color-box-shadow) 0px 0px 3px;
      border-color: var(--pf-color-border);
      z-index: 1;
    }
  }

  &__tab-title {
    margin: 0px 4px;
    overflow: hidden;
    user-select: none;
  }

  &__drawer {
    flex-shrink: 0;
    overflow: auto;
    box-shadow: var(--pf-color-box-shadow) 0px 0px 3px;
    border-top: 1px solid var(--pf-color-border);
  }
}
