.file-uploader {
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========== 上傳區塊 ========== */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.upload-area.drag-over {
    border-color: #3b82f6;
    background: #dbeafe;
    transform: scale(1.02);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon {
    color: #9ca3af;
    margin-bottom: 8px;
}

.upload-text {
    color: #6b7280;
    margin: 0;
    font-size: 14px;
}

.btn-browse {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-browse:hover {
    background: #2563eb;
}

.btn-browse:active {
    background: #1d4ed8;
}

/* ========== 檔案列表 ========== */
.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .file-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }
}

/* ========== 檔案項目 ========== */
.file-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.file-item:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.file-item.dragging {
    opacity: 0.5;
    cursor: move;
}

.file-item[data-status="uploading"] {
    opacity: 0.7;
}

.file-item[data-status="error"] {
    border-color: #fecaca;
    background: #fef2f2;
}

/* ========== 檔案預覽 ========== */
.file-preview {
    position: relative;
    width: 100%;
    height: 150px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #9ca3af;
}

.file-icon svg {
    width: 48px;
    height: 48px;
}

/* ========== 上傳進度 ========== */
.upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    transition: width 0.3s ease;
    animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

/* ========== 上傳錯誤 ========== */
.upload-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.upload-error svg {
    display: block;
}

/* ========== 檔案信息 ========== */
.file-info {
    padding: 12px;
    flex: 1;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.file-size {
    font-size: 12px;
    color: #6b7280;
}

/* ========== 檔案的操作 ========== */
.file-actions {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.btn-action {
    flex: 1;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.btn-action:hover {
    background: #e5e7eb;
    color: #111827;
}

.btn-action:active {
    transform: scale(0.95);
}

.btn-action svg {
    width: 16px;
    height: 16px;
}

.btn-delete:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

.btn-download:hover {
    background: #dbeafe !important;
    color: #2563eb !important;
}

.btn-drag {
    cursor: grab;
}

.btn-drag:active {
    cursor: grabbing;
}

.file-list:empty::before {
    content: '';
    display: none;
}

@media (max-width: 640px) {
    .upload-area {
        padding: 30px 15px;
    }

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

    .upload-text {
        font-size: 13px;
    }

    .btn-browse {
        padding: 8px 20px;
        font-size: 13px;
    }

    .file-preview {
        height: 120px;
    }

    .file-name {
        font-size: 12px;
    }

    .file-size {
        font-size: 11px;
    }

    .file-info {
        padding: 10px;
        min-height: 50px;
    }

    .file-actions {
        padding: 6px;
    }

    .btn-action {
        padding: 6px;
    }
}

/* ========== 其他 ========== */
.file-uploader :focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.file-input:focus + .upload-area {
    border-color: #3b82f6;
}

.file-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 上傳loading的狀態 ========== */
.file-item[data-status="uploading"] .file-preview::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ========== Inline 模式樣式 ========== */
.file-uploader-inline {
    width: 100%;
}

.inline-upload-container {
    display: flex;
    align-items: center;
    /* gap: 12px; */
}

.btn-inline-upload svg {
    flex-shrink: 0;
}

.inline-file-preview {
    flex: 1;
    display: flex;
    /* gap: 8px; */
    align-items: center;
}

.inline-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    transition: all 0.2s;
    animation: fadeInLeft 0.3s ease-out;
}

.inline-file-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.inline-file-item[data-status="uploading"] {
    opacity: 0.7;
}

.inline-file-item[data-status="error"] {
    border-color: #fca5a5;
    background: #fef2f2;
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Inline 預覽的圖 */
.inline-preview {
    position: relative;
    width: 50px;
    height: 50px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inline-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inline-file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.inline-file-icon svg {
    width: 30px;
    height: 30px;
}

/* Inline 上傳中的狀態 */
.inline-uploading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Inline 錯誤狀態 */
.inline-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(254, 242, 242, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Inline 操作按鈕 */
.inline-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.btn-inline-action {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.btn-inline-action:hover {
    background: #f3f4f6;
    color: #111827;
}

.btn-inline-action:active {
    transform: scale(0.95);
}

.btn-inline-action svg {
    width: 16px;
    height: 16px;
}

.btn-inline-delete:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

.btn-inline-view:hover {
    background: #dbeafe !important;
    color: #2563eb !important;
}

@media (max-width: 640px) {
    .btn-inline-upload {
        padding: 5px 10px;
        font-size: 12px;
    }

    .btn-inline-upload span {
        display: none;
    }

    .inline-preview {
        width: 40px;
        height: 40px;
    }

    .btn-inline-action {
        padding: 5px;
    }
}
