/* 全站公共补充样式（M1），所有页面共用 */

/* 页面基础：顶栏自带底边，无需顶部留白 */
body {
  padding-top: 0;
}

/* 记录表格字号略小，提升密度 */
.draws-table {
  font-size: 0.875rem;
}

/* 给表格最小宽度，触发 table-responsive 横向滚动，避免手机端列被压缩导致文字逐字换行。
   900px 是权衡值：9~13 列宽表在手机（≈390px）下各列仍有足够宽度放短字段不换行。 */
.table-responsive > .table {
  min-width: 900px;
}

/* 3 列以内的小表（如仪表盘账号健康表）不套用宽表 min-width，按内容自适应，避免列被拉宽 */
.table-responsive > .table.table-fit {
  min-width: auto;
}

/* 长 token 列（openid / URL / JSON / AppSecret / 任务ID 等无空格长串）：
   限宽并允许任意位置断行，避免长串把整张表撑得过宽，也不至于把相邻列挤扁。 */
.cell-token {
  max-width: 240px;
  word-break: break-all;
}

/* 标题类列的最小宽度（原写死在 alert_list 内联样式里，抽成通用类）：
   保证标题列有基本宽度，不会逐字换行。 */
.cell-title {
  min-width: 16rem;
}

/* 登录卡片限制宽度 */
.card {
  max-width: 100%;
}

/* 手机端：筛选表单纵向堆叠时按钮全宽 */
@media (max-width: 767.98px) {
  .filter-bar .btn {
    margin-top: 0.5rem;
  }
}

/* 发布批次 unknown 状态徽章：紫色加粗（提示需人工处置，M3） */
.badge.badge-unknown {
  background-color: #6f42c1;
  color: #fff;
  font-weight: 700;
}

/* 表格勾选列固定窄宽（死信表 / 告警表通用） */
.col-check {
  width: 36px;
}

/* 统一死信表格：失败原因列限制宽度，超长换行 */
.deadletter-table .cell-reason {
  max-width: 220px;
}

/* 审计日志"变更详情"列用了 text-nowrap，会让内部 <pre> 继承 nowrap；
   这里在 <pre> 上恢复 white-space: pre，保证展开后 JSON 仍是格式化换行 */
.audit-detail pre {
  white-space: pre !important;
}

/* 统一死信表格：已重放时间小字 */
.deadletter-table .replayed-at {
  font-size: 11px;
}

/* 仪表盘（M5 E） */
/* 健康卡片：标题小灰字 + 紧凑正文 */
.dashboard-card .dashboard-card-title {
  font-size: 0.8rem;
  color: #6c757d;
  margin-bottom: 0.35rem;
}

.dashboard-card .dashboard-card-body {
  font-size: 0.85rem;
  line-height: 1.45;
}

/* 卡片内迷你进度条（宽度由 JS 通过 --pct 变量驱动，避免内联样式） */
.dashboard-mini-progress {
  height: 6px;
  margin-top: 0.3rem;
}

.dashboard-mini-progress .progress-bar {
  width: var(--pct, 0%);
}

/* 心跳灯：圆点，在线绿 / 离线红 */
.lamp {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: middle;
}

.lamp-on {
  background-color: #198754;
  box-shadow: 0 0 0 2px rgba(25, 135, 84, 0.2);
}

.lamp-off {
  background-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

/* 账号健康表 Token 列固定窄宽 */
.col-token {
  width: 80px;
}

/* ============================================================
   后台框架布局：顶部条 + 左侧边栏 + 主内容区（桌面常驻 / 手机抽屉）
   ============================================================ */

/* 顶部条：始终常驻，白底带底边框 */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 0 .75rem 0 1rem;
  background-color: #fff;
  border-bottom: 1px solid #dee2e6;
}

.app-brand {
  font-size: 1.05rem;
  font-weight: 600;
  color: #212529;
  text-decoration: none;
  white-space: nowrap;
}

.app-brand:hover {
  color: #0d6efd;
}

.app-user-link {
  color: #495057;
  font-size: .9rem;
  text-decoration: none;
  white-space: nowrap;
}

