/* ========================================
   川渝好门户 - 统一表格组件
   Unified Table Components
   ======================================== */

/* ========== 基础表格 ========== */
.table-container {
    background: var(--cy-bg-white);
    border-radius: var(--cy-radius-lg);
    box-shadow: var(--cy-shadow-sm);
    overflow: hidden;
    margin-bottom: var(--cy-spacing-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--cy-font-md);
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--cy-border-light);
}

.table th {
    background: var(--cy-bg-light);
    font-weight: 600;
    color: var(--cy-text-primary);
    font-size: var(--cy-font-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    color: var(--cy-text-primary);
}

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

.table tbody tr:hover {
    background: rgba(var(--cy-primary-rgb), 0.02);
}

/* ========== 表格变体 ========== */
.table-striped tbody tr:nth-child(even) {
    background: var(--cy-bg-light);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--cy-border-light);
}

.table-compact th,
.table-compact td {
    padding: 10px 12px;
    font-size: var(--cy-font-sm);
}

.table-relaxed th,
.table-relaxed td {
    padding: 18px 20px;
}

/* ========== 表格头部样式 ========== */
.table-header-primary th {
    background: var(--cy-gradient-primary);
    color: #fff;
    border: none;
}

.table-header-dark th {
    background: var(--cy-gradient-dark);
    color: #fff;
    border: none;
}

/* ========== 表格行样式 ========== */
.table-row-success {
    background: rgba(56, 142, 60, 0.05) !important;
}

.table-row-warning {
    background: rgba(251, 192, 45, 0.05) !important;
}

.table-row-danger {
    background: rgba(211, 47, 47, 0.05) !important;
}

.table-row-info {
    background: rgba(25, 118, 210, 0.05) !important;
}

.table-row-active {
    background: rgba(var(--cy-primary-rgb), 0.05) !important;
}

/* ========== 表格列对齐 ========== */
.table-col-center {
    text-align: center !important;
}

.table-col-right {
    text-align: right !important;
}

.table-col-nowrap {
    white-space: nowrap;
}

/* ========== 表格操作列 ========== */
.table-actions {
    display: flex;
    gap: var(--cy-spacing-sm);
    align-items: center;
}

.table-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--cy-bg-light);
    border-radius: var(--cy-radius-md);
    color: var(--cy-text-secondary);
    cursor: pointer;
    transition: var(--cy-transition-fast);
}

.table-action-btn:hover {
    background: var(--cy-primary);
    color: #fff;
}

.table-action-btn.edit:hover {
    background: var(--cy-secondary);
}

.table-action-btn.delete:hover {
    background: var(--cy-danger);
}

.table-action-btn.view:hover {
    background: var(--cy-success);
}

/* ========== 表格状态标签 ========== */
.table-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--cy-radius-round);
    font-size: var(--cy-font-sm);
    font-weight: 500;
}

.table-status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--cy-radius-circle);
}

.table-status-success {
    background: rgba(56, 142, 60, 0.1);
    color: var(--cy-success);
}

.table-status-success .table-status-dot {
    background: var(--cy-success);
}

.table-status-warning {
    background: rgba(251, 192, 45, 0.1);
    color: #f57c00;
}

.table-status-warning .table-status-dot {
    background: var(--cy-warning);
}

.table-status-danger {
    background: rgba(211, 47, 47, 0.1);
    color: var(--cy-danger);
}

.table-status-danger .table-status-dot {
    background: var(--cy-danger);
}

.table-status-info {
    background: rgba(25, 118, 210, 0.1);
    color: var(--cy-secondary);
}

.table-status-info .table-status-dot {
    background: var(--cy-secondary);
}

.table-status-default {
    background: var(--cy-bg-light);
    color: var(--cy-text-secondary);
}

.table-status-default .table-status-dot {
    background: var(--cy-text-muted);
}

/* ========== 表格用户信息 ========== */
.table-user {
    display: flex;
    align-items: center;
    gap: var(--cy-spacing-sm);
}

.table-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--cy-radius-circle);
    overflow: hidden;
    flex-shrink: 0;
}

.table-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.table-user-info {
    flex: 1;
    min-width: 0;
}

