/* ==========================================================================
   宝之通增长中台 · components.css — 基础组件
   --------------------------------------------------------------------------
   页头 / 卡片 / 表格 / 徽标 / 表单 / 按钮 / 分页 / 警告 / 进度条
   ========================================================================== */

/* ==========================================================================
   TOC（章节锥点）— grep '=== \[<id>\]' 可直接跳转：
     [page-header]      页头
     [cards]            卡片
     [stat-cards]       统计卡
     [data-tables]      数据表格
     [follow-pills]     跟进状态 / 触达动作小药丸
     [pagination]       分页
     [badges]           徽标与 Bootstrap badge 语义色覆盖
     [forms]            表单与输入组
     [buttons]          按钮
     [alerts]           警告框
     [progress]         进度条
     [micro-motion]     微动效
     [nav-pills]        导航 Pills
     [empty-state]      空状态
     [text-utils]       文字工具类
     [responsive-utils] 通用响应式
     [bootstrap-brand]  Bootstrap 组件品牌统一（Modal / Dropdown / Tooltip）
   ========================================================================== */

/* === [page-header] 页头 === */
.page-header,
.import-hero,
.trash-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--surface-border);
}

.page-header > div:first-child { min-width: 0; }

.page-title,
h4.mb-0 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--text-main);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
}

.page-title i,
h4.mb-0 > i:first-child {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--accent);
    background: var(--accent-soft);
    font-size: 0.82rem;
}

.page-subtitle,
.import-hero-copy {
    margin-top: 4px;
    max-width: 72ch;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    line-height: var(--lh-relaxed);
}

.page-actions,
.import-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 0 1 auto;
}

/* === [cards] 卡片 === */
.card,
.toolbar-card,
.table-card,
.stat-card,
.import-panel,
.import-step,
.customer-rich-table,
.customer-summary-row > td,
.customer-detail-row > td {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--motion-base) var(--easing),
                box-shadow var(--motion-base) var(--easing);
}