.app-user-link:hover {
  color: #0d6efd;
  text-decoration: underline;
}

/* 外层 flex 容器：align-items:flex-start 保证侧栏 sticky 生效 */
.app-shell {
  align-items: flex-start;
  min-height: calc(100vh - 56px);
}

/* 侧栏双形态公共样式（深色底）；手机抽屉宽度 260px。
   注意：Bootstrap 响应式 offcanvas 在大屏会强制 transparent !important，
   这里必须同级 !important 才能保住深色底。 */
.app-sidebar {
  background-color: #1e293b !important;
  color: #cbd5e1;
  --bs-offcanvas-width: 260px;
}

.app-sidebar .offcanvas-header {
  background-color: #1e293b;
  color: #e2e8f0;
}

.app-sidebar .offcanvas-body {
  padding: 0;
  overflow-y: auto;
}

/* 菜单分组标题 */
.sidebar-group-title {
  padding: 1rem 1rem .35rem;
  font-size: .72rem;
  letter-spacing: .06em;
  color: #64748b;
}

/* 菜单项 */
.sidebar-link {
  display: block;
  padding: .5rem 1rem;
  margin: 1px .5rem;
  border-radius: .375rem;
  color: #cbd5e1;
  font-size: .9rem;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, .09);
  color: #fff;
}

.sidebar-link.active {
  background-color: #0d6efd;
  color: #fff;
  font-weight: 600;
}

/* 桌面（>=992px）：侧栏常驻、独立纵向滚动，主内容占满剩余宽度。
   说明：本项目 Bootstrap 5.3.3 构建的 .offcanvas-lg 大屏块只做了透明化，
   未覆盖基类的 visibility:hidden / transform:translateX(-100%)，
   因此这里必须显式恢复可见与归位（小屏抽屉行为不受影响）。 */
@media (min-width: 992px) {
  #appSidebar {
    position: sticky;
    top: 56px;
    width: 220px;
    flex: 0 0 220px;
    height: calc(100vh - 56px);
    visibility: visible !important;
    transform: none !important;
    z-index: 1000;
    border-right: 1px solid rgba(255, 255, 255, .12);
  }

  /* 覆盖 Bootstrap 响应式 offcanvas 大屏默认（display:flex; flex-grow:0），
     使菜单容器纵向撑满并自行滚动 */
  #appSidebar .offcanvas-body {
    flex-direction: column;
    flex-grow: 1;
  }

  .sidebar-nav {
    width: 100%;
  }
}

/* 主内容区：允许收缩，防止宽表格撑破 flex 布局 */
.app-main {
  min-width: 0;
}

/* ============================================================
   配置中心：分组 tab（桌面左侧纵向，手机横向滚动）
   ============================================================ */
.settings-tabs {
  gap: .25rem;
}

.settings-tabs .nav-link {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .settings-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: .25rem;
  }

  .settings-tabs .nav-link {
    flex: 0 0 auto;
  }
}

@media (min-width: 992px) {
  .settings-tabs .nav-link {
    width: 100%;
    text-align: left;
  }
}

/* 顶栏汉堡按钮图标：.navbar-toggler-icon 的背景图变量在 Bootstrap 5.3.3 中
   只定义在 .navbar 作用域内，而本项目顶栏是自建 .app-topbar（无 .navbar 祖先），
   导致变量未定义、图标空白。此处显式提供官方亮色黑灰杠 SVG（与 .navbar 内一致），
   适配白底顶栏。 */
.app-topbar .navbar-toggler-icon {
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* 审计日志：变更详情 <pre> 长文本横向滚动，避免撑破手机屏幕。
   全局规则安全：pre 仅用于审计页（audit_list.html L69/L73，全模板 grep 确认）。 */
pre {
  overflow-x: auto;
}

/* 内容详情：正文长图等比缩放，避免原图宽（750~1080px）溢出手机屏幕。
   正文容器为 content_detail.html L25 的 .article-body，长图 img 由
   default_templates.py 生成、无内联宽度约束，在此兜底。 */
.article-body img {
  max-width: 100%;
  height: auto;
}
