/* 自定义样式 */

/* 主体样式 */
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 导航栏样式 */
.navbar-brand {
    font-weight: 600;
}

/* 卡片样式 */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

/* 文件上传区域 */
.file-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.file-upload-area:hover {
    border-color: #007bff;
    background-color: #f8f9ff;
}

.file-upload-area.dragover {
    border-color: #007bff;
    background-color: #e3f2fd;
}

/* 文件列表样式 */
.file-list-item {
    transition: all 0.2s ease;
}

.file-list-item:hover {
    background-color: #f8f9fa;
}

/* 进度条样式 */
.progress {
    height: 1rem;
    border-radius: 0.5rem;
}

.progress-bar {
    transition: width 0.6s ease;
}

/* 状态标记 */
.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* 按钮组 */
.btn-group-sm .btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

/* 表格样式 */
.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
    font-size: 0.875rem;
}

.table td {
    vertical-align: middle;
    font-size: 0.875rem;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

/* 模态框样式 */
.modal-header {
    border-bottom: 1px solid #e9ecef;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
}

/* 预览表格样式 */
.preview-table {
    font-size: 0.8rem;
}

.preview-table th,
.preview-table td {
    padding: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* 配置卡片样式 */
.file-config {
    transition: opacity 0.3s ease;
}

.file-config.disabled {
    opacity: 0.6;
}

/* 任务状态页面样式 */
.task-status-card {
    position: sticky;
    top: 20px;
}

/* 日志容器 */
.logs-container {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

/* 统计卡片 */
.stats-card {
    text-align: center;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.stats-card .stats-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stats-card .stats-label {
    color: #6c757d;
    font-size: 0.875rem;
    margin: 0;
}

/* 错误页面样式 */
.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    
    .table-responsive {
        border: none;
    }
    
    .preview-table th,
    .preview-table td {
        max-width: 100px;
        font-size: 0.7rem;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* 加载状态 */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* 自定义滚动条 */
.logs-container::-webkit-scrollbar {
    width: 6px;
}

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

.logs-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.logs-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 提示工具样式 */
.tooltip {
    font-size: 0.8rem;
}

/* 徽章样式 */
.badge {
    font-weight: 500;
}

/* 表单控件样式 */
.form-control:focus,
.form-select:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* 复选框和单选按钮样式 */
.form-check-input:checked {
    background-color: #007bff;
    border-color: #007bff;
}

/* 手风琴样式 */
.accordion-button:not(.collapsed) {
    background-color: #e7f1ff;
    color: #0c63e4;
}

.accordion-button:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* 分页样式 */
.pagination .page-link {
    color: #007bff;
}

.pagination .page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}

/* 拖拽文件样式 */
.drag-over {
    border-color: #007bff !important;
    background-color: rgba(0, 123, 255, 0.1) !important;
}

/* 结果页面样式 */
.result-card {
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left-color: #007bff;
}

.result-card.selected {
    border-left-color: #28a745;
    background-color: #f8fff8;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.file-size {
    font-size: 0.9em;
    color: #6c757d;
    font-weight: 500;
}

.file-date {
    font-size: 0.85em;
    color: #adb5bd;
}

.batch-actions {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #dee2e6;
    display: none;
    animation: slideDown 0.3s ease;
}

.batch-actions.show {
    display: block;
}

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

.data-preview-table {
    font-size: 0.85em;
    max-height: 400px;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.data-preview-table th {
    position: sticky;
    top: 0;
    background-color: #343a40 !important;
    z-index: 1;
}

.pivot-field {
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 4px;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    cursor: grab;
    display: inline-block;
    user-select: none;
    transition: all 0.2s ease;
    font-size: 0.9em;
    font-weight: 500;
}

.pivot-field:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #f1f3f4 100%);
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pivot-field:active {
    cursor: grabbing;
}

.pivot-field.dragging {
    opacity: 0.6;
    transform: rotate(5deg) scale(0.95);
}

.drop-zone {
    min-height: 80px;
    border: 2px dashed #ced4da;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    transition: all 0.3s ease;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.drop-zone.dragover {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.05);
    color: #007bff;
    transform: scale(1.02);
}

.drop-zone.has-fields {
    border-style: solid;
    background: #f8f9fa;
    text-align: left;
    justify-content: flex-start;
    align-items: flex-start;
}

.chart-container {
    min-height: 400px;
    position: relative;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e9ecef;
}

.field-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
}

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

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

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

.field-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.loading {
    text-align: center;
    padding: 60px 40px;
    color: #6c757d;
}

.loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

.no-results {
    text-align: center;
    padding: 80px 40px;
    color: #adb5bd;
}

.no-results i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #dee2e6;
}

.btn-group-sm > .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 4px;
}

.btn-group-sm > .btn:not(:last-child) {
    margin-right: 2px;
}

/* 模态框增强样式 */
.modal-xl {
    max-width: 95%;
}

.modal-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-bottom: none;
    border-radius: 0.5rem 0.5rem 0 0;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0 0 0.5rem 0.5rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .result-card .btn-group-sm {
        flex-direction: column;
    }
    
    .result-card .btn-group-sm > .btn {
        width: 100%;
        margin: 1px 0;
    }
    
    .batch-actions .row {
        text-align: center;
    }
    
    .batch-actions .col-md-4 {
        margin-bottom: 10px;
    }
    
    .batch-actions .col-md-4:last-child {
        margin-top: 10px;
    }
    
    .modal-xl {
        max-width: 98%;
        margin: 0.5rem;
    }
    
    .drop-zone {
        min-height: 60px;
        padding: 15px;
    }
    
    .pivot-field {
        margin: 2px;
        padding: 6px 10px;
        font-size: 0.85em;
    }
}

/* 透视表和图表优化样式 */
.alert-info {
    border-left: 4px solid #0dcaf0;
    background-color: #d1ecf1;
    border-color: #b8daff;
}

.table-primary th {
    background-color: #cce5ff !important;
    border-color: #b3d9ff !important;
    color: #004085 !important;
}

.table-primary th.fw-bold {
    font-weight: 600 !important;
}

/* 透视表专用样式 */
.pivot-table-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.pivot-table-scroll {
    max-height: 600px;
    overflow: auto;
}

.pivot-table {
    margin-bottom: 0;
    font-size: 0.85rem;
    table-layout: auto;
}

.pivot-table th.pivot-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%) !important;
    color: white !important;
    font-weight: 600 !important;
    border: 1px solid #0056b3 !important;
    padding: 8px 12px !important;
    font-size: 0.8rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pivot-header.row-header {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%) !important;
    min-width: 120px;
    max-width: 200px;
}

