/* Upload modal styles */

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

.upload-modal-content {
    width: min(100vw - 1.5rem, 640px);
    max-width: 640px;
    max-height: min(90vh, 720px);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    gap: 0;
    /* Override the global `transition: all` on .modal-content (perf footgun during repaint). */
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.upload-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    background: linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--card)) 60%, hsl(var(--muted) / 0.18) 100%);
}

.upload-modal-heading {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.upload-modal-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: calc(var(--radius) + 4px);
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    flex: 0 0 auto;
}

.upload-modal-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.upload-modal-title-group {
    min-width: 0;
}

.upload-modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.upload-modal-subtitle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
    font-size: 0.82rem;
    color: hsl(var(--muted-foreground));
    min-width: 0;
}

.upload-modal-folder-icon {
    width: 0.9rem;
    height: 0.9rem;
    flex: 0 0 auto;
}

.upload-modal-path {
    font-weight: 500;
    color: hsl(var(--foreground));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 320px;
}

.upload-modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.1rem 1.25rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed hsl(var(--border));
    border-radius: calc(var(--radius) + 6px);
    background: hsl(var(--background));
    padding: 1.6rem 1.25rem;
    transition: border-color 150ms ease, background-color 150ms ease;
    cursor: pointer;
    position: relative;
}

.drop-zone:hover {
    border-color: hsl(var(--primary) / 0.6);
    background: hsl(var(--muted) / 0.35);
}

.drop-zone.drag-over {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.07);
}

.drop-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    text-align: center;
}

.drop-zone-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.drop-zone-icon svg {
    width: 28px;
    height: 28px;
}

.drop-zone-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: hsl(var(--foreground));
}

.drop-zone-subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}

.drop-zone-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.drop-zone-hint {
    margin: 0;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.85);
}

/* When files are selected, drop zone is compact */
.upload-modal-content.has-selection .drop-zone {
    padding: 0.85rem 1rem;
}

.upload-modal-content.has-selection .drop-zone-inner {
    flex-direction: row;
    justify-content: space-between;
    gap: 0.85rem;
    text-align: left;
}

.upload-modal-content.has-selection .drop-zone-icon {
    width: 36px;
    height: 36px;
}

.upload-modal-content.has-selection .drop-zone-icon svg {
    width: 18px;
    height: 18px;
}

.upload-modal-content.has-selection .drop-zone-title {
    font-size: 0.92rem;
}

.upload-modal-content.has-selection .drop-zone-subtitle {
    margin: 0.1rem 0 0;
}

.upload-modal-content.has-selection .drop-zone-actions {
    margin-left: auto;
}

/* Summary bar */
.upload-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    background: hsl(var(--muted) / 0.32);
    flex-wrap: wrap;
}

.upload-summary-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    flex-wrap: wrap;
}

.upload-summary-count {
    font-weight: 600;
    color: hsl(var(--foreground));
}

.upload-summary-size {
    font-weight: 500;
    color: hsl(var(--foreground));
}

.upload-summary-divider {
    opacity: 0.45;
}

.upload-summary-progress {
    color: hsl(var(--primary));
    font-weight: 500;
}

.upload-summary-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
    gap: 0.35rem;
}

.btn-sm svg {
    width: 0.95rem;
    height: 0.95rem;
}

/* Selected file list */
.upload-progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* Empty state inside the modal */
.upload-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.5rem;
    border: 1px dashed hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    background: hsl(var(--muted) / 0.2);
    color: hsl(var(--muted-foreground));
    font-size: 0.9rem;
}

.upload-empty-state svg {
    width: 1.5rem;
    height: 1.5rem;
    opacity: 0.6;
}

.upload-empty-state.hidden {
    display: none;
}

/* Per-file card */
.upload-task-card {
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    background: hsl(var(--card));
    padding: 0.75rem 0.85rem;
    /* Only animate on status changes (rare), not on every progress tick. */
    transition: border-color 150ms ease, background-color 150ms ease;
    contain: layout style;
    will-change: auto;
}

.upload-task-card.status-success {
    border-color: hsl(142 71% 45% / 0.6);
    background: hsl(142 71% 45% / 0.06);
}

.upload-task-card.status-failed {
    border-color: hsl(0 84.2% 60.2% / 0.6);
    background: hsl(0 84.2% 60.2% / 0.05);
}

.upload-task-card.status-cancelled {
    border-color: hsl(var(--border));
    opacity: 0.85;
}

.upload-task-head {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.7rem;
}

.upload-task-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
    flex: 0 0 auto;
}

.upload-task-icon svg {
    width: 18px;
    height: 18px;
}

.upload-task-meta-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.upload-task-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    line-height: 1.25;
}

.upload-task-path {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.2;
}

.upload-task-status-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
    min-width: 90px;
}

.upload-task-status {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    text-align: right;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-task-card.status-success .upload-task-status {
    color: hsl(142 71% 45%);
}

.upload-task-card.status-failed .upload-task-status {
    color: hsl(0 84.2% 60.2%);
}

.upload-task-card.status-uploading .upload-task-status {
    color: hsl(var(--primary));
}

.upload-task-size {
    font-size: 0.78rem;
    color: hsl(var(--muted-foreground));
    font-variant-numeric: tabular-nums;
}

.upload-task-remove {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    color: hsl(var(--muted-foreground));
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
    flex: 0 0 auto;
}

.upload-task-remove svg {
    width: 14px;
    height: 14px;
}

.upload-task-remove:hover {
    background: hsl(0 84.2% 60.2% / 0.1);
    color: hsl(0 84.2% 60.2%);
    border-color: hsl(0 84.2% 60.2% / 0.4);
}

.upload-task-progress {
    margin-top: 0.55rem;
    height: 6px;
    /* Short, cheap width transition for smoothness on the per-file bar. */
    transition: none;
}

.upload-task-progress .progress-fill {
    transition: width 120ms linear;
    will-change: width;
}

.upload-task-foot {
    margin-top: 0.4rem;
    display: flex;
    justify-content: flex-end;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

/* Footer */
.upload-modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid hsl(var(--border));
    background: hsl(var(--card));
    flex-wrap: wrap;
}

.upload-modal-foot-meta {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}

.upload-modal-foot-meta strong {
    color: hsl(var(--foreground));
    font-weight: 600;
}

.upload-modal-foot-meta.hidden {
    display: none;
}

.upload-modal-foot-actions {
    display: flex;
    gap: 0.55rem;
}

#startUploadBtn:not(:disabled) {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

#startUploadBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Mobile tweaks */
@media (max-width: 640px) {
    .upload-modal-content {
        width: 100vw;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }

    .upload-modal-content.has-selection .drop-zone-inner {
        flex-direction: column;
        text-align: center;
    }

    .upload-modal-foot {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-modal-foot-actions {
        justify-content: stretch;
    }

    .upload-modal-foot-actions .btn {
        flex: 1 1 0;
    }
}
