/**
 * Pipeline Summary Table Styles - CoreFramework Colors
 * Only affects #pipeline-summary-table
 */

/* Use ID selector for maximum specificity */
#pipeline-summary-table {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

#pipeline-summary-table h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2rem;
    text-align: center;
}

#pipeline-summary-table .table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    /* Allow sticky to work */
    -webkit-overflow-scrolling: touch;
    margin-bottom: 3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-body-l-2);
    position: relative;
    /* Remove the gradient backgrounds that might interfere */
}

#pipeline-summary-table .table-responsive::-webkit-scrollbar {
    height: 8px;
}

#pipeline-summary-table .table-responsive::-webkit-scrollbar-track {
    background: var(--bg-body-l-2);
    border-radius: 4px;
}

#pipeline-summary-table .table-responsive::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

#pipeline-summary-table .table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--primary-d-1);
}

#pipeline-summary-table .table-responsive::after {
    content: '← Swipe to explore →';
    display: none;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.875rem;
    color: var(--primary-d-2);
    padding: 0.5rem;
    background: var(--bg-body-l-4);
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    opacity: 0.8;
}

@media (max-width: 768px) {
    #pipeline-summary-table .table-responsive {
        position: relative;
    }

    #pipeline-summary-table .table-responsive::after {
        display: block;
    }
}

#pipeline-summary-table .pipeline-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    background: var(--bg-body-l-5);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

#pipeline-summary-table .pipeline-table thead {
    background: var(--primary);
    color: var(--bg-body-l-5);
}

#pipeline-summary-table .pipeline-table thead th {
    padding: 1rem 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--primary-d-1);
    /* Sticky positioning - stays at top when scrolling the page */
    position: sticky;
    top: 0;
    /* Stick to top of the scrolling container */
    z-index: 990;
    /* Enhanced sticky header with shadow */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    /* Ensure background is solid when sticky */
    background: var(--primary);
    color: var(--bg-body-l-5);
}

/* First column sticky (horizontal scroll) - only for body cells */
#pipeline-summary-table .pipeline-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
}

#pipeline-summary-table .pipeline-table thead th:first-child {
    min-width: 280px;
    padding-left: 1.5rem;
    /* Higher z-index for header */
    z-index: 991;
    /* Keep header cell visible when sticky */
    background: var(--primary);
}

#pipeline-summary-table .pipeline-table thead th:not(:first-child) {
    text-align: center;
    min-width: 80px;
}

#pipeline-summary-table .pipeline-table tbody tr {
    border-bottom: 1px solid var(--bg-body-d-2);
    transition: background-color 0.2s ease;
}

#pipeline-summary-table .pipeline-table tbody tr:hover {
    background-color: var(--bg-secondary-surface-10);
}

#pipeline-summary-table .pipeline-table tbody tr:nth-child(even) {
    background-color: var(--bg-body-l-3);
}

#pipeline-summary-table .pipeline-table tbody tr:nth-child(even):hover {
    background-color: var(--secondary-l-4);
}

#pipeline-summary-table .pipeline-table tbody td {
    padding: 1rem 0.75rem;
    font-size: 1rem;
    color: var(--primary-d-3);
}

#pipeline-summary-table .pipeline-table tbody td:first-child {
    font-weight: 500;
    padding-left: 1.5rem;
    color: var(--primary);
    background: var(--bg-body-l-5);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

/* Style for linked indications */
#pipeline-summary-table .pipeline-table .pipeline-indication-link {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: var(--primary);
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

#pipeline-summary-table .pipeline-table .pipeline-indication-link:hover {
    color: var(--primary-d-2);
    text-decoration-color: var(--secondary);
}

/* Ensure even rows' first cell has correct background */
#pipeline-summary-table .pipeline-table tbody tr:nth-child(even) td:first-child {
    background: var(--bg-body-l-3);
}

/* Hover state for first cell */
#pipeline-summary-table .pipeline-table tbody tr:hover td:first-child {
    background: var(--bg-secondary-surface-10);
}

#pipeline-summary-table .pipeline-table tbody tr:nth-child(even):hover td:first-child {
    background: var(--secondary-l-4);
}

/* Totals row first cell */
#pipeline-summary-table .pipeline-table tbody tr.totals-row td:first-child {
    background: var(--secondary-l-3);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

#pipeline-summary-table .pipeline-table tbody td:not(:first-child) {
    text-align: center;
    font-feature-settings: 'tnum';
    font-variant-numeric: tabular-nums;
}

#pipeline-summary-table .pipeline-table tbody td:empty::before {
    content: '—';
    color: var(--bg-body-d-2);
}

#pipeline-summary-table .pipeline-table tbody tr.totals-row {
    background: var(--secondary-l-3);
    border-top: 2px solid var(--secondary);
    font-weight: 700;
}

