/* admin-packages.css — AD-PKG (/admin/packages, M4: APK, WF-23) and the
   per-product testing-content panel (TCE). Token-bound only (F-R01).

   The page composes chrome.css's record table and admin-editors.css's panels,
   action rows, and upload zone; this file adds only what a build table needs
   that a product table does not — ten columns, two toggle cells, and the
   Markdown field with a preview toggle. Column widths are fixed for the same
   reason the other admin tables fix theirs (SC §2.6: widths never re-compute
   row to row), so the bare pixel values here are that contract, not literals. */

/* --- Page composition ------------------------------------------------------
   Scoped to this page: the sibling editors space their panels with the flex gap
   on .adm-editor, and a bare .adm-panel + .adm-panel rule would double it. */
.adm-pkg {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    min-width: 0;
}

.adm-pkg__filters {
    align-items: flex-start;
}

/* The chip group's name is a span, not a <label> — it labels a radiogroup, not a
   single control — so it takes the filter row's label styling explicitly. */
.adm-pkg__filterlabel {
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.adm-pkg__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

/* --- The build table (APK-R01) ---------------------------------------------
   Nine columns carry past the shared 720px floor before the wrapper scrolls.
   The wrapper is what scrolls (chrome.css sets overflow-x on it), so the page
   body never scrolls sideways on a narrow screen. */
/* Product name over the file it shipped as: the file name is the fact an admin
   matches against a download, so it belongs in the row, not in a tooltip. */
.adm-pkg__product,
.adm-pkg__file,
.adm-pkg__when,
.adm-pkg__by {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adm-pkg__file,
.adm-pkg__by {
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.adm-pkg__when {
    font-family: var(--font-numeric);
    font-variant-numeric: tabular-nums;
}

/* --- Via column (§12) -------------------------------------------------------
   Which door the build came through: the admin's email, or the API key's public
   prefix (never the secret — AK-R01) with its label under it. */
.adm-pkg__keyprefix {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-numeric);
    font-size: var(--font-size--1);
}

/* --- Arrival highlight (§12/UPA-R04) ---------------------------------------
   The upload email deep-links ?pkg={id}; the staged row flashes on arrival —
   the forum's permalink contract (frm-arrive), driven by the query instead of
   a fragment. site.js scrolls the [data-arrive] row into view. */
.adm-pkg__row--arrive > td {
    animation: adm-pkg-arrive var(--motion-highlight, 1200ms) var(--motion-ease);
}

@keyframes adm-pkg-arrive {
    from { background-color: var(--accent-surface); }
    to { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .adm-pkg__row--arrive > td { animation: none; }
}

/* Unpublished rows read as not-yet-live without relying on color alone — the
   Published switch beside them carries the same fact as state (F-R05). */
.adm-pkg__row--unpublished .adm-pkg__product {
    color: var(--text-secondary);
    font-style: italic;
}

.adm-pkg__toggle {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.adm-pkg__toggle:disabled {
    cursor: not-allowed;
}

/* APK-R01: the prerequisite is readable text in the cell, never a tooltip. */
.adm-pkg__note {
    display: block;
    margin-top: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.adm-pkg__danger {
    color: var(--status-danger-text);
}

/* The expanded rows (a refusal, or the notes editor) span the full table and
   sit on the deep surface so they read as belonging to the row above. */
.adm-pkg__subrow > td {
    padding: var(--space-md);
    background-color: var(--surface-deep);
}

.adm-pkg__notes {
    display: flex;
    flex-direction: column;
    gap: var(--field-gap);
    max-width: var(--measure-prose-max);
}

.adm-pkg__facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.adm-pkg__minos .input {
    width: 16ch;
}

/* --- Upload panel (APK-R02, APK-R05) --------------------------------------- */
.adm-pkg__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.adm-pkg__version .input {
    width: 100%;
}

.adm-pkg__filelabel {
    display: block;
    margin-bottom: var(--label-gap);
}

.adm-pkg__progress {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

/* The native element carries the value to assistive tech; the appearance is
   normalized so the bar reads the same in both themes. */
.adm-pkg__meter {
    width: 100%;
    height: 6px;
    appearance: none;
    border: none;
    border-radius: var(--radius-control);
    background-color: var(--surface-deep);
    color: var(--accent);
}

.adm-pkg__meter::-webkit-progress-bar {
    border-radius: var(--radius-control);
    background-color: var(--surface-deep);
}

.adm-pkg__meter::-webkit-progress-value {
    border-radius: var(--radius-control);
    background-color: var(--accent);
}

.adm-pkg__meter::-moz-progress-bar {
    border-radius: var(--radius-control);
    background-color: var(--accent);
}

.adm-pkg__pct {
    color: var(--text-secondary);
    font-family: var(--font-numeric);
    font-size: var(--font-size--1);
    font-variant-numeric: tabular-nums;
}

/* --- Testing content panel (TCE-R01) --------------------------------------- */
.adm-pkg__tcproduct .input {
    width: 28ch;
    max-width: 100%;
}

.adm-pkg__saved {
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

/* --- Markdown field with a preview toggle ----------------------------------
   The toggle sits on the label line so the field keeps one row of chrome; the
   preview replaces the box rather than sitting beside it, because the admin
   pane is not wide enough for a split that would push both under measure. */
.adm-mdfield__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-sm);
}

.adm-mdfield__toggle {
    font-size: var(--font-size--1);
}

.adm-mdfield__preview {
    min-height: 6rem;
    padding: var(--container-pad-dense);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-container);
    background-color: var(--surface-deep);
}

/* Refused uploads (SHIP-R28): the reason is a sentence, so it wraps. */
.adm-pkg__why {
    min-width: 24ch;
    max-width: 60ch;
    white-space: normal;
    overflow-wrap: anywhere;
}
