/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    padding: 20px;
    min-height: 100vh;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== 头部 ========== */
.header {
    background: white;
    padding: 24px 30px;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.header h1 {
    font-size: 28px;
    color: #1a2332;
}

.header p {
    color: #6b7a8f;
    margin-top: 6px;
}

/* ========== 上传区域 ========== */
.upload-section {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.upload-area {
    border: 3px dashed #d0d7de;
    padding: 50px 20px;
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    background: #fafbfc;
    transition: all 0.3s;
}

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

.upload-area.dragover {
    border-color: #3b82f6;
    background: #e8f0fe;
    transform: scale(1.01);
}

.upload-area .upload-icon {
    font-size: 56px;
    display: block;
    margin-bottom: 12px;
}

.upload-area h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a2332;
}

.upload-area .upload-hint {
    color: #6b7a8f;
    font-size: 14px;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
    pointer-events: none;
}

/* ========== 加载状态 ========== */
.loading {
    text-align: center;
    padding: 30px;
    display: none;
}

.loading .spinner {
    display: inline-block;
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    margin-top: 16px;
    color: #6b7a8f;
}

/* ========== 调试信息 ========== */
.debug-info {
    background: #1a2332;
    color: #00ff41;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    max-height: 200px;
    overflow-y: auto;
}

.debug-info strong {
    color: #fff;
    display: block;
    margin-bottom: 4px;
}

.debug-info #debugContent {
    white-space: pre-wrap;
    line-height: 1.6;
}

/* ========== 文件信息 ========== */
.file-info {
    background: #f8fafc;
    padding: 12px 20px;
    border-radius: 8px;
    margin-top: 16px;
    display: none;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #374151;
}

.file-info span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-info strong {
    color: #1a2332;
}

.btn-preview {
    background: #8b5cf6;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-preview:hover {
    background: #7c3aed;
}

.btn-reset {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.btn-reset:hover {
    background: #dc2626;
}

/* ========== 搜索框 ========== */
.search-box {
    margin-top: 16px;
    display: none;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.search-box input:focus {
    border-color: #3b82f6;
}

/* ========== 统计卡片 ========== */
.stats {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 5px solid #3b82f6;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #6b7a8f;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a2332;
    margin-top: 2px;
}

.stat-card.flashdriver {
    border-left-color: #22c55e;
}
.stat-card.app {
    border-left-color: #3b82f6;
}
.stat-card.cal {
    border-left-color: #f59e0b;
}
.stat-card.other {
    border-left-color: #f59e0b;
}
.stat-card.invalid {
    border-left-color: #ef4444;
}

/* ========== 文件列表 ========== */
.files-container {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.file-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 450px;
}

.file-panel.unclassified {
    border: 2px solid #f59e0b;
}

.file-panel.invalid-panel {
    border: 2px solid #ef4444;
}

.file-panel .panel-header {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.file-panel .panel-title {
    font-weight: 600;
    font-size: 14px;
    color: #1a2332;
}

.file-panel .badge {
    background: #e5e7eb;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.file-panel .badge.flashdriver {
    background: #dcfce7;
    color: #166534;
}
.file-panel .badge.app {
    background: #dbeafe;
    color: #1e40af;
}
.file-panel .badge.cal {
    background: #fef3c7;
    color: #92400e;
}
.file-panel .badge.other {
    background: #fef3c7;
    color: #92400e;
}
.file-panel .badge.invalid {
    background: #fecaca;
    color: #991b1b;
}

.file-list {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.file-item {
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid transparent;
    margin-bottom: 2px;
}

.file-item:hover {
    background: #f8fafc;
}

.file-item .file-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.file-item .file-name {
    flex: 1;
    font-size: 13px;
    color: #1f2937;
    word-break: break-all;
}

.file-item .file-size {
    font-size: 11px;
    color: #6b7a8f;
    flex-shrink: 0;
}

.file-item .file-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.file-tag.flashdriver {
    background: #dcfce7;
    color: #166534;
}
.file-tag.app {
    background: #dbeafe;
    color: #1e40af;
}
.file-tag.cal {
    background: #fef3c7;
    color: #92400e;
}
.file-tag.other {
    background: #fef3c7;
    color: #92400e;
}
.file-tag.invalid {
    background: #fecaca;
    color: #991b1b;
}

.file-item.flashdriver {
    border-left-color: #22c55e;
}
.file-item.app {
    border-left-color: #3b82f6;
}
.file-item.cal {
    border-left-color: #f59e0b;
}
.file-item.other {
    border-left-color: #f59e0b;
}
.file-item.invalid {
    border-left-color: #ef4444;
    opacity: 0.7;
}

.file-item .classify-btn {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
}

.file-item .classify-btn:hover {
    background: #d97706;
}

.file-valid.valid {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #dcfce7;
    color: #166534;
    flex-shrink: 0;
}

.file-valid.invalid {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fecaca;
    color: #991b1b;
    flex-shrink: 0;
}

.file-empty {
    padding: 30px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* ========== 打包预览 ========== */
.preview-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 2px solid #3b82f6;
}

.preview-header {
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    font-size: 16px;
    color: #1a2332;
}

.preview-header .preview-count {
    background: #3b82f6;
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.preview-list {
    padding: 12px 16px;
    max-height: 400px;
    overflow-y: auto;
}

.preview-list::-webkit-scrollbar {
    width: 6px;
}

.preview-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.preview-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.preview-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    gap: 12px;
}

.preview-item:last-child {
    border-bottom: none;
}

.preview-item .preview-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.preview-item .preview-name {
    flex: 1;
    font-size: 14px;
    color: #1f2937;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.preview-item .preview-size {
    font-size: 12px;
    color: #6b7a8f;
    flex-shrink: 0;
}

.preview-item .preview-status {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.preview-status.valid {
    background: #dcfce7;
    color: #166534;
}

.preview-status.invalid {
    background: #fecaca;
    color: #991b1b;
}

.preview-status.classified {
    background: #dbeafe;
    color: #1e40af;
}

.preview-actions {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 2px solid #e5e7eb;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-confirm-download {
    background: #22c55e;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-confirm-download:hover {
    background: #16a34a;
}

.btn-cancel-preview {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-cancel-preview:hover {
    background: #dc2626;
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.modal-header h3 {
    font-size: 18px;
    color: #1a2332;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6b7a8f;
    line-height: 1;
}

.modal-close:hover {
    color: #1a2332;
}

.modal-body {
    padding: 24px;
}

.modal-file-name {
    font-size: 15px;
    font-weight: 500;
    color: #1a2332;
    margin-bottom: 4px;
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    word-break: break-all;
    border: 1px solid #e5e7eb;
}

.modal-file-ext {
    font-size: 13px;
    color: #6b7a8f;
    margin: 8px 0 16px 0;
}

.type-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.type-option {
    padding: 14px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
}

.type-option:hover {
    border-color: #3b82f6;
    background: #f0f7ff;
    transform: translateX(4px);
}

.type-option.flashdriver:hover {
    border-color: #22c55e;
    background: #f0fdf4;
}

.type-option.app:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.type-option.cal:hover {
    border-color: #f59e0b;
    background: #fffbeb;
}

.type-option .option-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.type-option .option-label {
    flex: 1;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .files-container {
        grid-template-columns: 1fr;
    }

    .file-panel {
        max-height: 300px;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .file-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .preview-actions {
        flex-direction: column;
    }

    .preview-actions button {
        width: 100%;
        text-align: center;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .type-option {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 46px;
    }
}