.pivot-header.column-group-header {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%) !important;
    text-align: center !important;
}

.pivot-header.value-header {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
    color: #212529 !important;
    min-width: 100px;
}

.pivot-header.value-subheader {
    background: linear-gradient(135deg, #fd7e14 0%, #e55a00 100%) !important;
    color: white !important;
    font-size: 0.75rem;
    min-width: 100px;
}

.pivot-header.row-header-spacer {
    background: transparent !important;
    border: none !important;
}

/* 可排序表头样式 */
.pivot-header.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
}

.pivot-header.sortable:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.1) 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pivot-header.sortable:active {
    transform: translateY(0);
}

.sort-icon {
    font-size: 0.7rem;
    margin-left: 4px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.sortable:hover .sort-icon {
    opacity: 1;
}

.sort-icon.active {
    opacity: 1;
    color: #ffc107 !important;
    filter: drop-shadow(0 0 2px rgba(255, 193, 7, 0.5));
}

/* 排序时的动画效果 */
.pivot-table tbody {
    transition: all 0.3s ease;
}

.pivot-cell {
    transition: background-color 0.2s ease;
}

/* 排序指示器 */
.pivot-header.sortable::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background-color 0.2s ease;
}

.pivot-header.sortable:hover::before {
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.5) 50%, transparent 100%);
}

