/* ========== Reset & Base ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ========== Header ========== */
.header {
    text-align: center;
    padding: 24px 0 20px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a2e;
}

.subtitle {
    color: #888;
    font-size: 14px;
    margin-top: 6px;
}

/* ========== Folder Section ========== */
.folder-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.form-group {
    margin-bottom: 14px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.form-group select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid #d9d9d9;
    border-radius: 8px;
    font-size: 15px;
    color: #333;
    background: #fafafa;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select:focus {
    outline: none;
    border-color: #4f6ef7;
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
    background-color: #fff;
}

.form-group select:disabled {
    background: #f5f5f5;
    color: #bbb;
    cursor: not-allowed;
}

/* ========== Upload Section ========== */
.upload-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Select Area */
.select-area {
    text-align: center;
    padding: 30px 20px;
    border: 2px dashed #d9d9d9;
    border-radius: 10px;
    transition: border-color 0.2s, background 0.2s;
}

.select-area:hover {
    border-color: #4f6ef7;
    background: #f8f9ff;
}

.select-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.select-area p {
    color: #666;
    font-size: 14px;
}

.select-area .hint {
    color: #aaa;
    font-size: 12px;
    margin-top: 4px;
}

/* ========== Buttons ========== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #4f6ef7;
    color: #fff;
}

.btn-primary:hover {
    background: #3d5ce0;
}

.btn-primary:disabled {
    background: #b0bfee;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f0f2f5;
    color: #555;
    margin-top: 12px;
}

.btn-secondary:hover {
    background: #e4e6eb;
}

.btn-danger {
    background: #ff4d4f;
    color: #fff;
    padding: 4px 12px;
    font-size: 12px;
}

.btn-danger:hover {
    background: #e63e40;
}

.btn-small {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 16px;
}

/* ========== Preview Section ========== */
.preview-section {
    margin-top: 20px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: #555;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eee;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.preview-item:hover .remove-btn {
    opacity: 1;
}

.preview-item .file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 10px;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== Progress Section ========== */
.progress-section {
    margin-top: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
}

.progress-percent {
    font-weight: 600;
    color: #4f6ef7;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4f6ef7, #7c8cf8);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.file-progress-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.file-progress-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fafafa;
    border-radius: 8px;
    font-size: 13px;
}

.file-progress-item .status-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.file-progress-item .file-info {
    flex: 1;
    min-width: 0;
}

.file-progress-item .file-info .name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.file-progress-item .file-info .detail {
    font-size: 11px;
    color: #999;
}

.file-progress-item .mini-progress {
    width: 60px;
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.file-progress-item .mini-progress .mini-fill {
    height: 100%;
    background: #4f6ef7;
    border-radius: 2px;
    transition: width 0.2s;
}

.file-progress-item.status-success .status-icon {
    color: #52c41a;
}

.file-progress-item.status-failed .status-icon {
    color: #ff4d4f;
}

.file-progress-item.status-failed {
    background: #fff2f0;
}

/* ========== Result Section ========== */
.result-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.result-header {
    margin-bottom: 16px;
}

.result-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.result-summary {
    font-size: 14px;
    color: #888;
}

.result-summary .success-count {
    color: #52c41a;
    font-weight: 600;
}

.result-summary .fail-count {
    color: #ff4d4f;
    font-weight: 600;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.result-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
}

.result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-item.success {
    border-color: #52c41a;
}

.result-item.failed {
    border-color: #ff4d4f;
}

.result-item .result-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 10px;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-item .result-status {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 14px;
}

/* ========== Responsive ========== */
@media (max-width: 480px) {
    .container {
        padding: 12px 10px 30px;
    }

    .header h1 {
        font-size: 20px;
    }

    .folder-section,
    .upload-section,
    .result-section {
        padding: 14px;
        border-radius: 10px;
    }

    .select-area {
        padding: 20px 14px;
    }

    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 8px;
    }

    .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .btn-large {
        padding: 12px;
        font-size: 15px;
    }

    /* 移动端始终显示删除按钮 */
    .preview-item .remove-btn {
        opacity: 1;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

/* ========== Scrollbar ========== */
.preview-grid::-webkit-scrollbar,
.file-progress-list::-webkit-scrollbar,
.result-grid::-webkit-scrollbar {
    width: 4px;
}

.preview-grid::-webkit-scrollbar-thumb,
.file-progress-list::-webkit-scrollbar-thumb,
.result-grid::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* ========== Loading animation ========== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.uploading {
    animation: pulse 1.5s ease-in-out infinite;
}