.toolbar-card { padding: 14px 16px; margin-bottom: 14px; }
.toolbar-card .form-label {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.table-card { margin-bottom: 14px; overflow: hidden; }

.card-header {
    padding: 12px 16px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.card-header h6,
.card-header h5,
.card-header .card-title {
    margin: 0;
    color: var(--text-main);
    font-size: var(--fs-base);
    font-weight: 700;
}
.card-body { padding: 16px; }
.card-body + .card-body { padding-top: 0; }

.card-title,
.card-header h6,
.stat-card h6 {
    color: var(--text-main);
    font-weight: 700;
}

/* === [stat-cards] 统计卡 === */
.stat-card {
    min-height: 104px;
    padding: 16px 18px;
    transition: border-color var(--motion-base) var(--easing),
                box-shadow var(--motion-base) var(--easing),
                transform var(--motion-base) var(--easing);
}
.stat-card:hover {
    border-color: var(--accent-line);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.stat-card .icon {
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
}
.stat-card .stat-value,
.stat-card h3,
.stat-card h2 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}
.stat-card .stat-label,
.stat-card .text-muted {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* === [data-tables] 数据表格 === */
.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.data-table {
    margin-bottom: 0;
    min-width: 860px;
    color: var(--text-main);
    font-size: var(--fs-sm);
}

.data-table thead th {
    padding: 10px 14px;
    color: var(--text-muted);
    background: var(--surface-soft);
    border-bottom: 1px solid var(--surface-border);
    font-size: var(--fs-xs);
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.data-table tbody td {
    padding: 11px 14px;
    vertical-align: middle;
    border-color: var(--surface-border);
}

.data-table tbody tr {
    transition: background var(--motion-fast) var(--easing);
}
.data-table tbody tr:nth-child(even) td { background: var(--surface-soft); }
.data-table tbody tr:hover,
.table-hover > tbody > tr:hover > * {
    background: var(--surface-soft);
}

/* 表格右侧操作列吸附 */
.data-table th:last-child,
.data-table td:last-child {
    position: sticky;
    right: 0;
    background: inherit;
    box-shadow: -6px 0 12px -6px rgba(15, 23, 42, 0.08);
    z-index: 2;
}
.data-table thead th:last-child { background: var(--surface-soft); z-index: 3; }
.data-table tbody td:last-child { background: var(--surface); }
.data-table tbody tr:hover td:last-child { background: var(--surface-soft); }
.data-table tbody tr:nth-child(even) td:last-child { background: var(--surface-soft); }

/* 表格行 hover 显示操作 (桌面端) */
@media (hover: hover) and (pointer: fine) and (min-width: 901px) {
    .crm-col-actions .table-action,
    .crm-my-actions .table-action {
        opacity: 0;
        transform: translateX(2px);
        transition: opacity var(--motion-fast) var(--easing),
                    transform var(--motion-fast) var(--easing);
    }
    tr:hover .crm-col-actions .table-action,
    tr:hover .crm-my-actions .table-action,
    tr:focus-within .crm-col-actions .table-action,
    tr:focus-within .crm-my-actions .table-action {
        opacity: 1;
        transform: none;
    }
    .crm-col-actions .btn-outline-primary.table-action,
    .crm-my-actions .btn-outline-primary.table-action {
        opacity: 1;
        transform: none;
    }
}

/* 公司 / 电话单元 */
.company-cell { min-width: 220px; max-width: 300px; }
.company-name {
    display: block;
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.4;
    text-decoration: none;
}
.company-name:hover { color: var(--accent); }
.company-meta {
    margin-top: 2px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.phone-cell {
    min-width: 130px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.phone-cell a { color: var(--accent); font-weight: 600; }

.table-action {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
}

/* === [follow-pills] 跟进状态 / 触达动作小药丸（pool.html / mine.html / my_customers.html）=== */
.action-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px 3px 7px;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    transition: background var(--motion-fast) var(--easing),
                color var(--motion-fast) var(--easing),
                border-color var(--motion-fast) var(--easing);
}
.action-pill > i { font-size: 0.85em; }
.action-pill.action-muted {
    background: var(--surface-soft);
    color: var(--text-muted);
    border-color: var(--surface-border);
    border-left-color: var(--surface-border);
}
.action-pill.action-warm {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-color: rgba(37, 99, 235, 0.18);
    border-left-color: var(--accent);
}
.action-pill.action-hot {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger-pressed);
    border-color: rgba(220, 38, 38, 0.22);
    border-left-color: var(--danger);
}
.action-pill.action-warning {
    background: var(--warning-soft);
    color: var(--warning-dark);
    border-color: rgba(217, 119, 6, 0.25);
    border-left-color: var(--warning);
}

/* === [pagination] 分页 === */
.pool-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.pool-pagination-summary {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    white-space: nowrap;
}
.pool-pagination-summary strong { color: var(--text-main); }
.pool-pagination-list {
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.pool-pagination-list .page-link {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border-color: var(--surface-border);
    color: var(--text-secondary);
    font-weight: 600;
    box-shadow: none;
    transition: background var(--motion-fast) var(--easing),
                color var(--motion-fast) var(--easing);
}
.pool-pagination-list .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--surface);
}
.pool-pagination-list .page-item.disabled .page-link {
    color: var(--text-faint);
    background: var(--surface-soft);
}

@media (max-width: 768px) {
    .pool-pagination { flex-direction: column; align-items: flex-start; }
    .pool-pagination-list { justify-content: flex-start; }
}

/* === [badges] 徽标 === */
.badge { border-radius: var(--radius-xs); font-weight: 700; font-size: var(--fs-xs); padding: 4px 8px; }
.badge-grade {
    min-width: 24px;
    border-radius: var(--radius-xs);
    font-weight: 700;
}
.badge-status { border-radius: var(--radius-xs); padding: 0.25rem 0.5rem; }

.badge-grade.bg-danger,
.badge-grade.text-bg-danger { background: var(--danger); color: var(--surface); }
.badge-grade.bg-warning,
.badge-grade.text-bg-warning { background: var(--warning); color: var(--surface); }
.badge-grade.bg-success,
.badge-grade.text-bg-success { background: var(--success); color: var(--surface); }

/* Bootstrap badge 语义色覆盖 (WCAG AA 强化文字色) */
.bg-primary, .badge.bg-primary { background: var(--accent-soft); color: var(--accent-pressed); }
.bg-success, .badge.bg-success { background: var(--success-soft); color: var(--success-dark); }
.bg-warning, .badge.bg-warning, .text-bg-warning { background: var(--warning-soft); color: var(--warning-dark); }
.bg-danger, .badge.bg-danger { background: var(--danger-soft); color: var(--danger-pressed); }
.bg-info, .badge.bg-info { background: var(--info-soft); color: var(--accent-pressed); }
.bg-secondary, .badge.bg-secondary { background: var(--surface-muted); color: var(--text-secondary); }
.text-bg-light, .bg-light { color: var(--text-secondary); background-color: var(--surface-soft); }

/* === [forms] 表单 === */
.form-control,
.form-select {
    min-height: var(--control-height);
    border-color: var(--surface-border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text-main);
    font-size: var(--fs-sm);
    box-shadow: none;
    transition: border-color var(--motion-fast) var(--easing),
                box-shadow var(--motion-fast) var(--easing);
}
.form-control:hover,
.form-select:hover { border-color: var(--border-strong); }
.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
    outline: 0;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:disabled,
.form-select:disabled {
    background-color: var(--surface-soft);
    color: var(--text-muted);
    cursor: not-allowed;
}
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
}
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}
.invalid-feedback { color: var(--danger); font-size: var(--fs-xs); }

.form-control-sm,
.form-select-sm { min-height: var(--control-height-sm); }

.form-label { color: var(--text-secondary); font-weight: 600; font-size: var(--fs-sm); }
.form-text, small.text-muted { font-size: var(--fs-xs); color: var(--text-faint); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: var(--shadow-focus); }
.form-check-label { font-size: var(--fs-sm); color: var(--text-secondary); }

/* 输入组 */
.input-group-text {
    background: var(--surface-soft);
    border-color: var(--surface-border);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
}

/* === [buttons] 按钮 === */
.btn {
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--fs-sm);
    transition: background var(--motion-fast) var(--easing),
                border-color var(--motion-fast) var(--easing),
                color var(--motion-fast) var(--easing),
                box-shadow var(--motion-fast) var(--easing);
}
.btn:focus-visible { box-shadow: var(--shadow-focus); outline: 0; }

