/**
 * MultipleUpload v1.0
 * (c) RichScripts
 */

/* ── CSS Custom Properties ── */
:root {
    --mu-primary: #4f46e5;
    --mu-primary-hover: #4338ca;
    --mu-primary-light: #eef2ff;
    --mu-success: #16a34a;
    --mu-success-light: #f0fdf4;
    --mu-danger: #dc2626;
    --mu-danger-light: #fef2f2;
    --mu-warning: #d97706;
    --mu-gray-50: #f9fafb;
    --mu-gray-100: #f3f4f6;
    --mu-gray-200: #e5e7eb;
    --mu-gray-300: #d1d5db;
    --mu-gray-400: #9ca3af;
    --mu-gray-500: #6b7280;
    --mu-gray-600: #4b5563;
    --mu-gray-700: #374151;
    --mu-gray-800: #1f2937;
    --mu-gray-900: #111827;
    --mu-font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mu-font-size: 0.875rem;
    --mu-border-radius: 0.5rem;
    --mu-border-radius-sm: 0.375rem;
    --mu-transition: 150ms ease;
    --mu-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --mu-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --mu-thumb-size: 64px;
}

/* ── Base ── */
.mu-uploader,
.mu-dropzone-standalone,
.mu-attachments {
    font-family: var(--mu-font-family);
    font-size: var(--mu-font-size);
    color: var(--mu-gray-800);
    line-height: 1.5;
}

/* ── Select Button ── */
.mu-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: var(--mu-primary);
    color: white;
    border: none;
    border-radius: var(--mu-border-radius-sm);
    font-size: var(--mu-font-size);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--mu-transition), box-shadow var(--mu-transition), transform var(--mu-transition);
    box-shadow: var(--mu-shadow);
}

.mu-select-btn:hover {
    background: var(--mu-primary-hover);
    box-shadow: var(--mu-shadow-md);
    transform: translateY(-1px);
}

.mu-select-btn:active {
    transform: translateY(0);
}

/* ── Drop Zone ── */
.mu-dropzone,
.mu-dropzone-standalone .mu-dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 160px;
    padding: 2rem;
    margin-top: 1rem;
    border: 2px dashed var(--mu-gray-300);
    border-radius: var(--mu-border-radius);
    background: var(--mu-gray-50);
    color: var(--mu-gray-500);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--mu-transition), background var(--mu-transition), color var(--mu-transition), box-shadow var(--mu-transition);
}

.mu-dropzone:hover,
.mu-dropzone-standalone .mu-dropzone-content:hover {
    border-color: var(--mu-primary);
    background: var(--mu-primary-light);
    color: var(--mu-primary);
}

.mu-drag-over,
.mu-drag-over .mu-dropzone-content {
    border-color: var(--mu-primary) !important;
    background: var(--mu-primary-light) !important;
    color: var(--mu-primary) !important;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.mu-dropzone-icon { opacity: 0.6; }
.mu-dropzone-text { font-size: 0.9375rem; font-weight: 500; }

/* ── Inline Image Thumbnails ── */
.mu-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0;
}

.mu-thumb {
    position: relative;
    width: var(--mu-thumb-size);
    height: var(--mu-thumb-size);
    border-radius: var(--mu-border-radius-sm);
    overflow: hidden;
    border: 2px solid var(--mu-gray-200);
    background: var(--mu-gray-100);
    flex-shrink: 0;
    transition: border-color var(--mu-transition), box-shadow var(--mu-transition);
    animation: mu-thumb-appear 200ms ease;
}