#pipeline-summary-table .pipeline-table tbody tr.totals-row td {
    padding: 1.5rem 0.75rem;
    color: var(--secondary-d-3);
}

#pipeline-summary-table .pipeline-table tbody tr.totals-row td:first-child {
    color: var(--primary);
}

#pipeline-summary-table .pipeline-table tbody td[data-value]:not([data-value="0"]):not(:first-child) {
    font-weight: 600;
    color: var(--secondary-d-2);
}

@media (max-width: 1024px) {
    #pipeline-summary-table {
        padding: 2rem 1rem;
    }

    #pipeline-summary-table h1 {
        font-size: 2rem;
    }

    #pipeline-summary-table .pipeline-table thead th,
    #pipeline-summary-table .pipeline-table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 640px) {
    #pipeline-summary-table {
        padding: 1.5rem 0.5rem;
    }

    #pipeline-summary-table h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }

    #pipeline-summary-table .pipeline-table {
        min-width: 600px;
    }

    #pipeline-summary-table .pipeline-table thead th:first-child {
        min-width: 200px;
    }

    #pipeline-summary-table .pipeline-table thead th,
    #pipeline-summary-table .pipeline-table tbody td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
}

@media print {
    #pipeline-summary-table .table-responsive::after {
        display: none;
    }

    #pipeline-summary-table .pipeline-table {
        min-width: 100%;
        box-shadow: none;
    }
}

/* Pipeline KPI Grid (Shortcode) */
.pipeline-kpi-grid {
    /* Variables for child cards */
    --card-size: 180px;
    --card-padding: 16px;

    /* Normal flow layout – no absolute positioning */
    position: relative;
    margin-top: var(--space-l, 32px);
    margin-bottom: var(--space-l, 32px);
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    /* left‑aligned */
    gap: var(--space-m, 24px);
    pointer-events: auto;
}




.pipeline-kpi-card {
    width: var(--card-size, 200px);
    height: var(--card-size, 200px);
    /* Explicit height */
    padding: var(--card-padding, 16px);
    pointer-events: auto;
    /* Re-enable clicks on cards */

    flex-shrink: 0;
    background-color: var(--bg-body, #fff);
    border-radius: var(--radius-l, 24px);

    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-xs, 16px);

    border: 1px solid var(--secondary, #A0EACE);
    box-shadow: rgba(0, 0, 0, 0.10) 0px 20px 25px -5px, rgba(0, 0, 0, 0.04) 0px 10px 10px -5px;

    transition: transform 0.3s ease;
}

.pipeline-kpi-card:hover {
    transform: translateY(-4px);
}

.pipeline-kpi-value {
    font-family: var(--text-heading-font-family, sans-serif);
    font-size: var(--text-display-l, 4rem);
    font-weight: 800;
    line-height: 1;
    color: var(--primary, #633368);
    margin-top: auto;
}

.pipeline-kpi-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs, 4px);
    width: 100%;
}

.pipeline-kpi-label {
    margin: 0;
    font-family: var(--text-heading-font-family, sans-serif);
    font-size: var(--text-l, 1.25rem);
    font-weight: 700;
    color: var(--text-secondary-surface-body, #333) !important;
    line-height: 1.3;
}

/* Specific styling for different phases if needed */
.pipeline-kpi-card.phase-publications .pipeline-kpi-value {
    color: var(--secondary-d-2, #2c7a5f);
}

/* Mobile: Reset to normal flow */
@media (max-width: 768px) {
    .pipeline-kpi-grid {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        transform: none;
        justify-content: flex-start;
        /* Left align on mobile */
        margin-top: var(--space-m, 24px);
        padding-right: 0;
        margin-bottom: var(--space-l, 32px);
    }

    .pipeline-kpi-card {
        width: calc(50% - 12px);
        /* 2 per row */
        min-width: 150px;
        height: auto;
        min-height: 150px;
        aspect-ratio: 1 / 1;
    }
}

/* --------------------------------------------------------------
   Hide the KPI block when the second column (the one with the shortcode)
   is empty. The heading column stays, but the whole block collapses.
   -------------------------------------------------------------- */
/* 1️⃣ Hide the column itself – this works everywhere */
.kpi-cards__column:empty {
    display: none !important;
}

/* 2️⃣ If the column is hidden, also hide its direct parents.
   The selectors are ordered from inner to outer so that the rule
   only fires when the empty column exists. */
.kpi-cards_container .kpi-cards__column:empty,
.kpi-cards .kpi-cards_container .kpi-cards__column:empty {
    display: none !important;
}

/* 3️⃣ Finally, hide the outermost wrapper when its inner
   container is gone. This ensures no blank space remains. */
.kpi-cards .kpi-cards_container:empty,
.kpi-cards:empty {
    display: none !important;
}