.btn-sm { min-height: var(--control-height-sm); padding: 4px 10px; }

.btn-primary {
    color: var(--surface);
    background: var(--accent);
    border-color: var(--accent);
}
.btn-primary:hover,
.btn-primary:focus {
    color: var(--surface);
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}
.btn-primary:active,
.btn-primary:focus-visible {
    color: var(--surface);
    background: var(--accent-pressed);
    border-color: var(--accent-pressed);
}
.btn-primary:disabled {
    background: var(--accent-line);
    border-color: var(--accent-line);
    opacity: 1;
}

.btn-success { color: var(--surface); background: var(--success); border-color: var(--success); }
.btn-success:hover { background: var(--success-dark); border-color: var(--success-dark); }

.btn-warning { color: var(--surface); background: var(--warning); border-color: var(--warning); }
.btn-warning:hover { background: var(--warning-dark); border-color: var(--warning-dark); }

.btn-outline-primary {
    color: var(--accent);
    background: var(--surface);
    border-color: var(--accent-line);
}
.btn-outline-primary:hover {
    color: var(--surface);
    background: var(--accent);
    border-color: var(--accent);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    background: var(--surface);
    border-color: var(--surface-border);
}
.btn-outline-secondary:hover {
    color: var(--accent);
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.3);
    background: var(--surface);
}
.btn-outline-danger:hover {
    color: var(--surface);
    background: var(--danger);
    border-color: var(--danger);
}

.btn-outline-info {
    color: var(--info);
    background: var(--surface);
    border-color: rgba(37, 99, 235, 0.3);
}
.btn-outline-info:hover {
    color: var(--surface);
    background: var(--info);
    border-color: var(--info);
}

