/*
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2025 The Linux Foundation
*/

/**
 * Minimal Theme for Repository Reporting System
 *
 * A clean, stripped-down theme focusing on content with minimal styling.
 * Perfect for maximum readability and fast loading.
 *
 * Features:
 * - Minimal visual styling
 * - Focus on typography and content
 * - Fast loading (smallest CSS file)
 * - Maximum readability
 * - Print-friendly by default
 */

/* ============================================================================
   CSS Custom Properties (Variables) - Minimal Theme
   ========================================================================== */

:root {
    /* Color Palette - Minimal (grayscale focused) */
    --primary-color: #000000;
    --primary-hover: #333333;
    --success-color: #000000;
    --warning-color: #000000;
    --error-color: #000000;
    --info-color: #000000;

    /* Background Colors */
    --background: #ffffff;
    --surface: #fafafa;
    --surface-hover: #f5f5f5;
    --surface-alt: #e0e0e0;

    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-inverse: #ffffff;

    /* Border Colors */
    --border-color: #e0e0e0;
    --border-color-dark: #cccccc;
    --border-color-light: #f0f0f0;

    /* Typography - System fonts only */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
                   Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    --font-size-base: 16px;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-h1: 2em;
    --font-size-h2: 1.5em;
    --font-size-h3: 1.17em;
    --font-size-h4: 1.125rem;
    --line-height-base: 1.6;
    --line-height-tight: 1.4;
    --font-weight-normal: 400;
    --font-weight-bold: 700;

    /* Spacing - Simplified */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Layout */
    --max-content-width: 800px;
    --container-padding: var(--spacing-md);
}

/* ============================================================================
   Base Styles
   ========================================================================== */

* {
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--text-primary);
    background: var(--background);
    margin: 0;
    padding: var(--spacing-md);
}

/* ============================================================================
   Accessibility
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--text-primary);
    color: var(--text-inverse);
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
}

.skip-link:focus {
    top: var(--spacing-sm);
    left: var(--spacing-sm);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================================
   Layout
   ========================================================================== */

.container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* ============================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

h1 {
    font-size: var(--font-size-h1);
    border-bottom: 2px solid var(--text-primary);
    padding-bottom: var(--spacing-sm);
}

h2 {
    font-size: var(--font-size-h2);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-sm);
}

h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }
h5, h6 { font-size: var(--font-size-base); }

p {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--text-primary);
    text-decoration: underline;
}

a:hover {
    color: var(--text-secondary);
}

a:focus {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

code, pre {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
}

code {
    background: var(--surface);
    padding: 2px 4px;
    border: 1px solid var(--border-color);
}

pre {
    background: var(--surface);
    padding: var(--spacing-md);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

pre code {
    background: none;
    padding: 0;
    border: none;
}

strong {
    font-weight: var(--font-weight-bold);
}

/* ============================================================================
   Page Header
   ========================================================================== */

.page-header {
    border-bottom: 2px solid var(--text-primary);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.page-header h1 {
    margin: 0 0 var(--spacing-sm) 0;
    border: none;
    padding: 0;
}

.page-header .metadata {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.page-header .metadata p {
    margin: var(--spacing-sm) 0;
}

/* ============================================================================
   Report Sections
   ========================================================================== */

.report-section {
    margin-bottom: var(--spacing-xl);
}

/* ============================================================================
   Table of Contents
   ========================================================================== */

.toc {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.toc h2 {
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    margin-top: 0;
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-xs);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: var(--spacing-xs);
}

.toc-link {
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    padding: var(--spacing-xs) var(--spacing-sm);
    transition: color 0.2s ease;
}

.toc-link:hover {
    color: var(--primary-hover);
}

.toc-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================================================
   Statistics Grid
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.stat-card {
    border: 1px solid var(--border-color);
    padding: var(--spacing-md);
    text-align: center;
}

.stat-value {
    display: block;
    font-size: var(--font-size-h2);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--spacing-sm);
}

.stat-label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ============================================================================
   Tables
   ========================================================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    border: 1px solid var(--border-color);
    font-size: 0.9em;
}

th {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    font-weight: var(--font-weight-bold);
    border-bottom: 2px solid var(--border-color-dark);
    background: var(--surface);
}

td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--text-primary);
    font-size: 0.75rem;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
}

