/**
 * 数据导入/导出功能样式
 * 支持亮色/暗色主题
 */

/* ===== 对话框覆盖层 ===== */
.import-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

body.light-theme .import-dialog-overlay {
    background: rgba(0, 0, 0, 0.5);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== 对话框容器 ===== */
.import-dialog-container {
    background: var(--panel-bg, white);
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.3));
    animation: slideIn 0.3s ease;
    color: var(--text-primary, #333);
}

body.light-theme .import-dialog-container {
    background: white;
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== 对话框头部 ===== */
.import-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid var(--panel-border, #e0e0e0);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.import-dialog-header h2 {
    margin: 0;
    font-size: 22px;
}

.import-dialog-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.import-dialog-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== 对话框主体 ===== */
.import-dialog-body {
    padding: 25px;
}

/* ===== 模式切换器 ===== */
.mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
    padding-bottom: 0;
}

.mode-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 15px;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    color: var(--text-secondary, #666);
    font-weight: 500;
}

.mode-btn:hover {
    color: #667eea;
}

.mode-btn.active {
    border-bottom-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

/* ===== 步骤指示器 ===== */
.import-step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
}

.import-step-indicator::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 50px;
    right: 50px;
    height: 2px;
    background: #e0e0e0;
    z-index: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--border-color, #e0e0e0);
    color: var(--text-tertiary, #999);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 8px;
    transition: all 0.3s;
}

