/* ============================================
   暗色模式 - 适用于 Bootstrap 5.1.3
   通过 <link disabled> 切换，无data-bs-theme依赖
   ============================================ */

/* 基础底色 */
html, body { background-color: #1a1d23 !important; color: #c9d1d9 !important; }

/* 顶部导航 */
.navbar.bg-white, .top-navbar { background-color: #21262d !important; border-bottom: 1px solid #30363d !important; }
.navbar-light .navbar-brand, .navbar-light .navbar-nav .nav-link { color: #c9d1d9 !important; }
.text-muted { color: #8b949e !important; }

/* 侧边栏 */
.sidebar { background-color: #161b22 !important; border-right: 1px solid #30363d !important; }
.sidebar .sidebar-header { background-color: #161b22 !important; border-bottom: 1px solid #30363d !important; }
.sidebar .nav-link { color: #c9d1d9 !important; }
.sidebar .nav-link:hover { background-color: #21262d !important; color: #58a6ff !important; }
.sidebar .nav-link.active { background-color: #1f6feb22 !important; color: #58a6ff !important; border-left: 3px solid #58a6ff; }
.sidebar .sidebar-user-info { border-bottom: 1px solid #30363d !important; color: #c9d1d9 !important; }
.sidebar .sidebar-user-info small { color: #8b949e !important; }

/* 卡片 */
.card, .card.shadow-sm { background-color: #21262d !important; border-color: #30363d !important; color: #c9d1d9 !important; }
.card-header { background-color: #161b22 !important; border-bottom-color: #30363d !important; color: #c9d1d9 !important; }
.card-body { background-color: #21262d !important; color: #c9d1d9 !important; }
.card-footer { background-color: #161b22 !important; border-top-color: #30363d !important; }

/* 表格 */
.table { color: #c9d1d9 !important; border-color: #30363d !important; }
.table thead th { background-color: #161b22 !important; border-bottom-color: #30363d !important; color: #c9d1d9 !important; }
.table tbody td { background-color: #21262d !important; border-color: #30363d !important; }
.table-striped tbody tr:nth-of-type(odd) td { background-color: #1c2128 !important; }
.table-hover tbody tr:hover td { background-color: #292e36 !important; }
.table-bordered th, .table-bordered td { border-color: #30363d !important; }

/* DataTables 覆盖 */
.dataTables_wrapper { color: #c9d1d9 !important; }
.dataTables_wrapper .dataTables_length select, 
.dataTables_wrapper .dataTables_filter input { 
    background-color: #161b22 !important; color: #c9d1d9 !important; 
    border: 1px solid #30363d !important; 
}
.page-link { background-color: #21262d !important; border-color: #30363d !important; color: #c9d1d9 !important; }
.page-item.active .page-link { background-color: #1f6feb !important; border-color: #1f6feb !important; }
.page-item.disabled .page-link { background-color: #161b22 !important; color: #484f58 !important; }

/* 表单 */
.form-control, .form-select, .input-group-text { 
    background-color: #161b22 !important; border-color: #30363d !important; color: #c9d1d9 !important; 
}
.form-control:focus, .form-select:focus { 
    background-color: #161b22 !important; border-color: #58a6ff !important; 
    box-shadow: 0 0 0 2px rgba(88,166,255,0.3) !important; color: #c9d1d9 !important; 
}
.form-control::placeholder { color: #484f58 !important; }
.form-label { color: #c9d1d9 !important; }
.form-text { color: #8b949e !important; }
.form-check-input { background-color: #21262d !important; border-color: #30363d !important; }

/* 按钮 - outline 系列调整 */
.btn-outline-secondary { color: #8b949e !important; border-color: #30363d !important; }
.btn-outline-secondary:hover { background-color: #30363d !important; color: #c9d1d9 !important; }

/* 列表组 */
.list-group-item { background-color: #21262d !important; border-color: #30363d !important; color: #c9d1d9 !important; }
.list-group-item-action:hover { background-color: #292e36 !important; color: #c9d1d9 !important; }
.list-group-item-action.active { background-color: #1f6feb !important; border-color: #1f6feb !important; }
.list-group-item-action:focus { background-color: #292e36 !important; color: #c9d1d9 !important; }
.list-group-item.disabled { color: #484f58 !important; background-color: #21262d !important; }

/* 下拉菜单 */
.dropdown-menu { background-color: #21262d !important; border-color: #30363d !important; }
.dropdown-item { color: #c9d1d9 !important; }
.dropdown-item:hover, .dropdown-item:focus { background-color: #292e36 !important; color: #c9d1d9 !important; }
.dropdown-divider { border-top-color: #30363d !important; }
.dropdown-header { color: #8b949e !important; }

/* 模态框 */
.modal-content { background-color: #21262d !important; border-color: #30363d !important; }
.modal-header { border-bottom-color: #30363d !important; }
.modal-footer { border-top-color: #30363d !important; }
.btn-close { filter: invert(0.8) !important; }

/* Toast */
.toast { background-color: #21262d !important; border-color: #30363d !important; }
.toast-header { background-color: #161b22 !important; border-bottom-color: #30363d !important; color: #c9d1d9 !important; }

/* 导航标签/页签 */
.nav-tabs { border-bottom-color: #30363d !important; }
.nav-tabs .nav-link { color: #8b949e !important; }
.nav-tabs .nav-link:hover { border-color: #30363d; }
.nav-tabs .nav-link.active { background-color: #21262d !important; border-color: #30363d #30363d transparent !important; color: #c9d1d9 !important; }
.nav-pills .nav-link { color: #8b949e !important; }
.nav-pills .nav-link.active { background-color: #1f6feb !important; }

/* 面包屑 */
.breadcrumb { background-color: transparent !important; }
.breadcrumb-item a { color: #58a6ff !important; }
.breadcrumb-item.active { color: #8b949e !important; }

/* 告警 */
.alert { background-color: #21262d !important; border-color: #30363d !important; }
.alert-primary { background-color: #0c2d6b !important; border-color: #1f6feb !important; color: #58a6ff !important; }
.alert-success { background-color: #0e3a1a !important; border-color: #238636 !important; color: #3fb950 !important; }
.alert-danger { background-color: #3d1111 !important; border-color: #da3633 !important; color: #f85149 !important; }
.alert-warning { background-color: #3d2e00 !important; border-color: #d29922 !important; color: #d29922 !important; }
.alert-info { background-color: #0c2d6b !important; border-color: #1f6feb !important; color: #58a6ff !important; }

/* 徽章 - 调整深色背景上的文字颜色 */
.badge.bg-light { background-color: #30363d !important; color: #c9d1d9 !important; }

/* 进度条 */
.progress { background-color: #30363d !important; }
.progress-bar { background-color: #1f6feb !important; }

/* 分页 */
.pagination { --bs-pagination-bg: #21262d; --bs-pagination-border-color: #30363d; --bs-pagination-color: #c9d1d9; --bs-pagination-hover-bg: #30363d; --bs-pagination-hover-color: #c9d1d9; --bs-pagination-focus-bg: #30363d; --bs-pagination-disabled-bg: #161b22; --bs-pagination-disabled-color: #484f58; --bs-pagination-active-bg: #1f6feb; --bs-pagination-active-border-color: #1f6feb; }

/* 代码块 */
code { color: #f85149 !important; background-color: #161b22 !important; padding: 2px 4px; border-radius: 4px; }
pre { background-color: #161b22 !important; border: 1px solid #30363d !important; color: #c9d1d9 !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #161b22; }
::-webkit-scrollbar-thumb { background: #484f58; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6e7681; }

/* 文本颜色强化 */
.text-dark { color: #c9d1d9 !important; }
.text-body { color: #c9d1d9 !important; }
.link-dark { color: #c9d1d9 !important; }
.link-dark:hover { color: #58a6ff !important; }
a { color: #58a6ff !important; }
a:not(.btn):not(.nav-link):not(.dropdown-item):hover { color: #79c0ff !important; }

/* 网格栈 Widget (dashboard) */
.grid-stack-item .card { border-color: #30363d !important; }

/* Flatpickr 暗色 */
.flatpickr-calendar { background: #21262d !important; border-color: #30363d !important; }
.flatpickr-months .flatpickr-month, 
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekdays,
span.flatpickr-weekday { background: #161b22 !important; color: #c9d1d9 !important; }
.flatpickr-day { color: #c9d1d9 !important; }
.flatpickr-day.today { border-color: #58a6ff !important; }
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange { 
    background: #1f6feb !important; border-color: #1f6feb !important; 
}
.flatpickr-day:hover { background: #30363d !important; }
.flatpickr-day.inRange { background: #1f6feb44 !important; border-color: transparent !important; }
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: #c9d1d9 !important; }
.flatpickr-current-month input.cur-year { color: #c9d1d9 !important; }

/* 安全承诺横幅 - 暗色保持红色渐变 */
[style*="background: linear-gradient(135deg, #991b1b"] { filter: brightness(0.9) !important; }

/* 安全天数 box */
.safe-days-box.green { filter: brightness(0.9) !important; }
.safe-days-box.yellow { filter: brightness(0.85) !important; }
.safe-days-box.red { filter: brightness(0.85) !important; }
