/**
 * 表格增强样式
 * 响应式、美观的表格样式
 */

/* 表格响应式包装器 */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 20px auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e8e8e8;
    border-radius: 0;
}

/* 滚动指示器 */
.table-responsive-wrapper.has-scroll.scroll-start::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.05));
    pointer-events: none;
    z-index: 1;
}

.table-responsive-wrapper.has-scroll.scroll-end::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, transparent, rgba(0, 0, 0, 0.05));
    pointer-events: none;
    z-index: 1;
}

/* 基础表格样式 */
.wznrys table.enhanced-table,
table.tablepress.enhanced-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    margin: 0 auto;
    font-size: 15px;
    line-height: 1.7;
    min-width: 100%; /* 确保表格能够撑满容器 */
    white-space: nowrap; /* 防止文字换行，触发横向滚动 */
}

/* 表头样式 */
.wznrys table.enhanced-table thead,
table.tablepress.enhanced-table thead {
    background: transparent !important;
    color: inherit !important;
}

.wznrys table.enhanced-table thead th,
table.tablepress.enhanced-table thead th {
    padding: 16px 20px !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    text-align: center !important;
    vertical-align: middle !important;
    border: none !important;
    border-right: 1px solid #e8e8e8 !important;
    border-bottom: 2px solid #e8e8e8 !important;
    position: relative;
    white-space: nowrap;
    transition: background-color 0.3s ease;
    background: transparent !important;
}

.wznrys table.enhanced-table thead th:last-child,
table.tablepress.enhanced-table thead th:last-child {
    border-right: none !important;
}

/* 排序图标（已禁用） */
/*
.wznrys table.enhanced-table thead th.sortable {
    padding-right: 30px;
}

.wznrys table.enhanced-table thead th .sort-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    opacity: 0.5;
}

.wznrys table.enhanced-table thead th .sort-icon::before,
.wznrys table.enhanced-table thead th .sort-icon::after {
    content: '';
    position: absolute;
    right: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.wznrys table.enhanced-table thead th .sort-icon::before {
    top: -8px;
    border-bottom: 5px solid currentColor;
}

.wznrys table.enhanced-table thead th .sort-icon::after {
    top: 2px;
    border-top: 5px solid currentColor;
}

.wznrys table.enhanced-table thead th.sort-asc .sort-icon::before {
    opacity: 1;
    border-bottom-color: #ffd700;
}

.wznrys table.enhanced-table thead th.sort-desc .sort-icon::after {
    opacity: 1;
    border-top-color: #ffd700;
}
*/

/* 表格主体样式 */
.wznrys table.enhanced-table tbody tr,
table.tablepress.enhanced-table tbody tr {
    border-bottom: 1px solid #e8e8e8 !important;
    transition: background-color 0.2s ease;
}

.wznrys table.enhanced-table tbody tr:hover,
table.tablepress.enhanced-table tbody tr:hover {
    background-color: #f8f9ff !important;
}

/* 斑马条纹（已禁用） */
/*
.wznrys table.enhanced-table tbody tr:nth-child(even),
table.tablepress.enhanced-table tbody tr.even,
table.tablepress.enhanced-table tbody tr:nth-child(even) {
    background-color: #fafafa !important;
}

.wznrys table.enhanced-table tbody tr:nth-child(even):hover,
table.tablepress.enhanced-table tbody tr.even:hover,
table.tablepress.enhanced-table tbody tr:nth-child(even):hover {
    background-color: #f8f9ff !important;
}
*/

.wznrys table.enhanced-table tbody td,
table.tablepress.enhanced-table tbody td {
    padding: 14px 20px !important;
    border: none !important;
    border-right: 1px solid #f0f0f0 !important;
    vertical-align: middle !important;
    text-align: center !important;
    font-size: 15px !important;
    white-space: nowrap; /* 防止文字换行 */
}

.wznrys table.enhanced-table tbody td:last-child,
table.tablepress.enhanced-table tbody td:last-child {
    border-right: none !important;
}

/* 第一列加粗 */
.wznrys table.enhanced-table tbody td:first-child,
table.tablepress.enhanced-table tbody td:first-child {
    font-weight: 600;
    color: #2c3e50;
}

