/* ── Async image upload component ──────────────────────────────── */

.aiu-status {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .76rem;
    color: var(--ink-soft, #6b7280);
    min-height: 1.2em;
    margin-top: .25rem;
}

.aiu-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid var(--border, #e5e2dc);
    border-top-color: var(--signal, #c0392b);
    border-radius: 50%;
    animation: aiu-spin .6s linear infinite;
    flex-shrink: 0;
}

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

/* Preview grid — used by the multi-upload mode */
.aiu-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: .4rem;
    margin-top: .65rem;
}

/* Single card */
.aiu-card {
    position: relative;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border, #e5e2dc);
    background: var(--surface, #f5f4f0);
    aspect-ratio: 1;
}

.aiu-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Loading shimmer (shown before image loads) */
.aiu-card--loading {
    background: linear-gradient(90deg,
        var(--border, #e5e2dc) 25%,
        var(--surface, #f5f4f0) 50%,
        var(--border, #e5e2dc) 75%);
    background-size: 200% 100%;
    animation: aiu-shimmer 1.2s ease-in-out infinite;
}

@keyframes aiu-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Overlay spinner on loading card */
.aiu-card--loading::after {
    content: '';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aiu-card__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aiu-spin .6s linear infinite;
}

/* Remove button */
.aiu-card__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: .72rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
}

.aiu-card:hover .aiu-card__remove { opacity: 1; }

@media (hover: none) {
    .aiu-card__remove { opacity: 1; }
}

/* Error state */
.aiu-card--error {
    border-color: var(--signal, #c0392b);
}

.aiu-card--error::before {
    content: '!';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--signal, #c0392b);
    background: rgba(192,57,43,.07);
}

/* Single-image preview (wider, for featured image) */
.aiu-single-preview {
    margin-top: .65rem;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: var(--surface, #f5f4f0);
    border: 1px solid var(--border, #e5e2dc);
}

.aiu-single-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    display: block;
}

.aiu-single-preview__remove {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: .2rem .55rem;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .72rem;
    cursor: pointer;
}

/* Upload zone / drop target */
.aiu-dropzone {
    border: 2px dashed var(--border, #e5e2dc);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    background: var(--surface, #f5f4f0);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: .84rem;
    color: var(--ink-soft, #6b7280);
}

.aiu-dropzone:hover,
.aiu-dropzone.dragover {
    border-color: var(--signal, #c0392b);
    background: rgba(192,57,43,.04);
    color: var(--ink, #0e1117);
}

/* ── File upload cards ──────────────────────────────────────────────────── */

.aiu-file-card {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .85rem;
    border: 1px solid var(--border, #e5e2dc);
    border-radius: 8px;
    background: var(--white, #fff);
    margin-top: .5rem;
    font-size: .85rem;
}

.aiu-file-card--loading {
    gap: .5rem;
    color: var(--ink-soft, #6b7280);
    background: var(--surface, #f5f4f0);
}

.aiu-file-card--error {
    border-color: var(--signal, #c0392b);
    background: rgba(192,57,43,.04);
}

.aiu-file-card__icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
}

.aiu-file-card__info {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
    flex: 1;
}

.aiu-file-card__name {
    color: var(--ink, #0e1117);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aiu-file-card__size {
    color: var(--ink-soft, #6b7280);
    font-size: .76rem;
}

.aiu-file-card__loading-label {
    color: var(--ink-soft, #6b7280);
    font-size: .84rem;
}

.aiu-file-card__remove {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: var(--surface, #f5f4f0);
    border: 1px solid var(--border, #e5e2dc);
    border-radius: 50%;
    font-size: .8rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-soft, #6b7280);
    transition: background .12s, color .12s;
}

.aiu-file-card__remove:hover {
    background: var(--signal, #c0392b);
    color: #fff;
    border-color: var(--signal, #c0392b);
}

/* Legacy compat (used by groups/equipment older views) */
.async-upload-preview { display: grid; gap: .35rem; border: 1px solid var(--border, #e5e2dc); border-radius: 8px; padding: .4rem; background: var(--white, #fff); }
.async-upload-preview img { width: 100%; height: 92px; object-fit: cover; border-radius: 6px; }
.async-upload-preview__meta { font-size: .72rem; color: var(--ink-soft, #6b7280); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.async-upload-preview__remove { border: 1px solid var(--border, #e5e2dc); background: transparent; border-radius: 999px; padding: .25rem .55rem; font-size: .72rem; cursor: pointer; }
