/* 表格样式 - 优化版本
 *
 * 【宽表 / 弹窗】约定（避免 modal、卡片、侧栏被撑出横向滚动条）：
 * - 不要给「全局 .table」设 min-width。历史上 min-width:1000px 曾导致所有带 .table 的
 *   模态框、首页窄卡片等布局被撑破；个别页面被迫写大量 !important 覆盖。
 * - 仅对「列表区」—— .table-responsive 的直接子表 —— 保留「至少 1000px + 由外层横滚」的行为。
 * - .modal / .offcanvas 内的表格一律取消该最小宽度，宽度随弹层约束。
 * - 若某表不在 .table-responsive 内、但仍需要宽表效果，请给 <table> 加 class：table-scroll-min-wide
 */

/* 表格容器样式 - 使用浏览器滚动条 */
.table-responsive {
    overflow-x: visible !important;
    overflow-y: visible !important;
    margin-top: 20px;
    width: 100% !important;
    min-width: 100% !important;
    display: block;
    box-sizing: border-box;
}


/* 表格基础样式（默认与 Bootstrap 一致，不强制最小宽度） */
.table {
    margin-bottom: 0;
    table-layout: auto;
}

/* 主内容区数据列表：宽表 + 横向滚动（仅直接子表，避免嵌套表误伤） */
.table-responsive > .table {
    min-width: 1000px;
    width: 100% !important;
}

/* 列表区表格至少占满 .table-responsive 容器（无数据、列少时也不缩成窄条） */
.table-responsive.partner-table > .table {
    min-width: 100%;
}

/* 弹层 / 抽屉内：禁止继承上面的「千像素宽表」 */
.modal .table-responsive > .table,
.offcanvas .table-responsive > .table {
    min-width: 0 !important;
    width: auto !important;
    max-width: 100%;
}

/* 不在 .table-responsive 内、又需要与列表相同宽表行为时，在 <table> 上增加此类 */
.table.table-scroll-min-wide {
    min-width: 1000px;
    width: auto !important;
}

/* 如果表格宽度小于容器，则填满容器（与上条 min-width:100% 配合） */
.partner-table .table {
    width: 100% !important;
}

/* 所有单元格不分行 */
.table td {
    white-space: nowrap;
}

/* 列表区缺省字号 12px（编程规范默认档，等同 table-font-small） */
.table-responsive.partner-table > .table {
    font-size: 12px;
}

.table-responsive.partner-table > .table.table-font-medium {
    font-size: 14px;
}

.table-responsive.partner-table > .table.table-font-large {
    font-size: 16px;
}

.table-responsive.partner-table > .table:not(.table-font-medium):not(.table-font-large) th,
.table-responsive.partner-table > .table:not(.table-font-medium):not(.table-font-large) td {
    font-size: 12px;
    padding: 6px 8px;
}

/* 表头必须显示全 */
.table th {
    white-space: nowrap;
    overflow: visible; /* 确保表头不截断 */
}

/* 表格头部样式 */
.table-dark {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: none;
}

.table-dark th {
    border: none;
    font-weight: 600;
    padding: 12px 8px;
}

/* 表格行悬停效果 */
.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* 表格选择样式 */
.table-selected {
    background-color: #c5e4f9 !important;
    border-left: 3px solid #1976d2;
}

/* 复选框列样式 */
.checkbox-column {
    width: 40px;
    text-align: center;
    vertical-align: middle;
}

.checkbox-column input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 操作列样式 */
.action-buttons {
    white-space: nowrap;
}

.action-buttons .btn {
    margin: 0 1px;
    font-size: 0.7rem;
    padding: 2px 6px;
    line-height: 1.2;
}

/* 状态徽章 */
.status-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
}

.badge-active {
    background-color: #28a745 !important;
}

.badge-inactive {
    background-color: #6c757d !important;
}

/* 表格排序样式 */
th[data-column] {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background-color 0.2s ease;
}

th[data-column]:hover {
    background-color: rgba(0, 0, 0, 0.1) !important;
}