.table-user-name {
    font-weight: 500;
    color: var(--cy-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-user-email {
    font-size: var(--cy-font-sm);
    color: var(--cy-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== 表格进度条 ========== */
.table-progress {
    display: flex;
    align-items: center;
    gap: var(--cy-spacing-sm);
}

.table-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--cy-bg-light);
    border-radius: var(--cy-radius-round);
    overflow: hidden;
}

.table-progress-fill {
    height: 100%;
    background: var(--cy-gradient-primary);
    border-radius: var(--cy-radius-round);
    transition: width var(--cy-animation-normal) ease;
}

.table-progress-text {
    font-size: var(--cy-font-sm);
    color: var(--cy-text-muted);
    min-width: 40px;
}

/* ========== 表格排序 ========== */
.table-sortable th {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 28px;
}

.table-sortable th::after {
    content: '⇅';
    position: absolute;
    right: 10px;
    color: var(--cy-text-muted);
    opacity: 0.5;
}

.table-sortable th:hover::after {
    opacity: 1;
}

.table-sortable th.sort-asc::after {
    content: '↑';
    color: var(--cy-primary);
    opacity: 1;
}

.table-sortable th.sort-desc::after {
    content: '↓';
    color: var(--cy-primary);
    opacity: 1;
}

/* ========== 表格分页 ========== */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-top: 1px solid var(--cy-border-light);
}

.table-pagination-info {
    font-size: var(--cy-font-sm);
    color: var(--cy-text-muted);
}

.table-pagination-nav {
    display: flex;
    gap: 4px;
}

.table-pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--cy-border);
    border-radius: var(--cy-radius-md);
    color: var(--cy-text-secondary);
    font-size: var(--cy-font-sm);
    cursor: pointer;
    transition: var(--cy-transition-fast);
}

.table-pagination-btn:hover {
    border-color: var(--cy-primary);
    color: var(--cy-primary);
}

.table-pagination-btn.active {
    background: var(--cy-primary);
    border-color: var(--cy-primary);
    color: #fff;
}

.table-pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 表格工具栏 ========== */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--cy-border-light);
    gap: var(--cy-spacing-md);
}

.table-toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--cy-spacing-sm);
}

.table-toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--cy-spacing-sm);
}

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

.table-toolbar-search input {
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--cy-border);
    border-radius: var(--cy-radius-md);
    font-size: var(--cy-font-sm);
    width: 200px;
    transition: var(--cy-transition);
}

.table-toolbar-search input:focus {
    border-color: var(--cy-primary);
    outline: none;
    width: 250px;
}

.table-toolbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cy-text-muted);
}

/* ========== 表格空状态 ========== */
.table-empty {
    text-align: center;
    padding: 60px 20px;
}

.table-empty-icon {
    font-size: 48px;
    color: var(--cy-text-muted);
    margin-bottom: var(--cy-spacing-md);
    opacity: 0.5;
}

.table-empty-text {
    font-size: var(--cy-font-md);
    color: var(--cy-text-muted);
    margin-bottom: var(--cy-spacing-lg);
}

/* ========== 表格加载状态 ========== */
.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;
}

.table-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--cy-border);
    border-top-color: var(--cy-primary);
    border-radius: var(--cy-radius-circle);
    animation: cy-spin 1s linear infinite;
    z-index: 1;
}

/* ========== 响应式表格 ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
    min-width: 600px;
}

/* 移动端卡片式表格 */
@media screen and (max-width: 768px) {
    .table-mobile-card {
        display: block;
    }
    
    .table-mobile-card thead {
        display: none;
    }
    
    .table-mobile-card tbody {
        display: block;
    }
    
    .table-mobile-card tr {
        display: block;
        background: var(--cy-bg-white);
        border: 1px solid var(--cy-border-light);
        border-radius: var(--cy-radius-md);
        margin-bottom: var(--cy-spacing-md);
        padding: var(--cy-spacing-md);
    }
    
    .table-mobile-card td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid var(--cy-border-light);
    }
    
    .table-mobile-card td:last-child {
        border-bottom: none;
    }
    
    .table-mobile-card td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--cy-text-secondary);
        margin-right: var(--cy-spacing-md);
    }
    
    .table-mobile-card td.table-col-center,
    .table-mobile-card td.table-col-right {
        text-align: right;
    }
    
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-toolbar-search input {
        width: 100%;
    }
    
    .table-toolbar-search input:focus {
        width: 100%;
    }
    
    .table-pagination {
        flex-direction: column;
        gap: var(--cy-spacing-md);
    }
}

/* ========== 表格固定列 ========== */
.table-sticky-col {
    position: sticky;
    background: var(--cy-bg-white);
    z-index: 1;
}

.table-sticky-col-first {
    left: 0;
}

.table-sticky-col-last {
    right: 0;
}

.table-sticky-col::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to right, rgba(0,0,0,0.05), transparent);
}

.table-sticky-col-first::after {
    right: -4px;
}

.table-sticky-col-last::after {
    left: -4px;
    background: linear-gradient(to left, rgba(0,0,0,0.05), transparent);
}

/* ========== 表格行展开 ========== */
.table-expandable-row {
    cursor: pointer;
}

.table-expandable-row td:first-child::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    color: var(--cy-text-muted);
    transition: var(--cy-transition-fast);
}

.table-expandable-row.expanded td:first-child::before {
    transform: rotate(90deg);
    color: var(--cy-primary);
}

.table-expandable-content {
    display: none;
    background: var(--cy-bg-light);
}

.table-expandable-content.show {
    display: table-row;
}

.table-expandable-content td {
    padding: 20px;
}
