/* ============= CI HUD Tab Styles ============= */
/* Compact stat-pill row used in per-repo CI HUD sub-sections (rocm-systems,
   rocm-libraries). Uses thin colored borders + tinted backgrounds for a
   clean status-pill look that matches the overall design system. */
.ci-hud-stats {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ci-hud-stats .stat-item {
    padding: 4px 11px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
}
.ci-hud-stats .stat-item span {
    font-size: 0.85rem;
    font-weight: 700;
    margin-right: 2px;
}
.ci-hud-stats .stat-item.all-pass {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.30);
    color: var(--status-pass);
}
.ci-hud-stats .stat-item.failing {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.30);
    color: #ef4444;
}
.ci-hud-stats .stat-item.running {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.30);
    color: #f59e0b;
}

.ci-hud-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-elevated);
    border-radius: 10px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
}

.ci-hud-container {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    overflow-x: auto;
    max-width: 100%;
}

/* Main CI HUD table (shares structure with repo CI HUD) */
.ci-hud-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.ci-hud-table thead {
    background: var(--card-bg);
}
.ci-hud-table thead th {
    background: var(--card-bg);
    padding: 12px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--card-border);
    white-space: nowrap;
}

.ci-hud-table thead th.sticky-col,
.ci-hud-table tbody td.sticky-col {
    box-sizing: border-box;
}
.ci-hud-table thead th.sticky-col {
    position: sticky;
    z-index: 3;
    background: var(--card-bg);
}
.ci-hud-table thead th.col-sha { left: 0; width: 80px; min-width: 80px; }
.ci-hud-table thead th.col-pr { left: 80px; width: 60px; min-width: 60px; }
.ci-hud-table thead th.col-msg { left: 140px; width: 220px; min-width: 220px; }
.ci-hud-table thead th.col-auth { left: 360px; width: 110px; min-width: 110px; }
.ci-hud-table thead th.col-time { left: 470px; width: 80px; min-width: 80px; }

.ci-hud-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--card-border);
    vertical-align: middle;
}

.ci-hud-table tbody td.sticky-col {
    position: sticky;
    z-index: 1;
    background: var(--card-bg);
}
.ci-hud-table tbody td.col-sha { left: 0; width: 80px; min-width: 80px; }
.ci-hud-table tbody td.col-sha a {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.82rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.ci-hud-table tbody td.col-sha a:hover { text-decoration: underline; }
.ci-hud-table tbody td.col-pr { left: 80px; width: 60px; min-width: 60px; font-size: 0.82rem; white-space: nowrap; }
.ci-hud-table tbody td.col-pr a { color: var(--primary); text-decoration: none; }
.ci-hud-table tbody td.col-pr a:hover { text-decoration: underline; }
.ci-hud-table tbody td.col-msg {
    left: 140px; width: 220px; min-width: 220px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 0.78rem; color: var(--text-primary);
}
.ci-hud-table tbody td.col-auth {
    left: 360px; width: 110px; min-width: 110px;
    font-size: 0.75rem; white-space: nowrap;
}
.ci-hud-table tbody td.col-time {
    left: 470px; width: 80px; min-width: 80px;
}
.ci-hud-table thead th.col-time {
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.3);
}
.ci-hud-table tbody td.col-time {
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.15);
    font-size: 0.72rem; color: var(--text-muted); white-space: nowrap;
}
.ci-hud-table tbody td.col-auth img.author-avatar {
    width: 18px; height: 18px; border-radius: 50%; vertical-align: middle; margin-right: 4px;
}
.ci-hud-table tbody td.col-cat {
    text-align: center; white-space: nowrap;
}

.ci-hud-table .repo-ci-row { cursor: pointer; }
.ci-hud-table .repo-ci-row:hover td { background: var(--bg-overlay); }
.ci-hud-table .repo-ci-row:hover td.sticky-col { background: var(--bg-overlay); }
.ci-hud-table .repo-row-fail td { background: rgba(239, 68, 68, 0.04); }
.ci-hud-table .repo-row-fail:hover td { background: rgba(239, 68, 68, 0.07); }
.ci-hud-table .repo-row-run td { background: var(--warning-light); }
.ci-hud-table .ci-hud-row.expanded td { background: var(--bg-overlay); }
.ci-hud-table .ci-hud-row.expanded td.sticky-col { background: var(--bg-overlay); }

