/* ==================== Excel风格表格增强 ==================== */

/* 表格容器 - 支持横向滚动 */
.table-enhanced-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

/* 增强型数据表格 */
.table-enhanced {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    min-width: 800px;
}

/* 表头单元格 */
.table-enhanced thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    padding: 8px 12px;
    border-bottom: 2px solid #dee2e6;
    text-align: left;
    font-size: 13px;
    position: relative;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 40px;
    vertical-align: middle;
}

/* 可排序的表头 */
.table-enhanced thead th.sortable {
    cursor: pointer;
    padding-right: 24px;
}

.table-enhanced thead th.sortable:hover {
    background-color: #e9ecef;
}

/* 排序指示器 */
.table-enhanced thead th .sort-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #6c757d;
}

.table-enhanced thead th.sort-asc .sort-indicator::after {
    content: "▲";
    color: #2196F3;
}

.table-enhanced thead th.sort-desc .sort-indicator::after {
    content: "▼";
    color: #2196F3;
}

/* 筛选按钮 */
.table-enhanced thead th .filter-btn {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    color: #6c757d;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.table-enhanced thead th .filter-btn:hover {
    background-color: #dee2e6;
    color: #212529;
}

.table-enhanced thead th .filter-btn.active {
    color: #2196F3;
    background-color: #e3f2fd;
}

/* 列宽调整手柄 */
.table-enhanced thead th .resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 10;
}

.table-enhanced thead th .resize-handle:hover,
.table-enhanced thead th .resize-handle.resizing {
    background-color: #2196F3;
}

/* 表头行 - 显示筛选行 */
.table-enhanced thead tr.filter-row th {
    padding: 4px 8px;
    border-bottom: 1px solid #dee2e6;
    background-color: #fafafa;
}

.table-enhanced thead tr.filter-row input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 12px;
    height: 28px;
}

.table-enhanced thead tr.filter-row input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

/* 表格主体 */
.table-enhanced tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #dee2e6;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.table-enhanced tbody tr:last-child td {
    border-bottom: none;
}

/* 筛选下拉面板 */
.filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    max-height: 350px;
    overflow-y: auto;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    padding: 8px;
    display: none;
}

.filter-dropdown.show {
    display: block;
}

.filter-dropdown .filter-search {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 12px;
}

.filter-dropdown .filter-options {
    max-height: 250px;
    overflow-y: auto;
}

.filter-dropdown .filter-option {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
}

.filter-dropdown .filter-option:hover {
    background-color: #f8f9fa;
}

.filter-dropdown .filter-option input[type="checkbox"] {
    margin-right: 8px;
}

.filter-dropdown .filter-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #dee2e6;
}

.filter-dropdown .filter-actions button {
    padding: 4px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 12px;
}

.filter-dropdown .filter-actions button:hover {
    background-color: #f8f9fa;
}

.filter-dropdown .filter-actions button.btn-primary {
    background-color: #2196F3;
    color: white;
    border-color: #2196F3;
}

.filter-dropdown .filter-count {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
    padding: 0 8px;
}

/* 表格工具栏 */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.table-toolbar .toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-toolbar .toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-toolbar .search-box {
    position: relative;
}

.table-toolbar .search-box input {
    padding: 6px 12px 6px 32px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 13px;
    width: 250px;
}

.table-toolbar .search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* 表格信息栏 */
.table-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
    color: #6c757d;
}

/* 已筛选指示器 */
.filter-active-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background-color: #e3f2fd;
    color: #1976D2;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 8px;
}

.filter-active-indicator i {
    margin-right: 4px;
}

/* 列宽调整时的视觉反馈 */
.table-enhanced.resizing {
    cursor: col-resize;
    user-select: none;
}

.table-enhanced.resizing * {
    cursor: col-resize !important;
}