.sort-icon {
    margin-left: 5px;
    font-size: 0.8em;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

th[data-column]:hover .sort-icon {
    opacity: 1;
}

.sort-asc,
.sort-desc {
    background-color: rgba(13, 110, 253, 0.1) !important;
}

/* 确保复选框列不可排序 */
.checkbox-column {
    cursor: default !important;
}

.checkbox-column:hover {
    background-color: inherit !important;
}

/* ========== 列类型样式 ========== */

/* normal-text 列：不截断，宽度随内容自适应 */
th[data-type="normal-text"],
td[data-type="normal-text"] {
    width: auto !important;
    min-width: 80px; /* 最小宽度保证可读性 */
    max-width: none !important;
    overflow: visible; /* 不截断 */
}

/* truncate-text 列：固定宽度 + 截断 + tooltip */
th[data-type="truncate-text"],
td[data-type="truncate-text"] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

/* truncate-text 列的 tooltip - 使用固定定位脱离表格布局 */
td[data-type="truncate-text"] {
    position: relative;
}

/* 只有当 data-fulltext 存在且不为空时才显示 tooltip（支持多行、自动换行与保留换行符） */
td[data-type="truncate-text"]:hover::after {
    content: attr(data-fulltext);
    position: fixed;
    top: calc(var(--tooltip-y, 0px) + 10px);
    left: calc(var(--tooltip-x, 0px) + 10px);
    background: rgba(30, 60, 114, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-wrap;   /* 保留换行符并自动换行，支持多行显示 */
    word-wrap: break-word;
    max-width: 400px;
    line-height: 1.4;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 如果 data-fulltext 为空或不存在，则不显示 tooltip */
td[data-type="truncate-text"]:not([data-fulltext]):hover::after,
td[data-type="truncate-text"][data-fulltext=""]:hover::after {
    display: none;
}

/* ========== 合作伙伴表格特定列宽度 ========== */

/* truncate-text 列的固定宽度定义 */
.col-partner-name {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
}

.col-customer-services {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

.col-vendor-lines {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

/* ========== 订单表格特定列宽度 ========== */

/* 操作备注列：宽度 150px，超出截断 */
.col-op-note {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 销售备注列：与操作备注同宽，超出截断 */
.col-order-note {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 客户名称：在 150px 基础上缩窄约 3 个汉字（≈42px，按表格常用字号估算） */
.col-customer-name {
    width: 108px;
    min-width: 108px;
    max-width: 108px;
}

/* 航线备注列：宽度 150px，超出截断 */
.col-route-note {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Booking Agent、国外代理 列固定宽度 150px */
.col-booking-agent-name,
.col-liner-name,
.col-agent-name {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
}

/* 确保链接内容也能正确截断 */
.col-customer-name,
.col-booking-agent-name,
.col-liner-name,
.col-agent-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-booking-agent-name .booking-agent-link {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* normal-text 列的宽度由内容自适应，无需定义固定宽度 */
/* 以下列将自动适应内容宽度：object_no, object_type, branch_name, sales_name, bank_name, entity_name, activated */

/* 操作列固定宽度 */
.col-actions {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    text-align: center;
}

/* 字体大小控制 */
.table-font-small {
    font-size: 12px;
}

.table-font-small th,
.table-font-small td {
    font-size: 12px;
    padding: 6px 8px;
}

.table-font-medium {
    font-size: 14px;
}

.table-font-medium th,
.table-font-medium td {
    font-size: 14px;
    padding: 8px 10px;
}

.table-font-large {
    font-size: 16px;
}

.table-font-large th,
.table-font-large td {
    font-size: 16px;
    padding: 10px 12px;
}

/* 分页信息 + 字体 SML 所在行：与上（查询条件）/下（表格）压紧；覆盖 pagination.css 的 .pagination-info 竖向 10px 留白 */
.table-controls-tight {
    margin-top: 0;
    margin-bottom: 0;
    --bs-gutter-y: 0;
    padding-top: 0;
    padding-bottom: 0;
    row-gap: 0 !important;
}
.table-controls-tight .pagination-info {
    margin: 0;
    padding: 0;
    line-height: 1.3;
}
.table-controls-tight .col-md-6 {
    padding-top: 0;
    padding-bottom: 0;
}

/* 字体大小控制：无外围框；S/M/L 小号字 */
.font-size-control {
    margin-bottom: 0;
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.font-size-control .btn-group {
    box-shadow: none;
}

.font-size-control .btn {
    border-color: #6c757d;
    color: #495057;
    transition: all 0.2s ease;
    font-size: 0.7rem;
    line-height: 1.2;
    padding: 1px 6px;
    min-width: 0;
}

/* 列设置：外框与 S/M/L 相同，浅蓝灰底区分功能 */
.font-size-control #columnSettingsBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    line-height: 1.2;
    background-color: #d4e3f2;
    border-color: #7f9bb5;
    color: #2f4558;
}
.font-size-control #columnSettingsBtn i {
    font-size: 0.7rem;
    transform: scale(1.35);
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
}
.font-size-control #columnSettingsBtn:hover {
    background-color: #bdd2e8;
    border-color: #6689a8;
    color: #1f3547;
}

.font-size-control .btn:hover {
    background-color: #e9ecef;
    border-color: #6c757d;
}

.font-size-control .btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* None值单元格样式 - 显示为很浅的黑色 */
.none-value-cell {
    color: #999999 !important; /* 很浅的黑色 */
    font-style: italic;
    opacity: 0.7;
}