.ci-hud-table .repo-ci-expand-row td {
    background: var(--bg-elevated);
    padding: 16px 20px;
    border-bottom: 2px solid var(--card-border);
}


/* CI HUD expanded detail content (inside expand row <td>) */
.ci-hud-table .repo-ci-expand-row .ci-hud-expanded-grid {
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

.ci-hud-expanded-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.expanded-section {
    background: var(--bg-elevated);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--card-border);
}

.expanded-section.full-width {
    grid-column: 1 / -1;
}

.expanded-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.expanded-section h5 {
    margin: 10px 0 8px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.expanded-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.expanded-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.expanded-item.success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.expanded-item.success:hover {
    background: #d1fae5;
}

.expanded-item.failure {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.expanded-item.failure:hover {
    background: #fee2e2;
}

.expanded-item.running {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.expanded-item.na {
    background: var(--bg-overlay);
    color: var(--text-muted);
    border: 1px solid var(--card-border);
}

.item-icon {
    font-weight: 700;
}

.expanded-actions {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.expanded-actions .action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #6366f1;
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: auto;
    height: auto;
    white-space: nowrap;
}

.expanded-actions .action-btn:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* CI HUD pagination */
.ci-hud-pagination {
    padding: 15px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* CI HUD loading/empty/error states */
.ci-hud-loading,
.ci-hud-empty,
.ci-hud-error {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 1rem;
}

.ci-hud-error {
    color: #dc2626;
}

/* Responsive */
@media (max-width: 1200px) {
    .ci-hud-expanded-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .ci-hud-expanded-grid {
        grid-template-columns: 1fr;
    }
}

/* CI HUD Pagination Controls */
.ci-hud-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    margin-top: 15px;
}

.ci-hud-pagination-btns {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ci-hud-page-btn {
    padding: 8px 16px;
    border: 1px solid var(--card-border);
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.ci-hud-page-btn:hover:not(:disabled) {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

.ci-hud-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ci-hud-page-nums {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ci-hud-page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border: 1px solid var(--card-border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.ci-hud-page-num:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.ci-hud-page-num.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
    cursor: default;
}

span.ci-hud-page-num.active {
    cursor: default;
}

/* Refresh Button States */
.refresh-btn {
    position: relative;
    transition: all 0.2s ease;
}

.refresh-btn.refreshing {
    background: #818cf8 !important;
    cursor: wait;
}

.refresh-btn.refresh-success {
    background: var(--status-pass) !important;
    border-color: var(--status-pass) !important;
}

.refresh-btn.refresh-error {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
}

/* Custom Tooltip - Shows Below */
.refresh-btn::after {
    content: 'Force re-fetch (live via webhooks, auto-refreshes every 2 min)';
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.refresh-btn::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    right: 16px;
    border: 6px solid transparent;
    border-bottom-color: #1e293b;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.refresh-btn:hover::after,
.refresh-btn:hover::before {
    opacity: 1;
    visibility: visible;
}

.refresh-btn.refreshing::after,
.refresh-btn.refreshing::before,
.refresh-btn.refresh-success::after,
.refresh-btn.refresh-success::before,
.refresh-btn.refresh-error::after,
.refresh-btn.refresh-error::before {
    display: none;
}

.export-excel-btn {
    background: #059669;
    color: #fff;
    border: 1px solid #047857;
    min-height: 40px;
    box-sizing: border-box;
}
.export-excel-btn:hover {
    background: #047857;
    box-shadow: 0 5px 15px rgba(5, 150, 105, 0.4);
}
/* Override Refresh tooltip for Export button - must win over .refresh-btn::after */
.refresh-btn.export-excel-btn::after {
    content: 'Download Release report as Excel (.xlsx)';
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.refresh-btn.export-excel-btn:hover::after {
    opacity: 1;
    visibility: visible;
}
.refresh-btn.export-excel-btn::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    right: 16px;
    border: 6px solid transparent;
    border-bottom-color: #1e293b;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.refresh-btn.export-excel-btn:hover::before {
    opacity: 1;
    visibility: visible;
}
