/* 全电发票管理系统 - 自定义样式 */

:root {
    --primary-color: #2563eb;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --info-color: #0891b2;
    --bg-light: #f8fafc;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

body { font-family: -apple-system, "Microsoft YaHei", "Segoe UI", Roboto, sans-serif; }

/* 数字等宽字体 */
.num { font-family: "SF Mono", "Consolas", "Courier New", monospace; font-variant-numeric: tabular-nums; }

/* 指标卡片 */
.stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.stat-card .stat-value {
    font-size: 1.6rem; font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* 表格 */
.table-hover tbody tr:hover { background-color: #f1f5f9; }
.dataTables_wrapper { padding: 0; }
.dataTables_filter { display: none; } /* 用自定义筛选 */
.table th { font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }

/* 状态标签 */
.badge-status-normal { background: #16a34a; color: #fff; }
.badge-status-red { background: #dc2626; color: #fff; }
.badge-status-reded { background: #f97316; color: #fff; }
.badge-payment-paid { background: #16a34a; color: #fff; }
.badge-payment-unpaid { background: #dc2626; color: #fff; }
.badge-payment-partial { background: #d97706; color: #fff; }
.badge-payment-pending { background: #6b7280; color: #fff; }
.badge-payment-ignore { background: rgba(128,128,128,0.1); color: #374151; }

/* 金额: 正数红色(涨),负数绿色(跌) - 中国习惯 */
.amount-positive { color: #dc2626; font-weight: 600; }
.amount-negative { color: #16a34a; font-weight: 600; }
.amount-zero { color: #6b7280; }

/* 筛选栏 */
.filter-bar {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--card-shadow);
}
.filter-bar .form-group { margin-bottom: 0.5rem; }

/* 图表容器 */
.chart-container {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 16px;
}
.chart-container canvas { max-height: 400px; }
/* 公司贡献度图表:12家公司需更大高度 */
.chart-seller-wrapper { position: relative; height: 380px; }

/* 内容区动画 */
.content-wrapper { background: var(--bg-light); }
#content-wrapper { min-height: calc(100vh - 56px - 50px); padding: 16px 24px; }

/* 空状态 */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state i { font-size: 4rem; margin-bottom: 16px; }

/* Select2 美化 */
.select2-container--default .select2-selection--single {
    height: 38px; border-radius: 6px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
}

/* 时间线 */
.timeline { list-style: none; padding: 0; }
.timeline-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #e2e8f0; }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }

/* 加载动画 */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.8); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.loading-spinner {
    width: 50px; height: 50px; border: 4px solid #e2e8f0;
    border-top: 4px solid var(--primary-color); border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }

/* 侧边栏品牌 */
.brand-link { background: #1e293b !important; color: #fff; }

/* 登录页 */
.login-page { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 400px; max-width: 90%; }
.login-card { border-radius: 16px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }

/* 发票列表：发票内容/备注 单元格（横向滚动下列内省略，悬停看全文） */
.inv-cell-text {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.login-logo { text-align: center; margin-bottom: 24px; color: #fff; font-size: 1.5rem; font-weight: 700; }

/* ===== 发票管理：整页冻结布局 =====
   做法：页面正常流式排版，仅表格体内部滚动(scrollY 由 JS 动态计算)；
   再用 body overflow:hidden 锁住整页滚动，使表头/翻页固定、翻页贴底。
   不依赖 flex/绝对定位撑高度，避免与 DataTables/AdminLTE 边距打架产生空白。 */
body.invoices-frozen-active { overflow: hidden; }

/* 仅中和会撑出底部空隙的少量外边距，让翻页能贴到页脚上方(无空白) */
.invoices-frozen-active #content-wrapper { padding-bottom: 0 !important; }
.invoices-frozen .card { margin-bottom: 0 !important; }
.invoices-frozen .inv-table-area { width: 100%; }

/* 关键：DataTables 初始化时按 scrollY(占位300) 在 scrollBody 上写了 inline max-height:300px，
   之后 fixLayout 只改 height 不改 max-height，导致真实高度被 300px 卡住 → 卡片远低于视口 → 底部大片空白。
   这里用 !important 彻底中和该上限，让 JS 算出的 height 真正生效。 */
.invoices-frozen .dataTables_scrollBody { max-height: none !important; }

/* 滚动条美化（表格体内部） */
.invoices-frozen .dataTables_scrollBody::-webkit-scrollbar { width: 10px; height: 10px; }
.invoices-frozen .dataTables_scrollBody::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 5px; }
.invoices-frozen .dataTables_scrollBody::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); }

/* ===== 导航栏可拖拽排序 ===== */
.nav-sidebar .nav-item { cursor: grab; }
.nav-sidebar .nav-item:active { cursor: grabbing; }
.nav-sidebar .nav-item.nav-dragging { opacity: 0.45; }
.nav-sidebar .nav-item.nav-drop-before,
.nav-sidebar .nav-item.nav-drop-after { background: rgba(0,123,255,0.14); }
.nav-sidebar .nav-item.nav-drop-before > .nav-link { box-shadow: inset 0 3px 0 0 #007bff; }
.nav-sidebar .nav-item.nav-drop-after  > .nav-link { box-shadow: inset 0 -3px 0 0 #007bff; }
.nav-sidebar .nav-link { user-select: none; }