.step-item.active .step-number {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.step-item.completed .step-number {
    background: #4caf50;
    color: white;
}

.step-label {
    font-size: 13px;
    color: var(--text-secondary, #666);
    text-align: center;
}

.step-item.active .step-label {
    color: #667eea;
    font-weight: 600;
}

/* ===== 表单样式 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 14px;
    background: var(--input-bg, white);
    color: var(--text-primary, #333);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== CSV字段说明 ===== */
.csv-field-guide {
    background: var(--input-bg, #f8f9fa);
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

body.light-theme .csv-field-guide {
    background: #f8f9fa;
}

.csv-field-guide.collapsed .guide-content {
    display: none;
}

.csv-field-guide.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.guide-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    user-select: none;
}

.guide-header:hover {
    background: linear-gradient(135deg, #5568d3 0%, #663d8f 100%);
}

.guide-icon {
    font-size: 20px;
    margin-right: 10px;
}

.guide-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

.toggle-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.guide-content {
    padding: 20px;
}

.field-section {
    margin-bottom: 25px;
}

.field-section:last-child {
    margin-bottom: 0;
}

.field-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #333);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.field-section.required h4 {
    color: #d32f2f;
    border-bottom-color: #d32f2f;
}

.field-section.recommended h4 {
    color: #f57c00;
    border-bottom-color: #f57c00;
}

.field-section.optional h4 {
    color: #1976d2;
    border-bottom-color: #1976d2;
}

.field-list {
    display: grid;
    gap: 10px;
}

.field-item {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 10px;
    background: var(--panel-bg, white);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s;
}

body.light-theme .field-item {
    background: white;
}

.field-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    transform: translateX(3px);
}

.field-name {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-weight: 600;
    color: #667eea;
    padding: 4px 8px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
    align-self: start;
}

.field-desc {
    color: var(--text-primary, #333);
    font-weight: 500;
    align-self: center;
}

.field-examples {
    grid-column: 1 / -1;
    color: var(--text-tertiary, #999);
    font-size: 12px;
    font-style: italic;
    padding-left: 8px;
    border-left: 2px solid var(--border-color, #ddd);
}

.field-notes {
    background: rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.field-notes p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: var(--text-primary, #333);
}

.field-notes ul {
    margin: 0;
    padding-left: 20px;
}

.field-notes li {
    margin: 5px 0;
    color: var(--text-secondary, #666);
    font-size: 13px;
}

.field-notes strong {
    color: #667eea;
    font-weight: 600;
}

/* ===== 上传区域 ===== */
.upload-area {
    border: 2px dashed var(--border-color, #ccc);
    padding: 50px 30px;
    text-align: center;
    border-radius: 12px;
    margin: 20px 0;
    background: var(--hover-bg, #fafafa);
    transition: all 0.3s;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.drag-over {
    border-color: #667eea;
    background: #e7f0ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.upload-area p {
    margin: 10px 0;
    color: var(--text-secondary, #666);
}

.upload-area .hint {
    font-size: 12px;
    color: var(--text-tertiary, #999);
}

/* ===== 进度条 ===== */
.upload-progress,
.import-progress {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar.large {
    height: 32px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary, #666);
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.stat-item {
    padding: 15px;
    background: var(--hover-bg, #f5f5f5);
    border-radius: 8px;
    text-align: center;
}

.stat-item.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.stat-item.warning {
    background: #fff9e6;
    color: #f57c00;
}

/* ===== 字段映射表 ===== */
.mapping-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    margin: 20px 0;
}

.mapping-table {
    width: 100%;
    border-collapse: collapse;
}

.mapping-table th,
.mapping-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    text-align: left;
}

.mapping-table th {
    background: var(--hover-bg, #f5f5f5);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mapping-table tr:hover {
    background: var(--hover-bg, #fafafa);
}

.mapping-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    font-size: 13px;
    background: var(--input-bg, white);
    color: var(--text-primary, #333);
}

.confidence-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.confidence-high {
    background: #e8f5e9;
    color: #2e7d32;
}

.confidence-medium {
    background: #fff9e6;
    color: #f57c00;
}

.confidence-low {
    background: #ffebee;
    color: #c62828;
}

.sample-value {
    font-family: monospace;
    color: var(--text-secondary, #666);
    font-size: 13px;
}

/* ===== 验证摘要 ===== */
.validation-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.summary-card {
    padding: 20px;
    border-radius: 10px;
    background: var(--hover-bg, #f5f5f5);
    text-align: center;
}

.summary-card.success {
    background: #e8f5e9;
    border: 2px solid #4caf50;
}

.summary-card.warning {
    background: #fff9e6;
    border: 2px solid #ff9800;
}

.summary-card.error {
    background: #ffebee;
    border: 2px solid #f44336;
}

.summary-label {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-bottom: 8px;
}

.summary-value {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary, #333);
}

.summary-hint {
    font-size: 11px;
    color: var(--text-tertiary, #999);
    margin-top: 5px;
}

/* ===== 测站报告 ===== */
.station-report {
    background: #f0f4ff;
    border: 1px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.station-report h4 {
    margin: 0 0 10px 0;
    color: var(--text-primary, #333);
}

.station-report .warning-title {
    color: #f57c00;
}

.station-report ul {
    margin: 10px 0;
    padding-left: 20px;
}

.station-report li {
    margin: 5px 0;
}

/* ===== 错误列表 ===== */
.error-list {
    background: #fff5f5;
    border: 1px solid #f44336;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

.error-list h4 {
    margin: 0 0 10px 0;
    color: #c62828;
}

.error-list ul {
    margin: 0;
    padding-left: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.error-list li {
    margin: 5px 0;
    font-size: 13px;
    color: var(--text-secondary, #666);
}

/* ===== 按钮 ===== */
.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 15px;
}

.btn-primary,
.btn-secondary {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--border-color, #e0e0e0);
    color: var(--text-secondary, #666);
}

.btn-secondary:hover {
    background: var(--hover-bg, #d0d0d0);
}

/* ===== 提示文本 ===== */
.hint {
    font-size: 13px;
    color: var(--text-tertiary, #999);
    margin: 10px 0;
}

/* ===== 手工表格占位符 ===== */
.manual-mode-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary, #999);
}

.manual-mode-placeholder h3 {
    color: var(--text-secondary, #666);
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .import-dialog-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .import-step-indicator {
        flex-direction: column;
        gap: 15px;
    }
    
    .import-step-indicator::before {
        display: none;
    }
    
    .step-item {
        flex-direction: row;
        gap: 15px;
    }
    
    .progress-stats {
        grid-template-columns: 1fr;
    }
    
    .validation-summary {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
}

/* ========================================
   数据导出对话框样式
   ======================================== */

/* 导出对话框覆盖层 */
.export-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

body.light-theme .export-dialog-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* 导出对话框容器 */
.export-dialog {
    background: var(--panel-bg, white);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.3));
    animation: slideIn 0.3s ease;
    color: var(--text-primary, #333);
}

body.light-theme .export-dialog {
    background: white;
    color: #333;
}

/* 导出对话框头部 */
.export-dialog .dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid var(--panel-border, #e0e0e0);
    background: linear-gradient(135deg, #4CAF50 0%, #2196F3 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.export-dialog .dialog-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.export-dialog .dialog-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.export-dialog .dialog-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 导出对话框主体 */
.export-dialog .dialog-body {
    padding: 25px;
}

/* 表单组 */
.export-dialog .form-group {
    margin-bottom: 20px;
}

.export-dialog .form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary, #333);
}

.export-dialog .form-select,
.export-dialog .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 14px;
    background: var(--input-bg, white);
    color: var(--text-primary, #333);
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.export-dialog .form-select:focus,
.export-dialog .form-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* 快捷时间按钮 */
.export-dialog .quick-time-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.export-dialog .quick-time-btn {
    padding: 8px 16px;
    border: 1.5px solid var(--border-color, #ddd);
    background: var(--input-bg, white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary, #333);
    transition: all 0.2s;
}

.export-dialog .quick-time-btn:hover {
    background: var(--hover-bg, #f5f5f5);
    border-color: #4CAF50;
}

/* 信息提示区域 */
.export-dialog .info-section {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

/* 对话框底部按钮 */
.export-dialog .dialog-footer {
    padding: 15px 25px;
    border-top: 2px solid var(--border-color, #e0e0e0);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.export-dialog .btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.export-dialog .btn-cancel {
    background: var(--border-color, #e0e0e0);
    color: var(--text-secondary, #666);
}

.export-dialog .btn-cancel:hover {
    background: var(--hover-bg, #d0d0d0);
}

.export-dialog .btn-confirm {
    background: linear-gradient(135deg, #4CAF50 0%, #2196F3 100%);
    color: white;
}

.export-dialog .btn-confirm:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transform: translateY(-1px);
}

/* ========================================
   导出进度对话框样式
   ======================================== */

/* 进度对话框覆盖层 */
.export-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease;
}

body.light-theme .export-progress-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* 进度对话框容器 */
.export-progress-overlay .export-dialog {
    background: var(--panel-bg, white);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.4));
}

body.light-theme .export-progress-overlay .export-dialog {
    background: white;
}

/* 进度条容器 */
.progress-bar-container {
    width: 100%;
    height: 24px;
    background: var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

body.light-theme .progress-bar-container {
    background: #e0e0e0;
}

/* 进度条填充 */
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50 0%, #2196F3 100%);
    border-radius: 12px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* 进度条动画效果 */
.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}
