// 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 "../../assets/theme";

.pf-trace-info-page {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  justify-content: center;

  // Inner container for better structure
  &__inner {
    width: 95%;
    max-width: 1400px;
    background: var(--pf-color-background);
    border-radius: $border-radius-large * 3;
    box-shadow: $box-shadow-1;
    overflow: hidden;
  }

  // Header section
  &__header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--pf-color-border);
  }

  &__header-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
  }

  &__subtitle {
    color: var(--pf-color-text-muted);
    font-size: var(--pf-font-size-l);
    line-height: 1.5;
  }

  // Tab content area
  &__tab-content {
    padding: 16px 28px 24px;
  }

  &__banner {
    margin-bottom: 16px;
  }

  // Category section headings
  &__category-heading {
    font-size: var(--pf-font-size-xl);
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 4px;
    color: var(--pf-color-text);
    word-break: break-word;
    overflow-wrap: break-word;
  }

  &__category-description {
    font-size: var(--pf-font-size-m);
    color: var(--pf-color-text-muted);
    margin-top: 2px;
    margin-bottom: 12px;
    line-height: 1.5;
  }

  // Cards (shared base styles)
  &__metric-card,
  &__status-card {
    padding: 12px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    background: var(--pf-color-background-secondary);
  }

  &__metric-card--wide {
    grid-column: span 2;
  }

  // Status cards with states
  &__status-card {
    justify-content: center;
  }

  &__status-card--success {
    border-left: 4px solid var(--pf-color-success);
  }

  &__status-card--warning {
    border-left: 4px solid var(--pf-color-warning);
  }

  &__status-card--danger {
    border-left: 4px solid var(--pf-color-danger);
  }

  &__status-card--clickable {
    cursor: pointer;
    transition:
      transform 0.1s ease-in-out,
      box-shadow 0.1s ease-in-out;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }

    &:active {
      transform: translateY(0);
    }
  }

  &__status-icon {
    font-size: 28px;
  }

  &__status-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  &__status-content {
    flex: 1;
    min-width: 0;
  }

  // Card labels (titles)
  &__status-title,
  &__metric-label {
    font-size: var(--pf-font-size-s);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--pf-color-text);
    opacity: 0.7;
    line-height: 1.3;
    margin-bottom: 12px;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  // Card values
  &__status-value {
    font-size: 36px;
    font-weight: 600;
    line-height: 1;
  }

  &__metric-value {
    font-size: var(--pf-font-size-xl);
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
  }

  &__status-link {
    display: flex;
    align-items: center;
    opacity: 0.7;

    &:hover {
      opacity: 1;
    }
  }

  &__status-link-icon {
    font-size: var(--pf-font-size-xxl);
  }

  // Args rendering (import errors detail)
  &__args {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: var(--pf-font-size-s);
  }

  &__arg-item {
    line-height: 1.4;
  }

  &__arg-key {
    font-weight: 600;
    color: var(--pf-color-text);
  }

  &__arg-value {
    font-family: var(--pf-font-monospace);
    color: var(--pf-color-text-muted);
  }

  // Logs grid with virtualization
  &__logs-grid {
    max-height: 500px;
  }

  // Help icon
  &__help-icon {
    font-size: var(--pf-font-size-m);
    margin-left: 6px;
    color: var(--pf-color-text-muted);
    opacity: 0.6;
    cursor: default;

    &:hover {
      opacity: 1;
    }
  }

  // UI Loading errors
  &__loading-errors {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  &__loading-error-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--pf-color-background-hover);
    border-radius: 4px;
    border-left: 3px solid var(--pf-color-danger);
    font-family: var(--pf-font-monospace);
  }

  &__loading-error-number {
    font-size: var(--pf-font-size-m);
    font-weight: 600;
    color: var(--pf-color-text-muted);
    flex-shrink: 0;
  }

  &__loading-error-text {
    font-size: var(--pf-font-size-s);
    line-height: 1.5;
    color: var(--pf-color-text);
    word-break: break-word;
  }

  // Stats tab table
  &__stats-table {
    width: 100%;
    border-spacing: 4px 1px;
    margin: 0;
  }

  &__stats-table-head-cell {
    padding-bottom: 5px;
    font-weight: 500;
  }

  &__stats-table-row:nth-child(odd) &__stats-table-cell {
    background-color: color_hover(transparent);
  }

  &__stats-table-cell {
    font-family: var(--pf-font-monospace);
    font-size: var(--pf-font-size-s);
    padding: 5px;
    word-break: break-all;
    white-space: pre-wrap;
    vertical-align: top;
  }

  &__stats-table-cell--name {
    font-weight: 800;
    min-width: 150px;
  }

  // Stats section wrapper
  &__stats-section {
    margin: 0;
    padding: 0;
  }

  // ============================================================================
  // External component overrides
  // These styles override external components for consistent appearance
  // ============================================================================

  // Override pf-tabs styling
  .pf-tabs {
    border-bottom: 1px solid var(--pf-color-border);
    padding: 0 28px;

    .pf-tabs__tab {
      font-size: var(--pf-font-size-l);
      font-weight: 500;
      padding: 14px 18px;
    }
  }

  // Override pf-section styling within tab content
  &__tab-content .pf-section {
    border: none;
    border-radius: 0;
    margin-bottom: 28px;

    &:last-child {
      margin-bottom: 0;
    }

    header {
      border-bottom: none;
      margin-bottom: 8px;
      padding: 0;

      h1 {
        font-size: var(--pf-font-size-xxl);
        font-weight: 600;
        color: var(--pf-color-text);
        letter-spacing: -0.01em;
        margin-bottom: 4px;
      }
    }

    .pf-section__subtitle {
      font-size: var(--pf-font-size-m);
      color: var(--pf-color-text-muted);
      line-height: 1.4;
      margin: 0;
    }

    article {
      padding: 0;
    }
  }

  // Override pf-grid styling for larger fonts
  &__tab-content .pf-grid {
    font-size: var(--pf-font-size-m);

    .pf-grid-header-cell {
      font-size: var(--pf-font-size-m);
      font-weight: 600;

      .pf-grid-header-cell__title-wrapper {
        padding: 10px 12px;
      }
    }

    .pf-grid-cell {
      font-size: var(--pf-font-size-m);
      padding: 10px 12px;
    }
  }

  // Override pf-grid-layout for consistent card layout
  &__tab-content .pf-grid-layout {
    margin-bottom: 0;
    gap: 16px;
  }

  // Override pf-code-snippet styling
  &__tab-content .pf-code-snippet pre code {
    font-size: var(--pf-font-size-m);
    line-height: 1.5;
  }

  // Generic heading overrides for category sections
  // These are used in utils.ts renderCategorySection
  &__tab-content h3 {
    font-size: var(--pf-font-size-xl);
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 4px;
    color: var(--pf-color-text);
    word-break: break-word;
    overflow-wrap: break-word;
  }

  &__tab-content p {
    font-size: var(--pf-font-size-m);
    color: var(--pf-color-text-muted);
    margin-top: 2px;
    margin-bottom: 12px;
    line-height: 1.5;
  }
}