/* 排序提示样式 */
.text-muted small {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* 增强排序状态的视觉反馈 */
.pivot-header.sortable[data-sorted="true"] {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2) 0%, rgba(255, 193, 7, 0.1) 100%) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 193, 7, 0.3);
}

/* 排序加载动画 */
@keyframes sortAnimation {
    0% { opacity: 0.5; transform: translateY(0); }
    50% { opacity: 0.8; transform: translateY(-1px); }
    100% { opacity: 1; transform: translateY(0); }
}

.pivot-table tbody.sorting {
    animation: sortAnimation 0.3s ease;
}

/* 表头工具提示增强 */
.pivot-header.sortable {
    position: relative;
}

.pivot-header.sortable:hover::after {
    content: '点击排序';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    animation: fadeInTooltip 0.2s ease forwards;
}

@keyframes fadeInTooltip {
    from { opacity: 0; transform: translateX(-50%) translateY(2px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.pivot-cell {
    padding: 6px 8px !important;
    border: 1px solid #dee2e6 !important;
    font-size: 0.8rem;
}

.pivot-cell.row-cell {
    background-color: #f8f9fa;
    font-weight: 500;
    border-left: 3px solid #28a745 !important;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pivot-cell.data-cell {
    min-width: 80px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 500;
}

.pivot-cell.high-value {
    background-color: #d1ecf1 !important;
    color: #0c5460 !important;
    font-weight: 600;
}

.pivot-cell.medium-value {
    background-color: #d4edda !important;
    color: #155724 !important;
}

.pivot-cell.low-value {
    background-color: #fff3cd !important;
    color: #856404 !important;
}

/* 数据统计卡片样式 */
.stat-item {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

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

.stat-label {
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: 500;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.2;
    word-break: break-all;
}

/* 紧凑的卡片设计 */
.card-header {
    border-radius: 8px 8px 0 0 !important;
}

.card-body {
    padding: 1rem !important;
}

/* 滚动条美化 */
.pivot-table-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.pivot-table-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.pivot-table-scroll::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.pivot-table-scroll::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.pivot-table-scroll::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

/* 紧凑的字段列表和拖放区域 */
.compact-field-list {
    max-height: 150px;
    padding: 8px;
    font-size: 0.8rem;
}

.compact-field-list .pivot-field {
    padding: 4px 8px;
    margin: 2px;
    font-size: 0.75rem;
}

.compact-drop-zone {
    min-height: 50px;
    padding: 8px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.compact-drop-zone.has-fields {
    padding: 4px;
}

.compact-drop-zone .pivot-field {
    padding: 4px 8px;
    margin: 2px;
    font-size: 0.75rem;
}

.compact-drop-zone .pivot-field button {
    font-size: 0.7rem;
    padding: 1px 4px;
    margin-left: 4px;
}

/* 透视表结果容器 */
.pivot-result-container {
    min-height: 400px;
    max-height: 600px;
    overflow: auto;
}

/* 模态框内的卡片优化 */
.modal-body .card {
    border: 1px solid #e9ecef;
    box-shadow: none;
}

.modal-body .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    font-size: 0.9rem;
}

.modal-body .card-body {
    background: #fff;
}

/* 字段配置区域的表单控件 */
.modal-body .form-label.small {
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.modal-body .form-select-sm {
    font-size: 0.8rem;
    padding: 4px 8px;
}

.modal-body .btn-sm {
    font-size: 0.8rem;
    padding: 6px 12px;
}

/* 批量操作按钮组优化 */
.batch-actions .btn-group-sm {
    gap: 5px;
}

.batch-actions .col-md-4 .btn {
    margin: 0 2px;
}