/* ============================================================================
   Mobile dropdown safety net — placed at the end of the file so it wins
   over earlier base rules (mobile overrides defined earlier in this file
   were being defeated by `.ci-run-dropdown { min-width: 650px }` at L2862,
   and inline `style="min-width:400px"` on a few <select>s).

   With !important, dropdowns and their containers are guaranteed never to
   overflow the viewport on small screens regardless of inline styles or
   source-order conflicts.
   ============================================================================ */
@media (max-width: 768px) {
    .ci-run-dropdown,
    .version-dropdown,
    select[id$="-select"] {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box;
    }
    /* Header-info containers on tab pages — let children shrink + wrap */
    .header-info {
        min-width: 0;
        flex-wrap: wrap;
        width: 100%;
    }
    .header-info > * {
        max-width: 100%;
        min-width: 0;
    }
    /* Section-level header-info (Multi-Arch Release pipeline section,
       CI Nightly run-selector, etc.) should stack vertically on mobile */
    .dashboard-section .header-info {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    /* Multi-Arch CI filter bar — keep filter pills from spilling sideways */
    .ci-hud-filters {
        flex-wrap: wrap;
        gap: 8px;
    }
    .ci-hud-filters .filter-group {
        min-width: 0;
        flex: 1 1 auto;
    }
    .ci-hud-filters .filter-group select,
    .ci-hud-filters .filter-group input {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
}

/* ----------------------------------------------------------------------------
   Downloads modal/popover
   ----------------------------------------------------------------------------
   The modal markup uses .modal / .modal-backdrop / .modal-content /
   .modal-header / .modal-body / .modal-close. Until now ONLY the inner
   .release-downloads-modal-content was styled — the base classes had no
   rules at all, so when JS set display:flex the modal opened in normal
   document flow with no fixed positioning, no backdrop, no z-index. To
   the user it looked like "the download button does nothing" because the
   body content was simply pushed below the page (or invisible behind
   other elements). These base rules fix that: full-viewport overlay,
   click-out-to-close backdrop, centered card, proper close-X button. */
.modal {
    position: fixed;
    inset: 0;
    z-index: 9500;
    /* JS toggles between display:none (hidden) and display:flex (shown);
       we provide the centering rules so the .modal-content lands in the
       middle of the viewport regardless of body scroll position. */
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: modal-fade-in 0.18s ease;
}
.modal-content {
    position: relative;
    background: var(--card-bg, #1f2937);
    color: var(--text-primary, #e5e7eb);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.55);
    max-width: 720px;
    width: min(720px, 92vw);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-slide-up 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-header {
    flex: 0 0 auto;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background-color: var(--card-bg, #1f2937);
    background-image: linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04));
}
.modal-header h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}
.modal-body {
    flex: 1 1 auto;
    /* CRITICAL min-height:0 — same trick as the tree-view sidebar — lets
       this flex item shrink below content size so overflow:auto works. */
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px;
}
.modal-close {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: var(--text-muted, #888);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: color 0.12s, background 0.12s;
}
.modal-close:hover {
    color: var(--status-fail, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}
@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modal-slide-up {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}
[data-theme="light"] .modal-content {
    background: #fff;
    color: #1e293b;
    border-color: #e2e8f0;
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.18);
}
[data-theme="light"] .modal-header {
    background-color: #f8fafc;
    background-image: none;
    border-bottom-color: #e2e8f0;
}
[data-theme="light"] .modal-close:hover {
    background: rgba(239, 68, 68, 0.06);
}

.release-downloads-modal-content {
    max-width: 880px;
    width: min(880px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.release-downloads-modal-content .modal-body {
    overflow-y: auto;
    padding: 0 24px 20px;
}

#release-downloads-body .rd-section {
    margin-bottom: 20px;
}
#release-downloads-body .rd-section h4 {
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
#release-downloads-body .rd-section .rd-section-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#release-downloads-body table.rd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
#release-downloads-body table.rd-table th {
    background: var(--table-header-bg);
    text-align: left;
    padding: 6px 10px;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}
#release-downloads-body table.rd-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--card-border);
    vertical-align: middle;
}
#release-downloads-body table.rd-table td.rd-arch {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-weight: 600;
    color: var(--text-primary);
    width: 140px;
}
#release-downloads-body .rd-link,
#release-downloads-body .rd-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.25);
    text-decoration: none;
    cursor: pointer;
    margin-right: 4px;
}
#release-downloads-body .rd-link:hover,
#release-downloads-body .rd-copy:hover {
    background: rgba(99, 102, 241, 0.22);
}
#release-downloads-body .rd-link.is-secondary,
#release-downloads-body .rd-copy.is-secondary {
    background: rgba(120, 120, 120, 0.10);
    color: var(--text-secondary);
    border-color: rgba(120, 120, 120, 0.25);
}

