/* 管理后台通用样式 */
body {
    background-color: #f8f9fa;
    font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 仅在表格自适应模式下防止页面滚动 */
body.auto-fit-table {
    overflow: hidden;
    height: 100vh;
}

html {
    height: 100%;
}

/* 导航栏样式 */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.navbar-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    border-radius: 0.75rem 0.75rem 0 0 !important;
    padding: 1rem 1.25rem;
}

/* 统计卡片样式 */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning {
    border: none;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #4c84ff 100%);
}

.card.bg-success {
    background: linear-gradient(135deg, var(--bs-success) 0%, #20c997 100%);
}

.card.bg-info {
    background: linear-gradient(135deg, var(--bs-info) 0%, #17a2b8 100%);
}

.card.bg-warning {
    background: linear-gradient(135deg, var(--bs-warning) 0%, #fd7e14 100%);
}

/* 按钮样式 */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* 快速操作按钮 */
.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-info:hover,
.btn-outline-warning:hover,
.btn-outline-secondary:hover,
.btn-outline-dark:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.375rem 0.75rem rgba(0, 0, 0, 0.15);
}

/* 表格样式 */
.table {
    border-radius: 0.5rem;
    overflow: hidden;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

/* 在自适应模式下让表头始终可见（仅滚动表体） */
body.auto-fit-table .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 分页样式 */
.pagination .page-link {
    border-radius: 0.375rem;
    margin: 0 0.125rem;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

.pagination .page-link:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* 表单样式 */
.form-control,
.form-select {
    border-radius: 0.5rem;
    border: 1px solid #ced4da;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* 模态框样式 */
.modal-content {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    border-radius: 0.75rem 0.75rem 0 0;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 0.75rem 0.75rem;
}

/* 徽章样式 */
.badge {
    font-size: 0.75em;
    font-weight: 500;
    border-radius: 0.375rem;
}

/* 状态徽章 */
.badge.status-new {
    background-color: #0d6efd;
}

.badge.status-contacted {
    background-color: #6f42c1;
}

.badge.status-qualified {
    background-color: #20c997;
}

.badge.status-converted {
    background-color: #198754;
}

.badge.status-lost {
    background-color: #dc3545;
}

/* 搜索框样式 */
.search-box {
    position: relative;
}

.search-box .form-control {
    padding-left: 2.5rem;
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 5;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        font-size: 0.875rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* 工具提示样式 */
.tooltip {
    font-size: 0.875rem;
}

.tooltip-inner {
    background-color: #212529;
    border-radius: 0.375rem;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 时间线样式 */
.timeline {
    position: relative;
    margin: 0.5rem 0 0 0.5rem;
    padding-left: 1.5rem;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e9ecef;
}
.timeline-item {
    position: relative;
    margin-bottom: 1rem;
}
.timeline-marker {
    position: absolute;
    left: -7px;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}
.timeline-content {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
}

/* 页面无滚动模式样式 - 仅在需要时应用 */
.no-page-scroll .container-fluid {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.no-page-scroll .main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 表格容器自适应高度样式 */
.auto-fit-table .table-container,
.auto-fit-table .table-responsive {
    overflow: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    -webkit-overflow-scrolling: touch; /* 移动端惯性滚动 */
}

/* 移动端覆盖：避免 body 禁止滚动导致子容器无法滚动（iOS Safari 特性） */
@media (max-width: 576px) {
    body.auto-fit-table {
        overflow-y: auto !important;
        height: auto !important;
    }
}

/* 分页容器样式优化 */
.auto-fit-table #pagination {
    flex-shrink: 0;
    margin-top: 1rem;
    padding: 0.5rem 0;
}

.timeline-content {
    padding: 0.75rem 1rem;
}
.timeline-time {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}
/* 页面工具栏（搜索/操作）样式：防止按钮文字折行并保持单行布局 */
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}
.toolbar-actions .btn {
    white-space: nowrap;
    flex-shrink: 0;
}
.toolbar-actions .form-control,
.toolbar-actions .form-select {
    width: 220px;
    max-width: 100%;
}

/* 小屏幕下的工具栏微调 */
@media (max-width: 576px) {
    .toolbar-actions {
        gap: 0.25rem;
    }
    .toolbar-actions .form-control,
    .toolbar-actions .form-select {
        width: 180px;
    }
}

/* 移动端通用优化与工具类 */
/* 让按钮工具栏在移动端自动换行并保持紧凑 */
.btn-toolbar,
.btn-group {
    flex-wrap: wrap;
}

@media (max-width: 576px) {
    .btn-group .btn,
    .btn-toolbar .btn {
        margin-bottom: 0.25rem;
    }
    /* 紧凑型卡片与表格排版，减小内边距提高信息密度 */
    .card-body {
        padding: 0.75rem;
    }
    .table-responsive {
        /* 避免过小字号影响可读性，保持 14px 左右视觉效果 */
        font-size: 0.9rem;
    }
    /* 行内选项在小屏幕改为堆叠显示，提高点击区域 */
    .form-check-inline {
        display: block;
        margin-right: 0;
    }
    .form-check-inline + .form-check-inline {
        margin-top: 0.25rem;
    }
}

/* 内容截断工具类：在移动端避免表格列过宽影响布局 */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 可选：为需要固定底部操作区的页面提供辅助类 */
.fixed-bottom-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 0.5rem 1rem;
}

/* 页面标题与动作区域在移动端堆叠显示（动作放到标题下） */
@media (max-width: 576px) {
    /* renderPageHeader 渲染的结构：.row > .col > .d-flex ... */
    .sticky-page-header .row .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    /* 让动作区域占满一行并自动换行 */
    .sticky-page-header .col-auto {
        width: 100%;
    }
    .sticky-page-header .col-auto .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}