/* 
 * Modern Table Beauty - 现代化表格美化样式
 * 为 Typecho 网站提供美观、现代化的表格展示
 * 兼容 Dracula 主题配色方案
 */

/* ====== 基础表格重置 ====== */
table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 1.5rem 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.125rem;
    line-height: 1.8;
    color: #333;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

table:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ====== 表头样式 ====== */
thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

thead th {
    padding: 1.125rem 1.375rem;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    font-size: 1.0625rem;
    border-bottom: 3px solid #5a67d8;
    position: relative;
    overflow: hidden;
}

thead th:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

thead th:hover:before {
    left: 100%;
}

/* ====== 表体样式 ====== */
tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #f1f5f9;
}

tbody tr:nth-child(even) {
    background: #f8fafc;
}

tbody tr:nth-child(odd) {
    background: white;
}

tbody tr:hover {
    background: linear-gradient(90deg, #f0f9ff 0%, #e0f2fe 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

tbody td {
    padding: 1.125rem 1.375rem;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    font-size: 1.125rem;
}

tbody td:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
}

tbody td:hover:after {
    width: 100%;
}

/* ====== 单元格对齐 ====== */
td[align="center"],
th[align="center"] {
    text-align: center;
}

td[align="right"],
th[align="right"] {
    text-align: right;
}

td[align="left"],
th[align="left"] {
    text-align: left;
}

/* ====== 特殊单元格样式 ====== */
td strong,
td b {
    color: #1e40af;
    font-weight: 600;
}

td em,
td i {
    color: #7c3aed;
    font-style: italic;
}

td code {
    background: #f1f5f9;
    color: #dc2626;
    padding: 0.375rem 0.625rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    font-size: 1.0625rem;
    font-weight: 600;
}

/* ====== 表格边框样式 ====== */
table.bordered,
table.border {
    border: 1px solid #e2e8f0;
}

table.bordered th,
table.bordered td,
table.border th,
table.border td {
    border: 1px solid #e2e8f0;
}

/* ====== 紧凑表格 ====== */
table.compact th,
table.compact td {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

/* ====== 条纹表格 ====== */
table.striped tbody tr:nth-child(odd) {
    background: #f8fafc;
}

table.striped tbody tr:nth-child(even) {
    background: white;
}

/* ====== 悬停表格 ====== */
table.hover tbody tr:hover {
    background: #f0f9ff;
}

/* ====== 响应式表格 ====== */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        border-radius: 6px;
        margin: 1rem 0;
    }
    
    thead th {
        padding: 0.875rem 1.125rem;
        font-size: 1rem;
    }
    
    tbody td {
        padding: 0.875rem 1.125rem;
        font-size: 1.0625rem;
    }
    
    table.compact th,
    table.compact td {
        padding: 0.625rem 0.875rem;
        font-size: 0.9375rem;
    }
}

/* ====== 暗色模式支持 ====== */
@media (prefers-color-scheme: dark) {
    table {
        background: #1e293b;
        color: #cbd5e1;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    thead {
        background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    }
    
    thead th {
        border-bottom-color: #4338ca;
        color: #f1f5f9;
    }
    
    tbody tr:nth-child(even) {
        background: #0f172a;
    }
    
    tbody tr:nth-child(odd) {
        background: #1e293b;
    }
    
    tbody tr:hover {
        background: linear-gradient(90deg, #1e3a8a 0%, #3730a3 100%);
        box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
    }
    
    tbody td {
        border-bottom-color: #334155;
        color: #cbd5e1;
    }
    
    td strong,
    td b {
        color: #60a5fa;
    }
    
    td em,
    td i {
        color: #a78bfa;
    }
    
    td code {
        background: #334155;
        color: #f87171;
    }
    
    table.bordered,
    table.border {
        border-color: #475569;
    }
    
    table.bordered th,
    table.bordered td,
    table.border th,
    table.border td {
        border-color: #475569;
    }
    
    table.striped tbody tr:nth-child(odd) {
        background: #0f172a;
    }
    
    table.striped tbody tr:nth-child(even) {
        background: #1e293b;
    }
    
    table.hover tbody tr:hover {
        background: #1e3a8a;
    }
}

/* ====== 表格标题 ====== */
table + p.caption,
table + .caption {
    display: block;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
    text-align: center;
    font-style: italic;
    color: #64748b;
    font-size: 0.875rem;
}

/* ====== 表格容器 ====== */
.table-container {
    position: relative;
    margin: 1.5rem 0;
    overflow: hidden;
    border-radius: 8px;
}

.table-container:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    z-index: 1;
}