/* 移动端响应式样式 */
@media screen and (max-width: 768px) {
    .table-responsive-wrapper {
        margin: 15px 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .wznrys table.enhanced-table,
    table.tablepress.enhanced-table {
        font-size: 14px !important;
        min-width: 600px; /* 确保触发横向滚动 */
        width: auto;
    }
    
    .wznrys table.enhanced-table thead th,
    table.tablepress.enhanced-table thead th {
        padding: 13px 15px !important;
        font-size: 15px !important;
    }
    
    .wznrys table.enhanced-table tbody td,
    table.tablepress.enhanced-table tbody td {
        padding: 12px 15px !important;
        font-size: 14px !important;
    }
    
    /* 滚动提示 */
    .table-responsive-wrapper.has-scroll::after {
        content: '← 左右滑动查看更多 →';
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(44, 62, 80, 0.9);
        color: #fff;
        text-align: center;
        padding: 8px;
        font-size: 13px;
        z-index: 2;
        animation: fadeInOut 3s ease-in-out infinite;
    }
    
    @keyframes fadeInOut {
        0%, 100% { opacity: 0.6; }
        50% { opacity: 1; }
    }
}

/* 超小屏幕（卡片式布局） */
@media screen and (max-width: 576px) {
    /* 可选：完全重构为卡片式布局 */
    .wznrys table.enhanced-table.card-mode {
        min-width: 100%;
        display: block;
    }
    
    .wznrys table.enhanced-table.card-mode thead {
        display: none;
    }
    
    .wznrys table.enhanced-table.card-mode tbody,
    .wznrys table.enhanced-table.card-mode tr {
        display: block;
        width: 100%;
    }
    
    .wznrys table.enhanced-table.card-mode tr {
        margin-bottom: 15px;
        border: 1px solid #e8e8e8;
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .wznrys table.enhanced-table.card-mode td {
        display: block;
        text-align: left;
        padding: 8px 0;
        border: none;
        position: relative;
        padding-left: 40%;
    }
    
    .wznrys table.enhanced-table.card-mode td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 38%;
        font-weight: 600;
        color: #2c3e50;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .wznrys table.enhanced-table.card-mode td:first-child {
        font-size: 16px;
        font-weight: 600;
        color: #2c3e50;
        border-bottom: 2px solid #e8e8e8;
        margin-bottom: 5px;
        padding-bottom: 8px;
    }
}

/* 打印样式 */
@media print {
    .table-responsive-wrapper {
        overflow: visible;
        box-shadow: none;
    }
    
    .wznrys table.enhanced-table {
        min-width: auto;
    }
    
    .wznrys table.enhanced-table thead th .sort-icon {
        display: none;
    }
    
    .wznrys table.enhanced-table tbody tr {
        page-break-inside: avoid;
    }
}

/* 加载动画 */
@keyframes tableLoad {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wznrys table.enhanced-table {
    animation: tableLoad 0.3s ease-out;
}

/* 深色模式支持（可选） */
@media (prefers-color-scheme: dark) {
    .wznrys table.enhanced-table,
    table.tablepress.enhanced-table {
        background: #1e1e1e !important;
        color: #e0e0e0 !important;
    }
    
    .wznrys table.enhanced-table thead,
    table.tablepress.enhanced-table thead {
        background: transparent !important;
        color: inherit !important;
    }
    
    .wznrys table.enhanced-table thead th,
    table.tablepress.enhanced-table thead th {
        border-right-color: #444 !important;
        border-bottom-color: #444 !important;
    }
    
    .wznrys table.enhanced-table tbody tr,
    table.tablepress.enhanced-table tbody tr {
        border-bottom-color: #333 !important;
    }
    
    .wznrys table.enhanced-table tbody td,
    table.tablepress.enhanced-table tbody td {
        border-right-color: #333 !important;
    }
    
    /* 深色模式斑马条纹（已禁用）
    .wznrys table.enhanced-table tbody tr:nth-child(even),
    table.tablepress.enhanced-table tbody tr.even,
    table.tablepress.enhanced-table tbody tr:nth-child(even) {
        background-color: #2a2a2a !important;
    }
    */
    
    .wznrys table.enhanced-table tbody tr:hover,
    table.tablepress.enhanced-table tbody tr:hover {
        background-color: #333 !important;
    }
}

/* ============================================
   TablePress 插件特定样式覆盖
   ============================================ */

/* 重置 TablePress 默认样式 */
.tablepress.enhanced-tablepress {
    border: 1px solid #e8e8e8 !important;
    border-radius: 0 !important;
    overflow: hidden;
}

/* 覆盖 TablePress 的表头样式 */
.tablepress.enhanced-tablepress thead th,
.tablepress.enhanced-tablepress thead td {
    background: transparent !important;
    color: inherit !important;
    border: none !important;
    border-right: 1px solid #e8e8e8 !important;
    border-bottom: 2px solid #e8e8e8 !important;
}

.tablepress.enhanced-tablepress thead th:last-child,
.tablepress.enhanced-tablepress thead td:last-child {
    border-right: none !important;
}

/* 覆盖 TablePress 的单元格边框 */
.tablepress.enhanced-tablepress tbody td {
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
}

/* 确保 TablePress 的行样式正确 */
.tablepress.enhanced-tablepress tbody tr.odd,
.tablepress.enhanced-tablepress tbody tr.even {
    background-color: #fff !important;
}

.tablepress.enhanced-tablepress tbody tr.odd:hover,
.tablepress.enhanced-tablepress tbody tr.even:hover {
    background-color: #f8f9ff !important;
}

/* 移除 TablePress 的默认边距和边框 */
.tablepress-scroll-wrapper {
    border: none !important;
    margin: 0 !important;
}

/* TablePress 分页和搜索栏优化 */
.dataTables_wrapper {
    margin-top: 15px !important;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 15px;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #e8e8e8;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #666;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* TablePress 分页按钮优化 */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px !important;
    margin: 0 2px !important;
    border-radius: 4px !important;
    border: 1px solid #e8e8e8 !important;
    background: #fff !important;
    color: #333 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f8f9ff !important;
    border-color: #666 !important;
    color: #333 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #333 !important;
    border-color: #333 !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* TablePress 信息文字优化 */
.dataTables_wrapper .dataTables_info {
    color: #666;
    font-size: 14px;
    padding: 10px 0;
}

/* TablePress 在移动端的优化 */
@media screen and (max-width: 768px) {
    .tablepress.enhanced-tablepress {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }
    
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        margin: 10px 0 !important;
    }
    
    .dataTables_wrapper .dataTables_length label,
    .dataTables_wrapper .dataTables_filter label {
        display: block;
        margin-bottom: 5px;
    }
    
    .dataTables_wrapper .dataTables_length select,
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 300px;
    }
}

/* 确保 TablePress 表格不被其他样式干扰 */
.tablepress.enhanced-tablepress,
.tablepress.enhanced-tablepress * {
    box-sizing: border-box;
}

/* ============================================
   额外工具类
   ============================================ */

/* 允许单元格内容换行（特殊情况使用） */
.wznrys table.enhanced-table.wrap-text td,
.wznrys table.enhanced-table .wrap-text {
    white-space: normal !important;
    word-wrap: break-word;
    word-break: break-all;
}

/* 紧凑型表格（减少内边距） */
.wznrys table.enhanced-table.compact thead th {
    padding: 10px 15px !important;
}

.wznrys table.enhanced-table.compact tbody td {
    padding: 8px 15px !important;
}

/* 左对齐表格（如果需要） */
.wznrys table.enhanced-table.text-left thead th,
.wznrys table.enhanced-table.text-left tbody td {
    text-align: left !important;
}

/* 右对齐表格（适合数字） */
.wznrys table.enhanced-table.text-right thead th,
.wznrys table.enhanced-table.text-right tbody td {
    text-align: right !important;
}

/* 固定宽度表格（避免过宽） */
.wznrys table.enhanced-table.fixed-width {
    max-width: 100%;
    table-layout: fixed;
}

.wznrys table.enhanced-table.fixed-width td,
.wznrys table.enhanced-table.fixed-width th {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   隐藏空白行
   ============================================ */

/* 隐藏完全空白的行（所有单元格都为空） */
.wznrys table.enhanced-table tbody tr:empty,
table.tablepress.enhanced-table tbody tr:empty {
    display: none !important;
}

/* 隐藏所有单元格都为空的行 */
.wznrys table.enhanced-table tbody tr td:empty,
table.tablepress.enhanced-table tbody tr td:empty {
    /* 空单元格样式 */
}

/* 检测并隐藏空白行（需要配合JavaScript） */
.wznrys table.enhanced-table tbody tr.empty-row,
table.tablepress.enhanced-table tbody tr.empty-row {
    display: none !important;
}

