/**
 * 3Syxty Studio — File Upload Component
 *
 * Drag-and-drop upload zone with progress tracking, file previews,
 * format validation, and multi-file support.
 */

/* -----------------------------------------------------------------------
   Drop Zone
   ----------------------------------------------------------------------- */

.upload-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-8) var(--space-6);
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-xl);
    background-color: var(--surface-secondary);
    cursor: pointer;
    transition: border-color var(--motion-fast),
                background-color var(--motion-fast),
                box-shadow var(--motion-fast);
    text-align: center;
    user-select: none;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background-color: var(--accent-primary-subtle);
}

.upload-zone[data-dragover="true"] {
    border-color: var(--accent-primary);
    background-color: var(--accent-primary-subtle);
    box-shadow: var(--shadow-glow);
}

.upload-zone:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.upload-zone[data-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.upload-zone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: var(--accent-primary-subtle);
    color: var(--accent-primary);
    transition: background-color var(--motion-fast), transform var(--motion-fast);
}

.upload-zone:hover .upload-zone-icon,
.upload-zone[data-dragover="true"] .upload-zone-icon {
    background-color: var(--accent-primary-muted);
    transform: scale(1.05);
}

.upload-zone-icon svg {
    width: 24px;
    height: 24px;
}

.upload-zone-title {
    font: var(--type-body);
    font-weight: 500;
    color: var(--text-primary);
}

.upload-zone-title strong {
    color: var(--accent-primary);
}

.upload-zone-hint {
    font: var(--type-body-sm);
    color: var(--text-muted);
}

.upload-zone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Compact variant (inline) */
.upload-zone-compact {
    flex-direction: row;
    padding: var(--space-4);
    gap: var(--space-4);
}

.upload-zone-compact .upload-zone-icon {
    width: 40px;
    height: 40px;
}

.upload-zone-compact .upload-zone-icon svg {
    width: 20px;
    height: 20px;
}

/* -----------------------------------------------------------------------
   File List
   ----------------------------------------------------------------------- */

.upload-file-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.upload-file {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background-color: var(--surface-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: border-color var(--motion-instant);
    animation: slide-up var(--motion-fast);
}

.upload-file[data-status="error"] {
    border-color: var(--error);
    background-color: var(--error-subtle);
}

.upload-file[data-status="complete"] {
    border-color: var(--success);
}

/* File thumbnail / icon */
.upload-file-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--surface-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.upload-file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-file-thumb svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

/* File info */
.upload-file-info {
    flex: 1;
    min-width: 0;
}

.upload-file-name {
    font: var(--type-body-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-file-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font: var(--type-caption);
    color: var(--text-muted);
    margin-top: 2px;
}

.upload-file-error {
    font: var(--type-caption);
    color: var(--error-text);
    margin-top: 2px;
}

/* Progress bar */
.upload-file-progress {
    width: 100%;
    height: 3px;
    background-color: var(--surface-tertiary);
    border-radius: var(--radius-full);
    margin-top: var(--space-1-5);
    overflow: hidden;
}

.upload-file-progress-bar {
    height: 100%;
    background-color: var(--accent-primary);
    border-radius: var(--radius-full);
    transition: width 200ms ease-out;
}

.upload-file[data-status="complete"] .upload-file-progress-bar {
    background-color: var(--success);
}

.upload-file[data-status="error"] .upload-file-progress-bar {
    background-color: var(--error);
}

/* Status icon */
.upload-file-status {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.upload-file-status svg {
    width: 16px;
    height: 16px;
}

.upload-file-status-spinner svg {
    animation: spin 0.7s linear infinite;
    color: var(--accent-primary);
}

.upload-file-status-success svg {
    color: var(--success);
}

.upload-file-status-error svg {
    color: var(--error);
}

/* Actions */
.upload-file-actions {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

.upload-file-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color var(--motion-instant), color var(--motion-instant);
}

.upload-file-remove:hover {
    background-color: var(--error-subtle);
    color: var(--error);
}

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

/* -----------------------------------------------------------------------
   Image Preview Grid
   ----------------------------------------------------------------------- */

.upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.upload-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--surface-tertiary);
    border: 1px solid var(--border-subtle);
}

.upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 50%);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: var(--space-1-5);
    opacity: 0;
    transition: opacity var(--motion-fast);
}

.upload-preview-item:hover .upload-preview-item-overlay {
    opacity: 1;
}

.upload-preview-item-name {
    font: var(--type-caption);
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.upload-preview-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.upload-preview-item-remove:hover {
    background: rgba(239, 68, 68, 0.8);
}

.upload-preview-item-remove svg {
    width: 10px;
    height: 10px;
}

/* Upload progress overlay on preview */
.upload-preview-item-progress {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.upload-preview-item-progress-text {
    font: var(--type-body);
    font-weight: 700;
    color: #FFFFFF;
}
