/* ==========================================================================
   SaaS 级顶部控制导航 (Control Dock) 与响应式自适应布局
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: var(--line-height);
  font-size: var(--font-base);
  -webkit-font-smoothing: antialiased;
  padding-top: 0; /* 采用 sticky 粘性自适应，取消固定高度 padding 避免遮挡 */
  padding-bottom: 80px;
}

/* 顶部控制栏 - 采用 sticky 粘性定位，高弹性响应式自适应，换行自动向下推流 */
.top-dock {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.03);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 24px;
  gap: 10px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  transition: all 0.2s ease;
}

.dock-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dock-center {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  flex: 1 1 auto;
  justify-content: center;
}

.dock-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  flex-shrink: 0;
  /* 空间不足换到第二行时，操作按钮仍靠右对齐，避免挤在左侧 */
  margin-left: auto;
}

.dock-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.dock-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.dock-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.dock-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: #f1f5f9;
  color: #475569;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

/* 控件样式 */
.control-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}

.select-custom {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 12.5px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  outline: none;
  max-width: 260px;
  transition: all 0.2s;
}
.select-custom:hover, .select-custom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* 主题颜色选择盘 */
.theme-palette {
  display: flex;
  gap: 6px;
  align-items: center;
}
.theme-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #cbd5e1;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.theme-dot:hover {
  transform: scale(1.18);
}
.theme-dot.active {
  box-shadow: 0 0 0 2.5px var(--accent);
  transform: scale(1.18);
}

/* 按钮通用 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-outline {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}
.btn-danger {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}
.btn-danger:hover {
  background: #fee2e2;
}
.btn:disabled,
.btn:disabled:hover {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* 退出登录：轻量图标按钮，不争夺「一键下载 PDF」的视觉主导 */
.dock-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  margin-left: -2px;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.dock-logout:hover {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

/* 顶部「使用说明」入口：复用退出按钮的轻量尺寸，悬停走主色而非红色 */
.dock-help {
  text-decoration: none;
  margin-left: 0;
}
.dock-help:hover {
  color: var(--primary);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.dock-logout:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

/* 状态指示徽标 */
.save-status-badge {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #10b981;
  font-weight: 500;
  background: #ecfdf5;
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid #a7f3d0;
  white-space: nowrap;
}

/* ==========================================================================
   响应式断点控制 (彻底解决缩小时拥挤、换行错位问题)
   ========================================================================== */

/* 屏幕宽度在 1200px 以下：优化字距与次要标识 */
@media (max-width: 1200px) {
  .dock-tag {
    display: none;
  }
  .top-dock {
    padding: 8px 16px;
    gap: 8px 12px;
  }
  .dock-center {
    gap: 8px 12px;
  }
  .select-custom {
    max-width: 220px;
  }
}

/* 屏幕宽度在 980px 以下：优雅两行化排版 */
@media (max-width: 980px) {
  .top-dock {
    justify-content: space-between;
  }
  .dock-left {
    order: 1;
  }
  .dock-right {
    order: 2;
  }
  .dock-center {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    padding-top: 6px;
    border-top: 1px dashed #e2e8f0;
  }
}

/* 屏幕宽度在 680px 以下 (手机端或超小窗口) */
@media (max-width: 680px) {
  .top-dock {
    padding: 8px 12px;
  }
  .dock-title {
    font-size: 14px;
  }
  /* 手机端左上品牌区与右侧按钮同处一行时，右侧按钮组原本 flex-shrink:0，
     会把内容顶出屏幕（390px 下溢出 79px）。这里放开收缩，让按钮自己换行。 */
  .dock-right {
    gap: 6px;
    flex-shrink: 1;
    min-width: 0;
    justify-content: flex-end;
  }
  .dock-left {
    flex-shrink: 1;
    min-width: 0;
  }
  .btn {
    padding: 5px 8px;
    font-size: 12px;
  }
  .dock-center {
    gap: 8px;
  }
  .control-item label, .control-item span {
    font-size: 12px;
  }
  .select-custom {
    max-width: 160px;
    font-size: 12px;
  }
}

/* 模态弹窗样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}
.modal-box {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: modalSlide 0.2s ease-out;
}
@keyframes modalSlide {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
}
.modal-close:hover {
  color: #0f172a;
}
.modal-body {
  padding: 20px 24px;
  max-height: 65vh;
  overflow-y: auto;
}
.modal-footer {
  padding: 14px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 模块显隐管理列表 */
.section-switch-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section-switch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}
.switch-label {
  font-weight: 600;
  font-size: 13.5px;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 24px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}
input:checked + .switch-slider {
  background-color: var(--accent);
}
input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* PDF 生成进度遮罩 (导出期间覆盖全屏，避免看到排版舞台) */
.pdf-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pdf-mask.active {
  display: flex;
}
.pdf-mask-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 26px 34px;
  min-width: 280px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}
.pdf-mask-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: pdfSpin 0.8s linear infinite;
}
@keyframes pdfSpin {
  to { transform: rotate(360deg); }
}
.pdf-mask-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}
.pdf-mask-sub {
  font-size: 12px;
  color: #64748b;
}

/* 快捷 Toast 消息 */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 99999;
  display: none;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