@keyframes mu-thumb-appear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.mu-thumb:hover {
    border-color: var(--mu-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

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

.mu-thumb-close {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--mu-transition), background var(--mu-transition);
    z-index: 2;
}

.mu-thumb:hover .mu-thumb-close {
    opacity: 1;
}

.mu-thumb-close:hover {
    background: var(--mu-danger);
}

/* Thumbnail overlay states */
.mu-thumb-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.mu-thumb-overlay--uploading {
    background: rgba(0, 0, 0, 0.4);
}

.mu-thumb-overlay--done {
    background: rgba(22, 163, 74, 0.5);
    animation: mu-overlay-flash 600ms ease;
}

.mu-thumb-overlay--error {
    background: rgba(220, 38, 38, 0.5);
}

@keyframes mu-overlay-flash {
    0% { background: rgba(22, 163, 74, 0.8); }
    100% { background: rgba(22, 163, 74, 0.5); }
}

.mu-thumb-progress-ring {
    width: 28px;
    height: 28px;
}

.mu-thumb-progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.mu-thumb-progress-ring circle:last-child {
    transition: stroke-dasharray 200ms ease;
}

/* ── Progress Bar ── */
.mu-progress {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--mu-gray-50);
    border-radius: var(--mu-border-radius-sm);
    border: 1px solid var(--mu-gray-200);
}

.mu-progress-bar {
    height: 0.5rem;
    background: var(--mu-gray-200);
    border-radius: 9999px;
    overflow: hidden;
}

.mu-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--mu-primary), #7c3aed);
    border-radius: 9999px;
    transition: width 200ms ease;
    width: 0;
}

.mu-progress-text {
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--mu-gray-500);
    font-variant-numeric: tabular-nums;
}

/* ── Queue ── */
.mu-queue {
    margin-top: 0.75rem;
}

.mu-queue-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: white;
    border: 1px solid var(--mu-gray-200);
    border-radius: var(--mu-border-radius-sm);
    margin-bottom: 0.375rem;
    transition: background var(--mu-transition), border-color var(--mu-transition);
    animation: mu-queue-slide-in 200ms ease;
}

@keyframes mu-queue-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.mu-queue-item:hover {
    background: var(--mu-gray-50);
    border-color: var(--mu-gray-300);
}

.mu-queue-item--completed { border-left: 3px solid var(--mu-success); }
.mu-queue-item--failed { border-left: 3px solid var(--mu-danger); background: var(--mu-danger-light); }
.mu-queue-item--uploading { border-left: 3px solid var(--mu-primary); background: var(--mu-primary-light); }
.mu-queue-item--cancelled { opacity: 0.5; }

.mu-file-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

.mu-status-icon {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    font-weight: bold;
}

.mu-status-ok { color: var(--mu-success); }
.mu-status-error { color: var(--mu-danger); }
.mu-status-uploading { color: var(--mu-primary); animation: mu-spin 1s linear infinite; }
.mu-status-cancelled { color: var(--mu-gray-400); }
.mu-status-pending { color: var(--mu-gray-400); }

@keyframes mu-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mu-queue-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mu-queue-size {
    flex-shrink: 0;
    color: var(--mu-gray-500);
    font-size: 0.8125rem;
}

.mu-queue-progress {
    flex: 0 0 100px;
    height: 0.375rem;
    background: rgba(79, 70, 229, 0.2);
    border-radius: 9999px;
    overflow: hidden;
}

.mu-queue-progress-fill {
    height: 100%;
    background: var(--mu-primary);
    border-radius: 9999px;
    transition: width 200ms ease;
}

.mu-queue-percent {
    flex-shrink: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--mu-primary);
    min-width: 2.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mu-queue-error {
    flex-shrink: 0;
    color: var(--mu-danger);
    font-size: 0.8125rem;
}

.mu-queue-cancel,
.mu-queue-remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--mu-gray-400);
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--mu-transition), color var(--mu-transition);
}

.mu-queue-cancel:hover { background: var(--mu-danger-light); color: var(--mu-danger); }
.mu-queue-remove:hover { background: var(--mu-gray-100); color: var(--mu-gray-600); }

/* ── Attachments ── */
.mu-attachments {
    border: 1px solid var(--mu-gray-200);
    border-radius: var(--mu-border-radius);
    overflow: hidden;
}

