/* 
 * 外贸邦 - 表格增强样式
 * 专门优化表格显示和交互体验
 */

/* ===== 专业化表格样式 ===== */

/* 表格整体布局优化 */
.data-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    background: white;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-variant-numeric: tabular-nums; /* 数字等宽显示 */
}

/* 表头专业化设计 */
.data-table thead th {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 2px solid #334155;
    border-right: 1px solid #cbd5e1;
    color: #1e293b;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 1rem 0.75rem;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.data-table thead th:last-child {
    border-right: none;
}

.data-table thead th i {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: #3b82f6;
}

.data-table thead th div {
    font-weight: 700;
    color: #1e293b;
}

/* 表格行专业化设计 */
.data-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    height: 60px;
    background: white;
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table tbody tr:hover {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

/* 表格单元格专业化设计 */
.data-table tbody td {
    padding: 0.75rem;
    border-right: 1px solid #e2e8f0;
    vertical-align: middle;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #374151;
    height: 60px;
    max-height: 60px;
    overflow: hidden;
    position: relative;
}

.data-table tbody td:last-child {
    border-right: none;
}

/* 左对齐的列 */
.data-table td[data-col="company_name"],
.data-table td[data-col="aizongjie"],
.data-table td[data-col="contact_info"],
.data-table td[data-col="main_products"],
.data-table td[data-col="official_website_information"],
.data-table td[data-col="is_beizhu"] {
    text-align: left;
    padding-left: 1rem;
}

/* 数字列右对齐 */
.data-table td[data-col="id"],
.data-table td[data-col="pingfen"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ===== 单元格内容优化 ===== */

/* 基础内容样式 */
.cell-content {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
    font-size: 0.875rem;
    color: #374151;
}

/* 多行内容限制 */
.cell-content.limited {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: 2.8em;
    line-height: 1.4;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cell-content.limited:hover {
    background: rgba(59, 130, 246, 0.05);
    border-radius: 4px;
    padding: 0.25rem;
    margin: -0.25rem;
}

/* 展开状态 */
.cell-content.expanded {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    white-space: normal;
    -webkit-line-clamp: unset;
    max-width: 400px;
    min-width: 250px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #1f2937;
}

/* ===== 控制按钮专业化 ===== */

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: white;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    margin: 0 2px;
}

.control-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.control-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.4);
}

.control-btn.important {
    color: #f59e0b;
    border-color: #fbbf24;
}

.control-btn.important:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #d97706;
}

.control-btn.important.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: white;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.4);
}

.control-btn.downloaded {
    background: #dcfce7;
    border-color: #16a34a;
    color: #16a34a;
    cursor: default;
}

.control-btn.downloaded:hover {
    transform: none;
    box-shadow: none;
}

/* ===== 特殊单元格样式 ===== */

/* 公司名称单元格 */
.company-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.company-cell i {
    color: #059669;
    font-size: 0.875rem;
}

.company-cell .cell-content {
    font-weight: 600;
    color: #1f2937;
}

/* 国家单元格 */
.country-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.country-cell i {
    color: #3b82f6;
    font-size: 0.875rem;
}

/* 评分单元格 */
.score-cell {
    text-align: center;
}

.score-cell .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* 链接单元格 */
.link-cell {
    text-align: center;
}

.link-cell .btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
}

.link-cell .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 备注单元格 */
.note-cell {
    text-align: left;
}

.note-cell .cell-content {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 2rem;
}

.note-cell .cell-content:hover {
    background: #f3f4f6;
}

.note-cell .text-muted {
    font-style: italic;
}

/* ===== 展开按钮优化 ===== */

.expand-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: #3b82f6;
    color: white;
    border: none;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    z-index: 5;
}

.cell-content.limited:hover .expand-btn {
    opacity: 1;
    transform: scale(1);
}

.expand-btn:hover {
    background: #2563eb;
    transform: scale(1.1);
}

