/* ============================================
   巴消消防 · 组件层 Components
   ------------------------------------------------------------
   2026-10-13 建立（Primer 规格卡思路）
   2026-10-18 v2：按苹果设计语言重写规格——
     控件高度 44–48、输入圆角 12、卡片 18、面板 20–24；
     组件只允许引用令牌，不定义颜色常量。
   每个组件按五件事描述：结构 / 变体 / 状态 / 键盘 / ARIA
   ============================================ */

/* ============================================
   00 · 无障碍工具
   ============================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 键盘焦点环（鼠标点击不显示，避免视觉噪音） */
:focus-visible {
  outline: 2px solid var(--ring, var(--accent));
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* ============================================
   01 · Button 按钮扩展
   ------------------------------------------------------------
   基础规格见 style.css 的 .btn；此处只补变体与状态。
   尺寸：sm 36 / md 44（默认）/ lg 52
   状态：hover 提亮 / active 缩放 .975 / disabled 50% / loading
   ============================================ */
.btn-sm {
  min-height: 36px;
  padding: 0 18px;
  font-size: 13px;
}

.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-link {
  display: inline;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { filter: none; text-decoration-thickness: 2px; }

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ============================================
   02 · Chip 芯片
   ------------------------------------------------------------
   结构：<span class="chip">消防器材</span>
   变体：.chip--accent（选中）
   ============================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-base);
  border-radius: var(--r-sm);
  background: var(--bg-alt);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  transition: border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}

.chip:hover { border-color: var(--border-light); color: var(--text-primary); }

.chip--accent,
.chip.hot {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ============================================
   03 · Form 表单
   ------------------------------------------------------------
   结构：
     <div class="form-field">
       <label class="form-label" for="x">标签</label>
       <input class="form-control" id="x" aria-describedby="x-hint">
       <p class="form-hint" id="x-hint">提示</p>
     </div>
   状态：hover 描边加深 / focus 强调色 + 3px 柔光环 / invalid 红描边
   键盘：Tab 顺序流转；错误时 aria-invalid="true"
   ============================================ */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: var(--sp-6);
}

.form-label {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-secondary);
}

.form-label .req { color: var(--accent-text); margin-left: 2px; }

.form-control {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: var(--fs-body);
  line-height: 1.5;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}

textarea.form-control {
  min-height: 120px;
  padding: 13px 16px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%),
    linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:hover { border-color: var(--border-strong); }

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-hint { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.form-error { font-size: 12.5px; color: var(--danger); line-height: 1.55; }

.form-field--error .form-control,
.form-control.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent);
}

.form-field--success .form-control { border-color: var(--success); }

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-6);
}

/* ============================================
   04 · Breadcrumb 面包屑
   ============================================ */
.breadcrumb {
  padding: 22px 0 0;
  font-size: 12.5px;
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: var(--text-muted);
  opacity: .7;
}

.breadcrumb-item a {
  color: var(--text-tertiary);
  transition: color var(--dur-fast) var(--ease);
}

.breadcrumb-item a:hover { color: var(--accent-text); }

.breadcrumb-current {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================
   05 · Badge 徽标
   ------------------------------------------------------------
   结构：<span class="badge badge--success">已完成</span>
   变体：accent（默认）/ success / warning / danger / info / neutral
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--accent-border);
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.badge--success {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
}

.badge--warning {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 35%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}

.badge--danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.badge--info {
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 35%, transparent);
  background: color-mix(in srgb, var(--info) 10%, transparent);
}

.badge--neutral {
  color: var(--text-tertiary);
  border-color: var(--border-light);
  background: var(--bg-alt);
}

/* ============================================
   06 · Table 表格
   ------------------------------------------------------------
   结构：.table-wrap > table.table（caption 必填，th 带 scope）
   ============================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-base);
  border-radius: var(--r-md);
  background: var(--bg-card);
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.table th,
.table td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-base);
  vertical-align: middle;
}

.table thead th {
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody tr:last-child td,
.table tbody tr:last-child th { border-bottom: none; }

.table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }

.table--compact th,
.table--compact td { padding: 9px 14px; font-size: 12.5px; }

.table--striped tbody tr:nth-child(even) { background: var(--bg-alt); }

/* ============================================
   07 · Drawer / Modal 抽屉与弹层
   ------------------------------------------------------------
   结构：.drawer[role=dialog][aria-modal=true] > .drawer-panel
   变体：默认右侧滑入 / .drawer--center 居中
   状态：.is-open 显示；Esc 关闭由 components.js 负责
   ============================================ */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
}

