/* ========================================
   通用组件：按钮、表单、下拉、toast、modal、spinner、空状态、
   微信分段器（.wx-seg）、微信 cell 列表（.wx-cell）
   2026-09-10 微信风 H5 重构：按钮/弹窗/Toast 换肤，新增 wx-* 组件样式
   （--color-mask / --color-danger-border / --color-tabbar-inactive
   已收编进 tokens.css，本文件一律引用变量）
   ======================================== */

/* ---- 按钮基座 ---- */
button {
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
  position: relative;
}

button:active { transform: scale(0.975); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* 微信主按钮：实心绿、白字、44px 高 */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 9px 18px;
  background: var(--color-brand);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  letter-spacing: -0.01em;
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--color-brand-strong);
  box-shadow: none;
  transform: none;
  filter: none;
}
.btn-primary:active { background: var(--color-brand-strong); }
.btn-primary svg { width: 16px; height: 16px; flex-shrink: 0; }

/* 微信次按钮：白底、灰描边、深色文字 */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover {
  background: var(--wx-pressed);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}
.btn-secondary:active { background: var(--wx-pressed); }
.btn-secondary svg { width: 16px; height: 16px; flex-shrink: 0; }

/* 语义色按钮：与主按钮同尺寸规格，仅换语义色 */
.btn-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--color-warning);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}

.btn-warning:hover {
  filter: brightness(1.06);
  box-shadow: none;
}
.btn-warning:active { background: var(--color-warning); filter: brightness(0.96); }
.btn-warning svg { width: 16px; height: 16px; }

/* 定时执行开关：与「失败续做」同构，用信息蓝区分（执行全部=金 / 续做=琥珀 / 定时=蓝） */
.btn-schedule {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--color-info);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}
.btn-schedule:hover { filter: brightness(1.08); }
.btn-schedule.active {
  background: var(--color-success);
  box-shadow: var(--shadow-sm);
}
.btn-schedule svg { width: 16px; height: 16px; }

.btn-icon {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { background: var(--color-brand-subtle); color: var(--color-text-primary); }
.btn-icon svg { width: 18px; height: 18px; }

.btn-icon-sm {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm:hover { background: var(--color-brand-subtle); color: var(--color-text-primary); }
.btn-icon-sm svg { width: 16px; height: 16px; }

/* 微信警示按钮：白底红字、浅红描边 */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
  font-weight: 500;
  font-size: 0.8rem;
  border-radius: var(--radius-md);
}

.btn-danger:hover {
  background: var(--color-danger-subtle);
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.btn-danger:active { background: var(--color-danger-subtle); }

/* 危险图标按钮（删除大类/小类） */
.btn-icon-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-icon-danger svg { width: 16px; height: 16px; }

.btn-icon-danger:hover:not(:disabled) {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
}

.btn-icon-danger:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--color-success-subtle);
  color: var(--color-success);
  font-weight: 500;
  font-size: 0.8rem;
  border-radius: var(--radius-md);
}

.btn-success:hover { background: var(--color-success); color: #fff; }

/* ---- 表单 ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-field.span-2 { grid-column: span 2; }

.form-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.field-header label { margin-bottom: 0; }

.field-header .btn-secondary {
  padding: 4px 10px;
  font-size: 0.75rem;
  gap: 4px;
}

.field-header .btn-secondary svg { width: 14px; height: 14px; }

.form-field label .required { color: var(--color-danger); }

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  outline: none;
}

.form-field input:hover,
.form-field textarea:hover,
.form-field select:hover {
  border-color: var(--color-border-strong);
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  background: var(--color-surface);
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.form-field textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.55;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--color-text-muted);
}

.input-with-icon { position: relative; }

.input-with-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.form-field .input-with-icon input { padding-left: 38px; }

/* ---- 自定义下拉面板（替代 datalist） ---- */
.dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  max-height: 224px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
}

.dropdown-panel.open { display: block; }

.dropdown-panel .dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--color-text-primary);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-panel .dropdown-item:hover {
  background: var(--color-brand-subtle);
  color: var(--color-brand-strong);
}

.dropdown-panel .dropdown-item.active {
  background: var(--color-brand-subtle);
  color: var(--color-brand-strong);
  font-weight: 600;
}

.dropdown-panel .dropdown-empty {
  padding: 12px 14px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* dropdown-trigger 作为定位父容器 */
.dropdown-trigger { position: relative; }

/* ---- secCode 实时联想面板（2026-08-26 实时联想计划 T6）----
   复用 .dropdown-panel/.dropdown-item 交互与视觉；差异点：
   - 挂在 .task-item-header 下（定位父容器），面板宽度限制避免撑满整卡
   - header 是 flex 行，panel 绝对定位不影响布局 */
.task-item-header { position: relative; }

.seccode-suggest-panel {
  left: 0;
  right: auto;
  width: 340px;
  max-width: 90%;
  white-space: normal;
}

.input-with-suffix { position: relative; }
.form-field .input-with-suffix input { padding-right: 40px; }

.input-suffix-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-suffix-btn:hover { background: var(--color-brand-subtle); color: var(--color-brand); }
.input-suffix-btn svg { width: 16px; height: 16px; }

/* ---- 并发步进器 ---- */
.concurrency-control {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface-sunken);
}