/* ===== 表格响应式优化 ===== */

/* 移动端表格优化 */
@media (max-width: 992px) {
    .data-table {
        min-width: 1000px;
        font-size: 0.8rem;
    }
    
    .data-table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .data-table tbody td {
        padding: 0.5rem;
        height: 50px;
        max-height: 50px;
    }
    
    .cell-content.limited {
        -webkit-line-clamp: 1;
        max-height: 1.4em;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
    
    .table-responsive {
        border-radius: var(--radius-lg);
        box-shadow: inset 0 0 10px rgba(102, 126, 234, 0.1);
    }
    
    /* 移动端滚动提示 */
    .table-responsive::after {
        content: '← 左右滑动查看更多 →';
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(37, 99, 235, 0.9) 100%);
        color: white;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.8rem;
        z-index: 10;
        backdrop-filter: blur(10px);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
}

/* ===== 长文本处理 ===== */

/* 长文本渐变遮罩 */
.cell-content.text-overflow {
    position: relative;
    overflow: hidden;
}

.cell-content.text-overflow::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 1.2em;
    background: linear-gradient(to right, transparent, white);
    pointer-events: none;
}

/* 展开时的遮罩层 */
.cell-expanded-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    backdrop-filter: blur(2px);
}

/* ===== 表格交互增强 ===== */

/* 行选中效果 */
.data-table tbody tr.selected {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left: 4px solid #3b82f6;
}

/* 单元格点击效果 */
.cell-content.clicked {
    animation: cellClick 0.3s ease;
}

@keyframes cellClick {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); background: rgba(59, 130, 246, 0.1); }
    100% { transform: scale(1); }
}

/* ===== 加载状态 ===== */

/* 表格加载骨架屏 */
.table-skeleton {
    animation: skeleton-loading 1.5s infinite;
}

.table-skeleton td {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* 按钮加载状态 */
.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spin 1s linear infinite;
}

@keyframes btn-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== 无障碍增强 ===== */

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .data-table th {
        border-bottom: 3px solid #000;
        background: #fff;
        color: #000;
    }
    
    .data-table td {
        border-bottom: 1px solid #666;
        border-right: 1px solid #666;
    }
    
    .control-btn {
        border: 2px solid currentColor;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .data-table tbody tr,
    .cell-content,
    .control-btn,
    .expand-btn {
        transition: none;
        animation: none;
    }
}

/* 焦点可见性增强 */
.control-btn:focus-visible,
.cell-content:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ===== 打印样式 ===== */
@media print {
    .table-responsive {
        overflow: visible !important;
        max-height: none !important;
    }
    
    .data-table {
        min-width: auto !important;
        table-layout: auto !important;
        font-size: 0.75rem;
    }
    
    .data-table thead th {
        background: #f8fafc !important;
        color: #000 !important;
        border: 1px solid #000;
    }
    
    .data-table tbody td {
        border: 1px solid #666;
    }
    
    .control-btn,
    .expand-btn {
        display: none !important;
    }
    
    .cell-content.limited {
        -webkit-line-clamp: unset !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/* ===== 深色模式支持 ===== */
@media (prefers-color-scheme: dark) {
    .data-table thead th {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        color: #f1f5f9;
        border-bottom-color: #64748b;
        border-right-color: #475569;
    }
    
    .data-table tbody tr {
        background: #0f172a;
        border-bottom-color: #334155;
    }
    
    .data-table tbody tr:nth-child(even) {
        background: #1e293b;
    }
    
    .data-table tbody tr:hover {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
    }
    
    .data-table tbody td {
        color: #e2e8f0;
        border-right-color: #334155;
    }
    
    .cell-content.expanded {
        background: #1e293b;
        border-color: #3b82f6;
        color: #f1f5f9;
    }
    
    .control-btn {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .control-btn:hover {
        background: #4b5563;
        border-color: #3b82f6;
        color: #3b82f6;
    }
} 