.badge-success,
.badge-warning,
.badge-error,
.badge-info,
.badge-default {
    background: var(--background);
    color: var(--text-primary);
}

/* ============================================================================
   Page Footer
   ========================================================================== */

.page-footer {
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-md);
    margin-top: var(--spacing-xl);
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.page-footer p {
    margin: var(--spacing-sm) 0;
}

/* ============================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        --font-size-h1: 1.75em;
        --font-size-h2: 1.35em;
        --font-size-h3: 1.1em;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    table {
        font-size: var(--font-size-sm);
    }

    th, td {
        padding: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    body {
        padding: var(--spacing-sm);
    }
}

/* ============================================================================
   Print Styles (minimal theme is print-optimized by default)
   ========================================================================== */

@media print {
    body {
        font-size: 11pt;
        line-height: 1.4;
    }

    h1 { font-size: 18pt; }
    h2 { font-size: 16pt; }
    h3 { font-size: 14pt; }

    .no-print,
    .skip-link {
        display: none !important;
    }

    table {
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    tr {
        page-break-inside: avoid;
    }
}

/* ============================================================================
   Utility Classes (minimal set)
   ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* ============================================================================
   CI/CD Job Status Colors
   ========================================================================== */

/* Status color variables for minimal theme */
:root {
    --status-success: #10b981;      /* Green - passing */
    --status-failure: #ef4444;      /* Red - failing */
    --status-warning: #f59e0b;      /* Orange/Yellow - unstable */
    --status-disabled: #9ca3af;     /* Gray - disabled */
    --status-unknown: #6b7280;      /* Gray - never run/unknown */
    --status-building: #3b82f6;     /* Blue - in progress */
    --status-aborted: #8b5cf6;      /* Purple - aborted */
}

/* GitHub Workflows and Jenkins Jobs - base link styles */
.cicd-jobs-table .github-workflows a,
.cicd-jobs-table .jenkins-jobs a {
    text-decoration: none;
    font-weight: 500;
}

.cicd-jobs-table .github-workflows a:hover,
.cicd-jobs-table .jenkins-jobs a:hover {
    opacity: 0.85;
    text-decoration: underline;
}

/* Success/Passing - Green */
.cicd-jobs-table .status-success {
    color: var(--status-success);
}

/* Failure/Failed - Red */
.cicd-jobs-table .status-failure {
    color: var(--status-failure);
}

/* Warning/Unstable - Orange/Yellow */
.cicd-jobs-table .status-warning {
    color: var(--status-warning);
}

/* Disabled - Gray */
.cicd-jobs-table .status-disabled {
    color: var(--status-disabled);
}

/* Unknown/Never Run - Gray */
.cicd-jobs-table .status-unknown,
.cicd-jobs-table .status-no-runs {
    color: var(--status-unknown);
}

/* Building/In Progress - Blue */
.cicd-jobs-table .status-building,
.cicd-jobs-table .status-in-progress {
    color: var(--status-building);
}

/* Aborted - Purple */
.cicd-jobs-table .status-aborted {
    color: var(--status-aborted);
}

/* Ensure visited links maintain their status color */
.cicd-jobs-table .github-workflows a:visited .status-success { color: var(--status-success); }
.cicd-jobs-table .github-workflows a:visited .status-failure { color: var(--status-failure); }
.cicd-jobs-table .github-workflows a:visited .status-warning { color: var(--status-warning); }
.cicd-jobs-table .github-workflows a:visited .status-disabled { color: var(--status-disabled); }
.cicd-jobs-table .github-workflows a:visited .status-unknown { color: var(--status-unknown); }
.cicd-jobs-table .github-workflows a:visited .status-no-runs { color: var(--status-unknown); }
.cicd-jobs-table .github-workflows a:visited .status-building { color: var(--status-building); }
.cicd-jobs-table .github-workflows a:visited .status-in-progress { color: var(--status-building); }
.cicd-jobs-table .github-workflows a:visited .status-aborted { color: var(--status-aborted); }

.cicd-jobs-table .jenkins-jobs a:visited .status-success { color: var(--status-success); }
.cicd-jobs-table .jenkins-jobs a:visited .status-failure { color: var(--status-failure); }
.cicd-jobs-table .jenkins-jobs a:visited .status-warning { color: var(--status-warning); }
.cicd-jobs-table .jenkins-jobs a:visited .status-disabled { color: var(--status-disabled); }
.cicd-jobs-table .jenkins-jobs a:visited .status-unknown { color: var(--status-unknown); }
.cicd-jobs-table .jenkins-jobs a:visited .status-no-runs { color: var(--status-unknown); }
.cicd-jobs-table .jenkins-jobs a:visited .status-building { color: var(--status-building); }
.cicd-jobs-table .jenkins-jobs a:visited .status-in-progress { color: var(--status-building); }
.cicd-jobs-table .jenkins-jobs a:visited .status-aborted { color: var(--status-aborted); }

/* Print-friendly: use text indicators for status */
@media print {
    .status-success::after { content: " [✓]"; }
    .status-failure::after { content: " [✗]"; }
    .status-warning::after { content: " [!]"; }
    .status-disabled::after { content: " [disabled]"; }
    .status-unknown::after { content: " [?]"; }
    .status-building::after { content: " [building]"; }
    .status-aborted::after { content: " [aborted]"; }
}

/* ============================================================================
   DataTables Integration Styles
   ========================================================================== */

/* DataTables wrapper - overall container */
.dataTable-wrapper {
    margin: 1.5em 0;
    font-size: 0.9rem;
}

/* DataTables top section (search and per-page selector) */
.dataTable-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

/* DataTables bottom section (info and pagination) */
.dataTable-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* Search input container */
.dataTable-search {
    flex: 1 1 auto;
    min-width: 200px;
}

.dataTable-search input {
    width: 100%;
    max-width: 300px;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.9rem;
    font-family: -apple-system, system-ui, sans-serif;
    background-color: #fff;
    color: #333;
}

.dataTable-search input:focus {
    outline: none;
    border-color: #0066cc;
}

.dataTable-search input::placeholder {
    color: #999;
}

/* Per-page selector */
.dataTable-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dataTable-dropdown label {
    color: #666;
    font-size: 0.85rem;
    white-space: nowrap;
}

.dataTable-selector select {
    padding: 0.4rem 1.5rem 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.9rem;
    background-color: #fff;
    color: #333;
    cursor: pointer;
}

/* Info text */
.dataTable-info {
    color: #666;
    font-size: 0.85rem;
}

/* Pagination container */
.dataTable-pagination {
    display: flex;
    gap: 0.2rem;
    align-items: center;
}

.dataTable-pagination ul {
    display: flex;
    gap: 0.2rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.dataTable-pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: #fff;
    color: #333;
    text-decoration: none;
    font-size: 0.85rem;
}

.dataTable-pagination a:hover:not(.active) {
    background-color: #f5f5f5;
}

.dataTable-pagination a.active {
    background-color: #0066cc;
    border-color: #0066cc;
    color: #fff;
}

.dataTable-pagination a.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Sorting indicators */
.dataTable-sorter {
    cursor: pointer;
    user-select: none;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .dataTable-top,
    .dataTable-bottom {
        flex-direction: column;
        align-items: stretch;
    }

    .dataTable-search input {
        max-width: none;
    }

    .dataTable-pagination {
        justify-content: center;
    }
}

/* Print styles */
@media print {
    .dataTable-top,
    .dataTable-bottom {
        display: none !important;
    }
}