#release-downloads-body .rd-snippet {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.74rem;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 6px 0 0;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Multi-Arch Release - Nightly downloads modal — additional install-instruction
   widgets used by `_marRenderDownloadsBody`. The shared rd-* classes above
   handle the table-style sections; the cards + grids below are for the
   per-family pip-install grid. */
#release-downloads-body .rd-install-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
    margin-top: 8px;
}
#release-downloads-body .rd-install-card {
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--bg-elevated, rgba(255,255,255,0.02));
}
#release-downloads-body .rd-install-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
#release-downloads-body .rd-install-card-head .rd-arch {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--primary-light, #818cf8);
}
#release-downloads-body .rd-install-card-head .rd-install-card-hw {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.2;
}
#release-downloads-body .rd-section-footer {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
#release-downloads-body .rd-link-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
#release-downloads-body .rd-link-list li {
    padding: 4px 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}
#release-downloads-body .rd-copy.is-tiny {
    padding: 1px 6px;
    font-size: 0.66rem;
}

#release-downloads-body .rd-checksum {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Confirmation toast for the "copied" state */
.rh-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(34, 197, 94, 0.95);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.82rem;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: rhToastFade 2.2s ease forwards;
}
@keyframes rhToastFade {
    0%   { opacity: 0; transform: translate(-50%, 8px); }
    10%  { opacity: 1; transform: translate(-50%, 0); }
    85%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -4px); }
}

/* Info banner that explains how to read the Release History table. Sits
   between the page header and the filters panel. Looks like a subtle,
   primary-tinted callout — much more readable than the previous misuse
   of `.section-meta`, which was actually a tiny all-caps pill badge style
   meant for inline title metadata (it made the paragraph render as one
   absurd long uppercase ribbon). */
/* Matrix-control toolbar — small toolbar that sits between the filters
   row and the matrix table. Hosts the "Expand all" / "Collapse all"
   controls. Was originally tucked into the right edge of the filters
   row where users couldn't find it; promoted to its own row with bigger
   button styling so the matrix-expansion feature is discoverable. */
.mar-matrix-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 8px 0 14px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border, var(--border-color));
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}
.mar-matrix-toolbar-label {
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    margin-right: 4px;
}
.mar-matrix-toolbar-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-left: 8px;
}
.mar-matrix-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--card-border, var(--border-color));
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-standard),
                border-color var(--dur-fast) var(--ease-standard),
                transform var(--dur-fast) var(--ease-standard);
}
.mar-matrix-btn i[data-lucide],
.mar-matrix-btn svg.lucide {
    width: 14px;
    height: 14px;
    color: var(--primary-light, #818cf8);
}
.mar-matrix-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.45);
}
.mar-matrix-btn:active { transform: translateY(1px); }
.mar-matrix-btn-primary {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.40);
    color: var(--text-primary);
}
.mar-matrix-btn-primary:hover {
    background: rgba(99, 102, 241, 0.24);
    border-color: rgba(99, 102, 241, 0.60);
}
.mar-matrix-btn-primary i[data-lucide],
.mar-matrix-btn-primary svg.lucide {
    color: var(--primary-light, #818cf8);
}
[data-theme="light"] .mar-matrix-toolbar { background: #f8fafc; }
[data-theme="light"] .mar-matrix-btn { background: #fff; }
[data-theme="light"] .mar-matrix-btn-primary { background: rgba(99, 102, 241, 0.10); }

@media (max-width: 600px) {
    .mar-matrix-toolbar-hint { display: none; }
    .mar-matrix-btn { padding: 8px 12px; min-height: 36px; }
}
