/* ============================================================
   Uploads: the top-bar indicator, the Uploads pane, and its rows
   (Components/FileUpload*.razor). Everything here is built from
   the design tokens, so it follows the theme.

   Row heights are fixed, and are repeated in FileUploadPane.razor,
   because long lists are virtualized by row height.
   ============================================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Top-bar indicator ---- */

.upload-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    height: 32px;
    padding: 0 12px 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--neutral-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-body);
    white-space: nowrap;
    cursor: pointer;
}

.upload-indicator:hover {
    border-color: var(--text-muted);
}

.upload-indicator:focus-visible,
.upload-icon-button:focus-visible,
.upload-group-toggle:focus-visible,
.upload-pane-title-row h2:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

.upload-indicator.open {
    border-color: var(--brand-accent);
    background: var(--accent-bg);
}

.upload-indicator.attention {
    border-color: var(--status-warning);
    background: var(--status-warning-bg);
}

.upload-indicator-detail {
    color: var(--text-muted);
}

.upload-indicator-attention {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--status-warning);
    font-weight: var(--fw-semibold);
}

.upload-ring {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke-width: 2.2;
}

.upload-ring-track {
    stroke: var(--border-strong);
}

.upload-ring-fill {
    stroke: var(--brand-accent);
    stroke-linecap: round;
    transition: stroke-dasharray var(--dur-base) var(--ease-out);
}

@media (max-width: 640px) {
    .upload-indicator-detail {
        display: none;
    }
}

/* ---- Pane ---- */

/* A side rail: css/side-rail.css places it under the top bar and makes room for it beside the page. */
.upload-pane {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-subtle);
    background: var(--surface-app);
    color: var(--text-secondary);
    font-size: var(--fs-body);
    line-height: var(--lh-normal);
}

.upload-pane-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 12px 10px 18px;
}

.upload-pane-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.upload-pane-title-row h2 {
    margin: 0;
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: var(--fs-section);
    font-weight: var(--fw-semibold);
    /* The base heading styles carry a display-size line height. */
    line-height: var(--lh-normal);
}

.upload-pane-destination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 18px;
    color: var(--text-muted);
    font-size: var(--fs-secondary);
}

.upload-pane-destination a {
    color: var(--status-info);
    text-decoration: none;
}

.upload-pane-destination a:hover {
    text-decoration: underline;
}

.upload-pane-body {
    flex: 1;
    min-height: 0;
    padding: 4px 10px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    /* Files move between groups as they progress. The list stays where the reader left it. */
    overflow-anchor: none;
}

.upload-pane-footer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: var(--fs-small);
}

/* ---- Summary ---- */

.upload-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 8px;
    padding: 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-2xl);
    background: var(--surface-card);
}

.upload-summary-headline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: var(--fs-card-title);
    font-weight: var(--fw-semibold);
}

.upload-summary-percent {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.upload-summary-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    color: var(--text-muted);
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
}

.upload-summary-sentence {
    font-size: var(--fs-secondary);
}

.upload-summary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.upload-summary-note {
    color: var(--text-muted);
    font-size: var(--fs-small);
}

/* ---- Progress bars ---- */

.upload-bar {
    display: block;
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--border-strong);
}

.upload-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand-accent);
    transition: width var(--dur-base) var(--ease-out);
}

.upload-bar-large {
    height: 6px;
    border-radius: 3px;
}

/* Nothing is moving. The bar shows how much of the list arrived. */
.upload-bar.settled > span {
    background: var(--status-success);
}

/* ---- Groups ---- */

.upload-group {
    margin-top: 14px;
}

.upload-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 6px 8px;
    color: var(--text-muted);
    font-size: var(--fs-label);
    font-weight: var(--fw-semibold);
    /* Headings bring their own line height, which would stretch the count beside them. */
    line-height: var(--lh-normal);
}

.upload-group-header.caps .upload-group-name {
    letter-spacing: var(--label-spacing-wide);
    text-transform: uppercase;
}

.upload-group.attention .upload-group-header {
    color: var(--status-warning);
}

.upload-group-toggle {
    box-sizing: border-box;
    width: 100%;
    border: 0;
    border-radius: var(--radius-xl);
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.upload-group-toggle:hover {
    background: var(--neutral-bg);
}

.upload-group-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* A destination heading: the place's own name, not a status label. */
.upload-group-toggle:not(.caps) .upload-group-name {
    overflow: hidden;
    color: var(--text-primary);
    font-size: var(--fs-body);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-group-subtitle {
    color: var(--text-muted);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
}

.upload-group-note {
    margin-left: auto;
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
    font-weight: var(--fw-regular);
    white-space: nowrap;
}

.upload-count {
    padding: 0 7px;
    border-radius: var(--radius-pill);
    background: var(--neutral-bg);
    color: var(--text-secondary);
    font-size: var(--fs-label);
    font-variant-numeric: tabular-nums;
}

/* ---- Rows ---- */

.upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    height: 52px;
    padding: 0 4px 0 8px;
    border-radius: var(--radius-xl);
}

.upload-row-attention {
    align-items: flex-start;
    height: 96px;
    padding-top: 8px;
}

.upload-tile {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xl);
    background: var(--neutral-bg);
}

.upload-tile.data {
    background: var(--status-info-bg);
}

.upload-tile.attention {
    background: var(--status-warning-bg);
}