/* === [alerts] 警告框 === */
.alert {
    border-radius: var(--radius-md);
    line-height: var(--lh-relaxed);
    padding: 12px 14px;
    border-width: 1px;
    border-style: solid;
}
.alert-success {
    color: var(--success-darker);
    background: var(--success-soft);
    border-color: rgba(5, 150, 105, 0.25);
}
.alert-warning {
    color: var(--warning-dark);
    background: var(--warning-soft);
    border-color: rgba(217, 119, 6, 0.25);
}
.alert-info {
    color: var(--accent-pressed);
    background: var(--accent-soft);
    border-color: rgba(37, 99, 235, 0.2);
}
.alert-danger {
    color: var(--danger-pressed);
    background: var(--danger-soft);
    border-color: rgba(220, 38, 38, 0.25);
}

/* === [progress] 进度条 === */
.progress { height: 6px; background: var(--surface-muted); border-radius: 999px; overflow: hidden; }
.progress-bar { background: var(--accent); transition: width var(--motion-slow) var(--easing); }

/* === [micro-motion] 微动效 === */
.btn:active:not(:disabled) { transform: translateY(1px); }

@keyframes badge-pop {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}
.nav-badge,
.topbar-notif-dot { animation: badge-pop 200ms var(--easing); }

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.stat-card,
.dashboard-decision-card,
.dashboard-quick-card,
.toolbar-card {
    animation: fade-in-up 240ms var(--easing) both;
}
@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .dashboard-decision-card,
    .dashboard-quick-card,
    .toolbar-card,
    .nav-badge,
    .topbar-notif-dot { animation: none !important; }
}

/* === [nav-pills] 导航 Pills === */
.nav-pills .nav-link { color: var(--text-secondary); border-radius: var(--radius-sm); }
.nav-pills .nav-link.active { color: var(--surface); background: var(--accent); }

/* === [empty-state] 空状态 === */
.empty-chart {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    background: var(--surface-soft);
    border: 1px dashed var(--surface-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
}
.empty-chart::before {
    content: "\F12B";
    font-family: "bootstrap-icons";
    font-size: 1.6rem;
    color: var(--text-faint);
    line-height: 1;
}
.empty-chart > i { font-size: 1.6rem; color: var(--text-faint); }

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-faint);
    font-size: 1.4rem;
}
.empty-state-title {
    color: var(--text-main);
    font-size: var(--fs-base);
    font-weight: 600;
    margin-bottom: 4px;
}

/* === [text-utils] 文字工具类 === */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-dark) !important; }
.text-warning { color: var(--warning-dark) !important; }
.text-danger { color: var(--danger-pressed) !important; }
.text-primary { color: var(--accent-pressed) !important; }
.text-info { color: var(--accent-pressed) !important; }
.text-nowrap-soft { white-space: nowrap; }

/* === [responsive-utils] 通用响应式 === */
@media (max-width: 900px) {
    .page-header,
    .import-hero,
    .trash-page-header { flex-direction: column; align-items: stretch; }
    .page-actions,
    .import-actions { justify-content: flex-start; width: 100%; }
    .toolbar-card, .card-body { padding: 12px; }
}

@media (max-width: 575px) {
    .page-actions .btn,
    .import-actions .btn { width: 100%; }
    .data-table { min-width: 760px; }
    .btn { max-width: 100%; white-space: normal; }
    .stat-card { min-height: 88px; }
}

/* === [bootstrap-brand] Bootstrap 组件品牌统一（Modal / Dropdown / Tooltip）----- */
.modal-content {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.modal-header {
    border-bottom-color: var(--surface-border);
    padding: 14px 18px;
}

.modal-footer {
    border-top-color: var(--surface-border);
    padding: 12px 18px;
    gap: 8px;
}

.modal-title { color: var(--text-main); font-weight: 700; }

.dropdown-menu {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    transition: background var(--motion-fast) var(--easing), color var(--motion-fast) var(--easing);
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: var(--accent-pressed);
    background: var(--accent-soft);
}

.dropdown-item.active,
.dropdown-item:active { color: var(--surface); background: var(--accent); }

.dropdown-divider {
    margin: 4px 0;
    border-top-color: var(--surface-border);
}

.tooltip-inner {
    border-radius: var(--radius-sm);
    background: var(--text-main);
    font-size: var(--fs-xs);
}