.table-container table {
    margin: 0;
    border-radius: 0 0 8px 8px;
}

/* ====== 表格工具栏 ====== */
.table-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
}

.table-toolbar button {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    margin-left: 0.5rem;
    font-size: 0.8125rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-toolbar button:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* ====== 表格分页 ====== */
.table-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 8px 8px;
}

.table-pagination button {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    font-size: 0.875rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-pagination button:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.table-pagination button.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* ====== 表格排序指示器 ====== */
th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 1.75rem;
}

th.sortable:after {
    content: '↕';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

th.sortable.asc:after {
    content: '↑';
    color: white;
}

th.sortable.desc:after {
    content: '↓';
    color: white;
}

/* ====== 表格单元格状态 ====== */
td.success {
    background: linear-gradient(90deg, #d1fae5, #a7f3d0) !important;
    color: #065f46 !important;
    font-weight: 600;
}

td.warning {
    background: linear-gradient(90deg, #fef3c7, #fde68a) !important;
    color: #92400e !important;
    font-weight: 600;
}

td.error {
    background: linear-gradient(90deg, #fee2e2, #fecaca) !important;
    color: #991b1b !important;
    font-weight: 600;
}

td.info {
    background: linear-gradient(90deg, #dbeafe, #bfdbfe) !important;
    color: #1e40af !important;
    font-weight: 600;
}

/* ====== 表格动画效果 ====== */
@keyframes tableRowEnter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

tbody tr {
    animation: tableRowEnter 0.3s ease forwards;
}

tbody tr:nth-child(1) { animation-delay: 0.05s; }
tbody tr:nth-child(2) { animation-delay: 0.1s; }
tbody tr:nth-child(3) { animation-delay: 0.15s; }
tbody tr:nth-child(4) { animation-delay: 0.2s; }
tbody tr:nth-child(5) { animation-delay: 0.25s; }
tbody tr:nth-child(6) { animation-delay: 0.3s; }
tbody tr:nth-child(7) { animation-delay: 0.35s; }
tbody tr:nth-child(8) { animation-delay: 0.4s; }
tbody tr:nth-child(9) { animation-delay: 0.45s; }
tbody tr:nth-child(10) { animation-delay: 0.5s; }

/* ====== 表格打印优化 ====== */
@media print {
    table {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        background: white !important;
        color: black !important;
    }
    
    thead {
        background: #f8f8f8 !important;
        color: black !important;
    }
    
    thead th {
        border-bottom: 2px solid #ccc !important;
    }
    
    tbody tr {
        border-bottom: 1px solid #eee !important;
    }
    
    tbody tr:nth-child(even) {
        background: #f8f8f8 !important;
    }
    
    .table-container:before,
    .table-toolbar,
    .table-pagination {
        display: none !important;
    }
}

/* ====== 表格可访问性 ====== */
@media (prefers-reduced-motion: reduce) {
    table,
    tbody tr,
    tbody td,
    thead th {
        transition: none !important;
        animation: none !important;
    }
    
    thead th:before,
    tbody td:after {
        display: none !important;
    }
}

/* ====== 表格焦点样式 ====== */
table:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

th:focus,
td:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

/* ====== 表格加载状态 ====== */
table.loading {
    position: relative;
    min-height: 200px;
}

table.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;
    font-size: 1rem;
    color: #64748b;
}

table.loading:before {
    content: '加载中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    font-size: 0.875rem;
    color: #64748b;
}

/* ====== 表格空状态 ====== */
table.empty tbody:after {
    content: '暂无数据';
    display: block;
    text-align: center;
    padding: 3rem;
    color: #94a3b8;
    font-style: italic;
    font-size: 0.9375rem;
}

/* ====== 表格单元格合并样式 ====== */
td[rowspan],
td[colspan],
th[rowspan],
th[colspan] {
    background: #f1f5f9;
    font-weight: 600;
    text-align: center;
}

/* ====== 表格脚注 ====== */
tfoot {
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
}

tfoot td {
    padding: 0.875rem 1.375rem;
    font-weight: 700;
    color: #475569;
    font-size: 1.125rem;
}

/* ====== 表格图标支持 ====== */
td .table-icon,
th .table-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* ====== 表格进度条 ====== */
.table-progress {
    display: inline-block;
    width: 100px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin: 0 0.5rem;
}

.table-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 3px;