.upload-row-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.upload-row-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.upload-row-name {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-row-meta {
    margin-left: auto;
    color: var(--text-muted);
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.upload-row-status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.upload-row-status > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-row-status.active {
    color: var(--status-info);
}

.upload-row-status.ready {
    color: var(--status-success);
}

/* Two lines at most, so the row keeps its height. The full text is in the title. */
.upload-row-message {
    display: -webkit-box;
    overflow: hidden;
    font-size: var(--fs-secondary);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.upload-row-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.upload-chip {
    flex: none;
    padding: 0 8px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-pill);
    color: var(--text-tertiary);
    font-size: var(--fs-micro);
    white-space: nowrap;
}

.upload-icon-button {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

button.upload-icon-button:hover,
a.upload-icon-button:hover {
    background: var(--neutral-bg);
    color: var(--text-primary);
}

/* Holds the place of an action that this row does not have, so that rows line up. */
span.upload-icon-button {
    cursor: default;
}

@media (prefers-reduced-motion: reduce) {
    .upload-ring-fill,
    .upload-bar > span {
        transition: none;
    }
}

/* ---- File status chip (Components/FileStatusChip.razor), used in file lists ---- */

.file-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-small);
    white-space: nowrap;
}

.file-status-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-status-chip.active {
    color: var(--status-info);
}

.file-status-chip.attention {
    color: var(--status-warning);
}

.file-status-chip.ready {
    color: var(--status-success);
}

button.file-status-chip {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
}

button.file-status-chip:hover {
    text-decoration-color: currentColor;
}

button.file-status-chip:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* A file that finished while the page was open is pointed out for a minute. */
.dashboard .data-grid .file-row-ready [role="gridcell"],
.dashboard .data-grid .file-row-ready td {
    background: var(--status-success-bg);
}

/* ---- In progress card on the record Files page (Components/RecordFileActivityCard.razor) ----
   Its rows use the file grid's column widths and cell padding, so the two line up. */

.file-activity-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    padding: 10px 18px;
    background: var(--surface-rail);
    border-bottom: 1px solid var(--border-subtle);
}

.file-activity-title {
    color: var(--text-primary);
    font-size: var(--fs-secondary);
    font-weight: var(--fw-semibold);
}

.file-activity-summary {
    color: var(--text-muted);
    font-size: var(--fs-small);
}

.file-activity-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 140px 120px 100px 198px;
    align-items: center;
    border-top: 1px solid var(--border-muted);
}

.file-activity-row:first-child {
    border-top: 0;
}

.file-activity-row > div {
    min-width: 0;
    padding: 8px 7px;
}

.file-activity-row > div:first-child {
    padding-left: 18px;
}

.file-activity-file {
    display: flex;
    align-items: center;
    gap: 11px;
}

.file-activity-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.file-activity-status {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: var(--text-muted);
    font-size: var(--fs-small);
}

.file-activity-status.active {
    color: var(--status-info);
}

.file-activity-status.attention {
    color: var(--status-warning);
}

.file-activity-sentence {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-activity-step {
    flex: none;
    color: var(--text-muted);
    white-space: nowrap;
}

.file-activity-bar {
    flex: none;
    width: 72px;
}

.file-activity-chip {
    display: inline-flex;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: var(--neutral-bg);
    color: var(--text-secondary);
    font-size: var(--fs-small);
    white-space: nowrap;
}

/* Not there yet: the data frame is made once the file has been processed. */
.file-activity-chip.pending {
    border: 1px dashed var(--border-strong);
    background: transparent;
    color: var(--text-tertiary);
}

.file-activity-row > .file-activity-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-right: 18px;
}

.file-activity-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 24px;
    padding: 0 6px 0 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--neutral-bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--fs-small);
    cursor: pointer;
}

.file-activity-toggle:focus-visible,
.file-activity-more:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

.file-activity-row > .file-activity-steps {
    grid-column: 1 / -1;
    padding: 0 18px 14px 61px;
}

.file-activity-times {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
}

.file-activity-more {
    display: block;
    box-sizing: border-box;
    width: 100%;
    padding: 9px 18px;
    border: 0;
    border-top: 1px solid var(--border-muted);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-small);
    text-align: left;
}

button.file-activity-more {
    color: var(--status-info);
    font-weight: var(--fw-semibold);
    cursor: pointer;
}

/* On a narrow page the type, data frame, and size columns give way to the file and its actions. */
@media (max-width: 900px) {
    .file-activity-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .file-activity-row > div:nth-child(2),
    .file-activity-row > div:nth-child(3),
    .file-activity-row > div:nth-child(4) {
        display: none;
    }
}

/* ---- Processing steps (Components/FileProcessingStepStrip.razor) ---- */

.file-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.file-steps li {
    display: flex;
    flex: 1 1 104px;
    align-items: center;
    gap: 5px;
    padding-top: 7px;
    border-top: 3px solid var(--border-strong);
    color: var(--text-muted);
    font-size: var(--fs-small);
}

.file-steps li.done {
    border-top-color: var(--status-success);
    color: var(--text-secondary);
}

.file-steps li.current {
    border-top-color: var(--brand-accent);
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
}

.file-steps li.attention {
    border-top-color: var(--status-warning);
    color: var(--status-warning);
    font-weight: var(--fw-semibold);
}