.mu-attachments-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--mu-gray-50);
    border-bottom: 1px solid var(--mu-gray-200);
}

.mu-attachments-count {
    color: var(--mu-gray-500);
    font-size: 0.8125rem;
}

.mu-attachments-list { padding: 0; }

.mu-attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--mu-gray-100);
    transition: background var(--mu-transition);
}

.mu-attachment-item:last-child { border-bottom: none; }
.mu-attachment-item:hover { background: var(--mu-gray-50); }

.mu-attachment-icon { flex-shrink: 0; font-size: 1rem; }

.mu-attachment-thumb {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--mu-gray-200);
}

.mu-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mu-attachment-size {
    flex-shrink: 0;
    color: var(--mu-gray-500);
    font-size: 0.8125rem;
}

.mu-attachment-progress {
    flex-shrink: 0;
    color: var(--mu-primary);
    font-weight: 600;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.mu-attachment-remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--mu-gray-400);
    cursor: pointer;
    transition: background var(--mu-transition), color var(--mu-transition);
}

.mu-attachment-remove:hover {
    background: var(--mu-danger-light);
    color: var(--mu-danger);
}

/* ── Paused / Processing / Disabled States ── */
.mu-queue-item--paused { border-left: 3px solid var(--mu-warning); background: rgba(217, 119, 6, 0.05); }
.mu-queue-item--processing { border-left: 3px solid var(--mu-primary); background: var(--mu-primary-light); }
.mu-status-paused { color: var(--mu-warning); }
.mu-status-processing { color: var(--mu-primary); animation: mu-pulse 1.5s ease infinite; }

@keyframes mu-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.mu-disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.mu-queue-retry,
.mu-queue-pause,
.mu-queue-resume {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--mu-gray-400);
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--mu-transition), color var(--mu-transition);
}

.mu-queue-retry:hover { background: var(--mu-primary-light); color: var(--mu-primary); }
.mu-queue-pause:hover { background: rgba(217, 119, 6, 0.1); color: var(--mu-warning); }
.mu-queue-resume:hover { background: var(--mu-success-light); color: var(--mu-success); }

/* ── Thumbnail paused overlay ── */
.mu-thumb-overlay--paused {
    background: rgba(217, 119, 6, 0.5);
}

/* ── Toast Notifications ── */
.mu-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 360px;
}

.mu-toast {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: var(--mu-border-radius);
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
    font-family: var(--mu-font-family);
    font-size: var(--mu-font-size);
    color: var(--mu-gray-800);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 300ms ease, transform 300ms ease;
    border-left: 4px solid var(--mu-gray-300);
}

.mu-toast--visible {
    opacity: 1;
    transform: translateX(0);
}

.mu-toast--leaving {
    opacity: 0;
    transform: translateX(100%);
}

.mu-toast--success { border-left-color: var(--mu-success); }
.mu-toast--error { border-left-color: var(--mu-danger); }
.mu-toast--warning { border-left-color: var(--mu-warning); }
.mu-toast--info { border-left-color: var(--mu-primary); }

.mu-toast-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.mu-toast--success .mu-toast-icon { color: var(--mu-success); }
.mu-toast--error .mu-toast-icon { color: var(--mu-danger); }
.mu-toast--warning .mu-toast-icon { color: var(--mu-warning); }
.mu-toast--info .mu-toast-icon { color: var(--mu-primary); }

.mu-toast-message {
    flex: 1;
    line-height: 1.4;
}

.mu-toast-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--mu-gray-400);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 9999px;
    transition: background var(--mu-transition), color var(--mu-transition);
}

.mu-toast-close:hover {
    background: var(--mu-gray-100);
    color: var(--mu-gray-600);
}

/* ── Lightbox ── */
.mu-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100001;
    align-items: center;
    justify-content: center;
}

.mu-lightbox--visible {
    display: flex;
}

.mu-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    animation: mu-fade-in 200ms ease;
}

@keyframes mu-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mu-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: mu-lightbox-zoom 200ms ease;
}