.drawer.is-open { display: block; }

.drawer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: drawer-fade var(--dur-base) var(--ease);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 100%);
  padding: var(--sp-8);
  background: var(--bg-body);
  border-left: 1px solid var(--border-base);
  box-shadow: var(--shadow-dropdown);
  overflow-y: auto;
  animation: drawer-in var(--dur-base) var(--ease-out);
}

.drawer--center .drawer-panel {
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
  width: min(560px, calc(100% - 32px));
  height: auto;
  max-height: 86vh;
  border-left: none;
  border: 1px solid var(--border-base);
  border-radius: var(--r-lg);
  animation: none;
}

.drawer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-base);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-tertiary);
  font-size: 18px;
  line-height: 1;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.drawer-close:hover { background: var(--bg-hover); color: var(--text-primary); }

@keyframes drawer-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawer-in {
  from { translate: 24px 0; opacity: 0; }
  to { translate: 0 0; opacity: 1; }
}

/* ============================================
   08 · Toast 轻提示
   ============================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: min(480px, calc(100% - 32px));
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg-card) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-dropdown);
  color: var(--text-primary);
  font-size: var(--fs-small);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity var(--dur-base) var(--ease),
              transform var(--dur-base) var(--ease);
}

.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast--success { border-color: var(--success); }
.toast--danger { border-color: var(--danger); }

/* ============================================
   09 · Timeline 时间线
   ============================================ */
.timeline {
  display: flex;
  flex-direction: column;
  list-style: none;
}

.timeline-step {
  position: relative;
  padding: 0 0 var(--sp-6) var(--sp-8);
  border-left: 1px solid var(--border-light);
}

.timeline-step:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline-step::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg-body);
  border: 1.5px solid var(--border-strong);
}

.timeline-step.is-done::before { background: var(--accent); border-color: var(--accent); }
.timeline-step.is-active::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline-step.is-done,
.timeline-step.is-active { border-left-color: var(--accent-border); }

.timeline-step .t { color: var(--accent-text); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.timeline-step h4 { font-size: var(--fs-body-lg); margin: 3px 0; }
.timeline-step p { color: var(--text-tertiary); font-size: 13px; line-height: 1.65; }

/* ============================================
   10 · Accordion 折叠面板（原生 details，零 JS）
   ============================================ */
.accordion { border-bottom: 1px solid var(--border-base); }

.accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 18px 0;
  cursor: pointer;
  font-size: var(--fs-body-lg);
  font-weight: 500;
  color: var(--text-primary);
  list-style: none;
  transition: color var(--dur-fast) var(--ease);
}

.accordion summary::-webkit-details-marker { display: none; }

.accordion summary::after {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-tertiary);
  border-bottom: 1.5px solid var(--text-tertiary);
  transform: rotate(45deg);
  transition: transform var(--dur-base) var(--ease);
}

.accordion summary:hover { color: var(--accent-text); }
.accordion[open] summary { color: var(--accent-text); }
.accordion[open] summary::after { transform: rotate(-135deg); }

.accordion-body {
  padding: 0 0 20px;
  color: var(--text-tertiary);
  font-size: var(--fs-small);
  line-height: 1.8;
}

/* ============================================
   11 · Skeleton 骨架屏
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--bg-card) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-xs);
  animation: skeleton-breathe 1.6s ease-in-out infinite;
}

.skeleton--text { height: 14px; margin-bottom: var(--sp-2); }
.skeleton--rect { height: 180px; }
.skeleton--circle { width: 48px; height: 48px; border-radius: 50%; }

@keyframes skeleton-breathe {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   12 · Dot 状态圆点（检索条 / 列表通用）
   ============================================ */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.name { background: var(--success); }
.dot.content { background: var(--info); }