.concurrency-control input {
  width: 50px;
  text-align: center;
  border: none !important;
  background: transparent !important;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 4px !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  -moz-appearance: textfield;
}

.concurrency-control input::-webkit-outer-spin-button,
.concurrency-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.concurrency-btn {
  width: 38px;
  height: 38px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.concurrency-btn:hover { background: var(--color-brand-subtle); color: var(--color-brand); }
.concurrency-btn svg { width: 16px; height: 16px; }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* 微信式 Toast：深色半透明底 + 白字 */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  font-weight: 400;
  color: #fff;
  pointer-events: auto;
  animation: toastIn var(--transition-spring);
  min-width: 280px;
  max-width: 420px;
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error .toast-icon { color: var(--color-danger); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.info .toast-icon { color: var(--color-info); }

/* ---- Modal（微信确认弹窗规格：白底圆角、标题/正文居中、actions 顶部 hairline 横排等分） ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-mask);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

.modal-dialog {
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 32px 24px 0;
  max-width: 440px;
  width: 80%;
  text-align: center;
  overflow: hidden;
  animation: modalIn var(--transition-spring);
  box-shadow: var(--shadow-lg);
}

.modal-icon { margin-bottom: 12px; }
.modal-icon svg { width: 40px; height: 40px; }

.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-body { color: var(--color-text-secondary); font-size: 14px; margin-bottom: 24px; line-height: 1.55; }

/* actions 横排等分 + 顶部 hairline（负 margin 抵消容器水平 padding，贴边通栏） */
.modal-actions {
  display: flex;
  margin: 0 -24px;
  border-top: 1px solid var(--color-border);
  gap: 0;
}

.modal-actions > * {
  flex: 1;
  min-height: 48px;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.modal-actions > *:not(:first-child) { border-left: 1px solid var(--color-border); }

/* ---- Loading spinner ---- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---- 空状态 ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; color: var(--color-text-secondary); }
.empty-state p { font-size: 0.85rem; }

/* ---- 官方树 VIP 门禁引导卡（2026-09-08） ---- */
/* 树容器与详情区共用（ranking_ui.js _buildOfficialTreeGateCard），替换树内容展示 */
.official-tree-gate-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  max-width: 560px;
  margin: 32px auto;
  padding: 24px 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
}
.official-tree-gate-card h3 { font-size: 1.05rem; font-weight: 600; color: var(--color-text-primary); }
.official-tree-gate-card p { font-size: 0.875rem; line-height: 1.6; margin: 0; color: var(--color-text-secondary); }
.official-tree-gate-hint { color: var(--color-warning); font-weight: 500; }
.official-tree-gate-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ========================================
   微信顶部文字分段条（契约2：.wx-seg--page）
   微信顶部文字 tab 风格（非 iOS 胶囊）：白底等分、item 高 44px、文字 15px；
   默认二级灰、激活品牌绿 + 底部 2px 圆角绿色指示条；
   底部 hairline 分隔。
   .wx-seg--page 桌面隐藏；≤768px 由 responsive.css 放开为
   display:flex + sticky 吸附在 44px 导航栏下
   ======================================== */
.wx-seg {
  display: flex;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.wx-seg-item {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--color-text-secondary);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.wx-seg-item:active {
  background: var(--wx-pressed);
  transform: none;
}

.wx-seg-item.active {
  color: var(--color-brand);
  font-weight: 600;
  background: none;
}

/* 激活指示条：底部 2px 圆角绿色短条，居中 */
.wx-seg-item.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  border-radius: 1px;
  background: var(--color-brand);
}

/* 页级分段条：默认隐藏（桌面），移动端由 responsive.css 放开 */
.wx-seg--page { display: none; }

/* ========================================
   微信 cell 列表（契约3：P4 阶段 JS 才渲染 cell 内容，本阶段先落样式）
   .wx-cells 白底卡片 + 圆角 + 上下 8px 外边距；
   .wx-cell flex 行、min-height 48px、active 按压态、cell 间 hairline（缩进左 16px）；
   .wx-cell-text 16px 一级色；.wx-cell-arrow 14px 灰 chevron（对内联 svg 生效）
   ======================================== */
.wx-cell-group { margin: 8px 0; }

.wx-cell-group-title {
  padding: 16px 8px 8px 16px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text-muted);
  user-select: none;
}

.wx-cells {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  margin: 8px 0;
  overflow: hidden; /* 圆角裁切 cell 按压背景 */
}

.wx-cell {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--wx-cell-height);
  padding: 0 var(--wx-cell-pad-h);
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast);
}

.wx-cell:active {
  background: var(--wx-pressed);
  transform: none;
}

/* cell 之间 hairline：1px 缩进左侧 16px，最后一个无边线 */
.wx-cell:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--color-border);
  transform: scaleY(0.5); /* 高分屏 hairline */
  transform-origin: bottom;
}

.wx-cell-bd {
  flex: 1;
  min-width: 0;
}

.wx-cell-text {
  font-size: 16px;
  color: var(--color-text-primary);
  line-height: 1.4;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wx-cell-ft {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin-left: 8px;
  color: var(--color-text-muted);
}

/* chevron：内联 svg 用 currentColor 时随 .wx-cell-ft 灰色 */
.wx-cell-arrow {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
}
