/* ============================================================================
   Failure modal — AI Investigation section (top of modal).
   Shown either as a CTA button (before AI runs) or as a rich insight
   card (after AI returns or on cache hit).
   ============================================================================ */
.failure-ai-section { margin: 14px 0 16px 0; }

/* CTA card — prominent invitation to invoke Claude */
.failure-ai-cta {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(34, 211, 238, 0.04));
    border: 1px solid rgba(129, 140, 248, 0.30);
    border-left: 3px solid var(--primary-light, #818cf8);
    border-radius: 10px;
    transition: background 0.15s, border-color 0.15s;
}
.failure-ai-cta:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(34, 211, 238, 0.06));
    border-color: rgba(129, 140, 248, 0.5);
}
.failure-ai-cta-body {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}
.failure-ai-cta-body i,
.failure-ai-cta-body svg.lucide {
    width: 22px;
    height: 22px;
    color: var(--primary-light, #818cf8);
    flex-shrink: 0;
}
.failure-ai-cta-body strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text-primary, #e4e4e7);
    margin-bottom: 2px;
}
.failure-ai-cta-body span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.45;
}
.failure-ai-cta button {
    flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
}

/* Rendered AI insight card */
.ai-insight-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(34, 211, 238, 0.04));
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-left: 3px solid var(--primary-light, #818cf8);
    border-radius: 10px;
    padding: 14px 18px;
}
.ai-insight-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ai-insight-cached {
    background: rgba(148, 163, 184, 0.18);
    color: var(--text-muted, #94a3b8);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.ai-insight-tag {
    background: rgba(99, 102, 241, 0.18);
    color: var(--primary-light, #818cf8);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: ui-monospace, monospace;
}
.ai-insight-refresh-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary, #a1a1aa);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ai-insight-refresh-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary, #e4e4e7);
    border-color: rgba(129, 140, 248, 0.35);
}
.ai-insight-refresh-btn i,
.ai-insight-refresh-btn svg.lucide {
    width: 12px;
    height: 12px;
}
.ai-insight-section-label {
    font-size: 0.72rem;
    color: var(--text-secondary, #a1a1aa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 4px;
}
.ai-insight-rootcause {
    font-size: 0.92rem;
    color: var(--text-primary, #e4e4e7);
    line-height: 1.55;
    margin-bottom: 12px;
    font-style: italic;
}
.ai-insight-nextstep {
    font-size: 0.9rem;
    color: var(--text-primary, #e4e4e7);
    line-height: 1.5;
    margin-bottom: 12px;
}
.ai-insight-meta {
    font-size: 0.7rem;
    color: var(--text-muted, #94a3b8);
}
.ai-insight-meta code {
    font-size: 0.92em;
    background: rgba(255, 255, 255, 0.04);
    padding: 1px 5px;
    border-radius: 3px;
}

/* Section h3 used in the modal between AI / Take action / Related issues */
.failure-section-h3 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: var(--text-primary, #e4e4e7);
    margin: 18px 0 8px 0;
}
.failure-section-h3 i,
.failure-section-h3 svg.lucide {
    width: 16px;
    height: 16px;
    color: var(--primary-light, #818cf8);
}
.failure-action-subtitle-row {
    margin-bottom: 8px;
}

/* ============================================================================
   Failure modal — unified action panel
   Two side-by-side option cards (Comment on existing / Create new), with the
   recommended one highlighted by a ★ badge + brighter border. Clicking a
   card switches the active option, which updates the draft preview + the
   submit button below. Single source of truth for "what action to take".
   ============================================================================ */
.failure-action-panel {
    background: var(--card-bg, rgba(0, 0, 0, 0.18));
    border: 1px solid var(--card-border, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    padding: 14px 16px;
    margin: 14px 0 16px 0;
}
/* (Removed .failure-action-header — the internal h3 was replaced by an
   external .failure-section-h3 above the panel.) */
.failure-action-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary, #a1a1aa);
}
.failure-action-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
@media (max-width: 600px) {
    .failure-action-choices { grid-template-columns: 1fr; }
}
/* The two big option buttons. Uses real <button> for keyboard / a11y. */
.failure-action-btn {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.025);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: var(--text-primary, #e4e4e7);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.failure-action-btn:hover:not(.is-active):not(.is-disabled) {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(129, 140, 248, 0.35);
}
.failure-action-btn.is-active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(99, 102, 241, 0.06));
    border-color: var(--primary-light, #818cf8);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.10),
                inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.failure-action-btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.failure-action-btn-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.failure-action-btn-row i,
.failure-action-btn-row svg.lucide {
    width: 16px; height: 16px;
    flex-shrink: 0;
    color: var(--text-primary, #e4e4e7);
}
.failure-action-btn.is-active .failure-action-btn-row i,
.failure-action-btn.is-active .failure-action-btn-row svg.lucide {
    color: var(--primary-light, #818cf8);
}
.failure-action-btn-title {
    font-weight: 600;
    font-size: 0.92rem;
    flex: 1 1 auto;
}
.failure-action-btn-sub {
    font-size: 0.78rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.4;
}
.failure-action-btn-sub strong {
    color: var(--text-primary, #e4e4e7);
}
.failure-action-rec-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.5;
    cursor: help;
}
/* Heuristic suggestion — softer indigo, signals "informational, AI may differ" */
.failure-action-rec-badge.rec-badge-heuristic {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(99, 102, 241, 0.08));
    color: var(--primary-light, #818cf8);
    border: 1px solid rgba(129, 140, 248, 0.35);
}
/* AI recommendation — green, signals "Claude analyzed this with full context" */
.failure-action-rec-badge.rec-badge-ai {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(16, 185, 129, 0.10));
    color: var(--status-pass);
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.06);
}
.failure-action-reason {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: rgba(99, 102, 241, 0.08);
    border-left: 2px solid var(--primary-light, #818cf8);
    padding: 7px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.5;
    margin-bottom: 10px;
}
.failure-action-labels {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 4px 0 12px 0;
    font-size: 0.78rem;
}
.failure-action-labels-label {
    color: var(--text-secondary, #a1a1aa);
    font-weight: 600;
    margin-right: 4px;
}
.failure-action-draft-wrap {
    margin-top: 8px;
}
.failure-action-draft-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.failure-action-draft-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #a1a1aa);
    font-weight: 700;
}
.failure-action-help {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    margin: 6px 0 10px 0;
    line-height: 1.5;
}
.failure-action-submit-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.failure-action-submit-btn {
    /* Use the same style as failure-modal-btn but slightly more prominent */
    font-weight: 600;
}

/* GitHub-style label chips for the modal "Suggested labels" section.
   Background and text color come from inline style (computed from the
   actual GitHub label color). */
.gh-label-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 11px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.5;
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: help;
}
/* Spinner used by the "Investigate with AI" button while loading */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; }
.failure-modal-draft-textarea {
    width: 100%;
    min-height: 240px;
    padding: 10px 12px;
    background: var(--bg-base, rgba(0,0,0,0.3));
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: ui-monospace, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    resize: vertical;
}
.summary-trend-link {
    align-self: flex-end;
    font-size: 0.72rem;
    color: var(--primary-light, #818cf8);
    text-decoration: none;
}
.summary-trend-link:hover { text-decoration: underline; }
@media (max-width: 900px) {
    .summary-trends-grid { grid-template-columns: 1fr; }
}

.tab-button {
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tab-button:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

.tab-button.active {
    background: var(--primary);
    color: #ffffff;
}

.tab-content {
    display: block;
    max-width: 100%;
    overflow-x: visible;
}

.repo-section {
    margin-bottom: 20px;
}
/* Drop the harsh bottom-border separator — the section's own card border
   already provides visual separation from the next section. */
.repo-section:last-of-type {
    margin-bottom: 0;
}

/* Repo CI HUD tables now share .ci-hud-table class (see below) */

/* Row highlighting */
.repo-ci-row { cursor: pointer; transition: background 0.15s; }
.repo-ci-row:hover { background: rgba(99, 102, 241, 0.05); }
.repo-ci-row.repo-row-fail { background: rgba(239, 68, 68, 0.06); }
.repo-ci-row.repo-row-fail:hover { background: rgba(239, 68, 68, 0.1); }
.repo-ci-row.repo-row-run { background: rgba(245, 158, 11, 0.05); }

/* Category badges */
.cat-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 36px;
    text-align: center;
}
.cat-pass { background: rgba(16, 185, 129, 0.15); color: var(--status-pass); }
.cat-fail { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.cat-run { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.cat-na { background: transparent; color: var(--text-muted); font-weight: 400; }

/* Expanded detail row */
.repo-ci-expand-row td {
    padding: 0 !important;
    background: var(--bg-overlay, rgba(0,0,0,0.02));
}

/* Light theme overrides (shared via .ci-hud-table) */
[data-theme="light"] .repo-ci-row:hover td.sticky-col {
    background: #f1f5f9;
}
[data-theme="light"] .repo-ci-expand-row td {
    background: #f8fafc;
}

/* CI Specific Styles - Reusing main dashboard styles */

/* Test Artifacts Table - uses pytorch-table styles for consistency */

/* Version Dropdown Styling */
.version-dropdown {
    padding: 8px 15px;
    background: rgba(79, 70, 229, 0.35);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #f3f4f6;
    border-radius: 10px;
    font-weight: 600;
    min-width: 250px;
    cursor: pointer;
    font-size: 14px;
    /* Only transition colors/shadow. Transitioning `all` causes the hitbox to
       wobble during mousedown on <select>, which the browser interprets as
       "pointer left the button" and the native dropdown closes immediately. */
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(10px);
}

.version-dropdown:hover {
    background: rgba(79, 70, 229, 0.45);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    /* Do NOT translateY here — native <select> buttons close their popup if the
       element moves between mousedown and mouseup. */
    border-color: rgba(139, 92, 246, 0.5);
}

.version-dropdown:focus,
.version-dropdown:active {
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
    /* Lock the background/position during press so the native popup stays open. */
    background: rgba(79, 70, 229, 0.45);
}

/* Dropdown options styling */
.version-dropdown option {
    background: #1a1a2e;
    color: #f3f4f6;
    padding: 10px;
    font-weight: normal;
}

.version-dropdown option:hover {
    background: #16213e;
}

/* Selected option */
.version-dropdown option:checked {
    background: #4f46e5;
    color: white;
}

/* Header Title Styling — keeps decorative properties; size/weight come from
   the global h1 rule above (using design tokens) so we don't fight specificity. */
h1.page-title {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-bottom: var(--space-5);
}

/* CI Run Dropdown Styling - matches version dropdown */
.ci-run-dropdown {
    padding: 10px 14px;
    background: rgba(79, 70, 229, 0.35);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #f3f4f6;
    border-radius: 10px;
    min-width: 650px;
    max-width: 850px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    cursor: pointer;
    /* See .version-dropdown comment: transitioning `all` / translating on hover
       destabilises the native popup anchor and closes the dropdown on press. */
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    font-weight: 500;
}

.ci-run-dropdown:hover {
    background: rgba(79, 70, 229, 0.45);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ci-run-dropdown:focus,
.ci-run-dropdown:active {
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(79, 70, 229, 0.45);
}

.ci-run-dropdown option {
    background: #1a1a2e;
    color: #f3f4f6;
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.6;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 400;
}

.ci-run-dropdown option:hover {
    background: #16213e;
}

.ci-run-dropdown option[data-status="success"] {
    background: #1a1a2e;
    border-left: 4px solid var(--status-pass);
    padding-left: 12px;
}

.ci-run-dropdown option[data-status="failure"] {
    background: #1a1a2e;
    border-left: 4px solid #ef4444;
    padding-left: 12px;
}

.ci-run-dropdown option[data-status="in_progress"] {
    background: #1a1a2e;
    border-left: 4px solid #3b82f6;
    padding-left: 12px;
}

.ci-run-dropdown option[data-status="queued"] {
    background: #1a1a2e;
    border-left: 4px solid #f59e0b;
    padding-left: 12px;
}

.ci-run-dropdown option[data-status="completed"] {
    background: #1a1a2e;
    border-left: 4px solid var(--status-pass);
    padding-left: 12px;
}

.ci-run-dropdown option[data-status="cancelled"] {
    background: #1a1a2e;
    border-left: 4px solid #6b7280;
    padding-left: 12px;
}

/* Sharded test container styles */
.shard-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    align-items: stretch;
    padding: 2px;
    max-width: 100%;
}

.shard-badge {
    flex: 0 0 auto;
    min-width: 70px;
    max-width: 85px;
    font-size: 11px;
}

/* Compact sharded status badges */
.status-badge.shard {
    padding: 4px 6px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 2px 0;
    border-radius: 4px;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

.status-badge.shard .shard-line {
    font-weight: 600;
    font-size: 11px;
}

.status-badge.shard .duration-line {
    font-size: 9px;
    opacity: 0.9;
    font-weight: normal;
}

/* Status badge duration - uses the same badge styles as main dashboard */
.status-badge small {
    display: block;
    margin-top: 1px;
    font-weight: normal;
    line-height: 1.1;
    font-size: 9px;
}

/* Duration text below the status icon */
.status-badge .time-info {
    display: block;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.95;
    margin-top: 2px;
    line-height: 1.3;
    letter-spacing: 0.3px;
}


/* Shard-summary line added to the workflow card (e.g. "✓ 9/11 passed • ✗ 2 failed") */
.workflow-run-card .workflow-shard-summary {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary, #888);
    font-weight: 500;
}