@keyframes mu-lightbox-zoom {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.mu-lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--mu-border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.mu-lightbox-caption {
    margin-top: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--mu-font-family);
    font-size: var(--mu-font-size);
    text-align: center;
}

.mu-lightbox-close {
    position: absolute;
    top: -2rem;
    right: -1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.25rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background var(--mu-transition);
}

.mu-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Confirm Dialog ── */
.mu-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    animation: mu-fade-in 150ms ease;
}

.mu-confirm-dialog {
    background: white;
    border-radius: var(--mu-border-radius);
    padding: 1.5rem;
    min-width: 300px;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    font-family: var(--mu-font-family);
    animation: mu-lightbox-zoom 150ms ease;
}

.mu-confirm-message {
    margin: 0 0 1.25rem 0;
    font-size: 0.9375rem;
    color: var(--mu-gray-800);
    line-height: 1.5;
}

.mu-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.mu-confirm-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--mu-gray-300);
    border-radius: var(--mu-border-radius-sm);
    font-size: var(--mu-font-size);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--mu-transition), border-color var(--mu-transition);
}

.mu-confirm-btn--cancel {
    background: white;
    color: var(--mu-gray-600);
}

.mu-confirm-btn--cancel:hover {
    background: var(--mu-gray-50);
    border-color: var(--mu-gray-400);
}

.mu-confirm-btn--ok {
    background: var(--mu-primary);
    color: white;
    border-color: var(--mu-primary);
}

.mu-confirm-btn--ok:hover {
    background: var(--mu-primary-hover);
    border-color: var(--mu-primary-hover);
}

/* ── Full Page Drop Overlay ── */
.mu-fullpage-drop-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(79, 70, 229, 0.08);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
}

.mu-fullpage-drop-overlay--visible {
    display: flex;
}

.mu-fullpage-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 4rem;
    background: white;
    border: 3px dashed var(--mu-primary);
    border-radius: 1rem;
    color: var(--mu-primary);
    font-family: var(--mu-font-family);
    font-size: 1.125rem;
    font-weight: 600;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    animation: mu-lightbox-zoom 200ms ease;
}

/* ── Attachment uploading state ── */
.mu-attachment-item--uploading {
    background: var(--mu-primary-light);
}

/* ── Dark Mode ── */
.mu-dark,
.mu-uploader.mu-dark,
.mu-dropzone-standalone.mu-dark,
.mu-attachments.mu-dark {
    --mu-gray-50: #1a1a2e;
    --mu-gray-100: #16213e;
    --mu-gray-200: #2a2a4a;
    --mu-gray-300: #3a3a5a;
    --mu-gray-400: #6a6a8a;
    --mu-gray-500: #9a9aba;
    --mu-gray-600: #c0c0d0;
    --mu-gray-700: #d0d0e0;
    --mu-gray-800: #e8e8f0;
    --mu-gray-900: #f5f5ff;
    --mu-primary-light: rgba(79, 70, 229, 0.15);
    --mu-success-light: rgba(22, 163, 74, 0.15);
    --mu-danger-light: rgba(220, 38, 38, 0.15);
}

.mu-dark .mu-queue-item,
.mu-dark .mu-thumb {
    background: var(--mu-gray-100);
}

.mu-dark .mu-toast {
    background: var(--mu-gray-100);
    color: var(--mu-gray-800);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.mu-dark .mu-confirm-dialog {
    background: var(--mu-gray-100);
    color: var(--mu-gray-800);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.mu-dark .mu-confirm-btn--cancel {
    background: var(--mu-gray-50);
    color: var(--mu-gray-600);
    border-color: var(--mu-gray-300);
}

.mu-dark .mu-fullpage-drop-content {
    background: var(--mu-gray-100);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .mu-queue-progress { display: none; }
    .mu-queue-item { flex-wrap: wrap; }
    .mu-thumb { --mu-thumb-size: 48px; }
}
