/*
 * Membership-Import detail view.
 *
 * Token-aware presentation of a single MembershipImport record inside the
 * `.auth-shell__workspace` glass container. Replaces an earlier hand-authored
 * Tailwind-palette card (bg-white, gray-200, shadow-md, font-semibold) that
 * violated several DESIGN.md rules: Tinted-Neutral (#fff frame), Heavy-Weight
 * (semibold 600), and one-off chrome instead of design-system surfaces.
 *
 * The shape: a single label/value list, no nested cards. Rows stack on
 * narrow viewports so long Spanish labels do not crush the value column.
 * Status iconography is brand-mapped where the system has a token (accent for
 * error, secondary for "in progress", primary for "processed clean") and uses
 * a single off-amber for the "processed with errors" warning case, which the
 * system has no canonical token for.
 */

.mi-view {
    display: flex;
    flex-direction: column;
}

.mi-view__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
}

.mi-view__title {
    margin: 0;
    min-width: 0;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    word-break: break-word;
}

.mi-view__actions {
    flex-shrink: 0;
}

.mi-view__list {
    margin: 0;
    padding: 0 28px 8px;
    list-style: none;
}

.mi-view__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    min-width: 0;
}

.mi-view__row:first-child {
    border-top: 0;
}

.mi-view__label {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 760;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    word-break: break-word;
}

.mi-view__value {
    margin: 0;
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 760;
    line-height: 1.5;
    word-break: break-word;
}

.mi-view__value--mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.mi-view__value--message {
    white-space: pre-wrap;
    color: var(--text-soft);
}

.mi-view__value--message-error {
    white-space: pre-wrap;
    color: var(--color-accent);
}

.mi-view__filename {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.mi-view__filename:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 4px;
}

@media (min-width: 640px) {
    .mi-view__row {
        grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
        gap: 28px;
        align-items: baseline;
    }
}

/*
 * Status indicator. Icon + label inline; the visible label is the accessible
 * name (icons are aria-hidden in the template). Color comes from a token per
 * status state, never a generic Tailwind hue.
 */

.mi-view__status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mi-view__status-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.mi-view__status-icon--error { color: var(--color-accent); }
.mi-view__status-icon--processing { color: var(--color-secondary); }
.mi-view__status-icon--warning { color: #d29318; } /* off-amber, no token */
.mi-view__status-icon--success { color: var(--color-primary); }

[data-theme="light"] .mi-view__status-icon--warning { color: #b07a13; }

.mi-view__status-label {
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.4;
    word-break: break-word;
}

@media (prefers-reduced-motion: no-preference) {
    .mi-view__status-icon--processing {
        animation: mi-view-spin 1.4s linear infinite;
    }
}

@keyframes mi-view-spin {
    to { transform: rotate(360deg); }
}

/*
 * Error count + download link cluster. Wraps on narrow viewports so a long
 * download label does not push past the value column.
 */

.mi-view__error-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.mi-view__error-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.mi-view__error-link:hover {
    background: var(--surface-strong);
    border-color: var(--line-strong);
    color: var(--text);
}

.mi-view__error-link:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.mi-view__error-link svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

@media (prefers-reduced-motion: reduce) {
    .mi-view__error-link {
        transition: none;
    }
}

/*
 * Poll-failure notice. Hidden until the import-status controller catches a
 * fetch error. Sits directly below the status pill so the connection between
 * "the spinner stopped updating" and "here's what to do" is unambiguous.
 */

.mi-view__poll-error {
    margin: 8px 0 0;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--color-accent) 42%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--color-accent) 12%, transparent);
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.45;
}

.mi-view__poll-error[hidden] {
    display: none;
}
