/* TalkPilot 组件样式。统一 tp- 前缀，不给裸标签写样式。依赖 tokens.css。 */

/* ---------- 按钮 ---------- */
.tp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 38px; padding: 0 var(--s-4); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-size: var(--fs-14); font-weight: 500;
  white-space: nowrap; cursor: pointer; user-select: none; box-shadow: 0 1px 1px rgba(16, 37, 43, .03);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tp-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); box-shadow: var(--sh-sm); }
.tp-btn:active:not(:disabled) { background: var(--surface-3); }
.tp-btn:disabled { opacity: .45; cursor: not-allowed; }
.tp-btn--primary { background: linear-gradient(135deg, var(--ink-hover) 0%, var(--ink) 55%, #0A2025 100%); border-color: var(--ink); color: var(--text-on-ink); box-shadow: 0 5px 14px rgba(16, 45, 51, .18); }
.tp-btn--primary:hover:not(:disabled) { background: linear-gradient(135deg, #25515A 0%, var(--ink-hover) 100%); border-color: var(--ink-hover); box-shadow: 0 7px 18px rgba(16, 45, 51, .2); }
.tp-btn--primary:active:not(:disabled) { background: var(--ink-press); }
.tp-btn--brand { background: linear-gradient(135deg, #11A99E 0%, #07877F 100%); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(8, 126, 119, .18); }
.tp-btn--brand:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.tp-btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.tp-btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.tp-btn--danger { color: var(--err); }
.tp-btn--danger:hover:not(:disabled) { background: var(--err-soft); border-color: var(--err); }
.tp-btn--sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-13); }
.tp-btn--lg { height: 48px; padding: 0 var(--s-6); font-size: var(--fs-16); }
.tp-btn--block { width: 100%; }
.tp-btn--icon { width: 38px; padding: 0; }
.tp-btn--sm.tp-btn--icon { width: 30px; }
.tp-btn.is-loading { pointer-events: none; }
.tp-btn.is-loading::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: tp-spin .7s linear infinite;
}
.tp-btn svg { width: 16px; height: 16px; flex: none; }
.tp-link { background: none; border: 0; padding: 0; color: var(--brand-text); cursor: pointer; font-size: inherit; }
.tp-link:hover { text-decoration: underline; }
.tp-btn--primary svg, .tp-btn--brand svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,.12)); }
@keyframes tp-spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.tp-field { display: flex; flex-direction: column; gap: 6px; }
.tp-field + .tp-field { margin-top: var(--s-4); }
.tp-label { font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }
.tp-help { font-size: var(--fs-12); color: var(--text-3); }
.tp-field.is-invalid .tp-help { color: var(--err); }
.tp-input, .tp-select, .tp-textarea {
  width: 100%; height: 40px; padding: 0 var(--s-3);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  color: var(--text); font-size: var(--fs-14);
  box-shadow: inset 0 1px 1px rgba(16, 37, 43, .025);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tp-textarea { height: auto; min-height: 88px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: var(--lh); }
.tp-input::placeholder, .tp-textarea::placeholder { color: var(--text-3); }
.tp-input:hover, .tp-select:hover, .tp-textarea:hover { border-color: var(--text-3); background: #FCFEFE; }
.tp-input:focus, .tp-select:focus, .tp-textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); background: var(--surface); }
.tp-field.is-invalid .tp-input, .tp-field.is-invalid .tp-textarea { border-color: var(--err); }
.tp-select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238A94A3' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.tp-check { display: inline-flex; align-items: flex-start; gap: var(--s-2); font-size: var(--fs-13); color: var(--text-2); cursor: pointer; }
.tp-check input { margin: 3px 0 0; accent-color: var(--brand); }
.tp-count { align-self: flex-end; font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- 面板（少用：只给内容上独立的区块） ---------- */
.tp-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden; }
.tp-panel__head {
  display: flex; align-items: center; gap: var(--s-3); min-height: 48px;
  padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #FFFFFF, #FBFDFD);
}
.tp-panel__title { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-16); font-weight: 700; margin-right: auto; }
.tp-panel__title svg { width: 17px; height: 17px; color: var(--brand-text); }
.tp-panel__body { padding: var(--s-5); }
.tp-panel__body--flush { padding: 0; }

/* ---------- 徽标 / 状态点 ---------- */
.tp-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border: 1px solid transparent; border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-12); font-weight: 600; white-space: nowrap;
}
.tp-badge--ok { background: var(--ok-soft); color: var(--ok); border-color: #C8EBD5; }
.tp-badge--warn { background: var(--warn-soft); color: var(--warn); border-color: #F4D4A7; }
.tp-badge--err { background: var(--err-soft); color: var(--err); border-color: #F6CACA; }
.tp-badge--brand { background: var(--brand-soft); color: var(--brand-text); border-color: var(--brand-line); }
.tp-badge--accent { background: var(--accent-soft); color: var(--accent-text); border-color: #F2D59A; }
.tp-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- 表格 ---------- */
.tp-table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.tp-table th {
  height: 40px; padding: 0 var(--s-5); text-align: left; white-space: nowrap;
  font-size: var(--fs-12); font-weight: 600; color: var(--text-2); background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.tp-table td { height: 48px; padding: 0 var(--s-5); border-bottom: 1px solid var(--border); color: var(--text); }
.tp-table tr:last-child td { border-bottom: 0; }
.tp-table tbody tr.is-link { cursor: pointer; }
.tp-table tbody tr.is-link:hover td { background: var(--surface-2); }
.tp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tp-table .muted { color: var(--text-3); }
.tp-table .mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.tp-table-wrap { overflow-x: auto; }

/* ---------- Tabs ---------- */
.tp-tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--border); }
.tp-tab {
  position: relative; height: 40px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--text-3); font-size: var(--fs-14); font-weight: 500;
}
.tp-tab:hover { color: var(--text); }
.tp-tab[aria-selected="true"] { color: var(--text); }
.tp-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); }

/* ---------- 下拉菜单 ---------- */
.tp-menu-anchor { position: relative; }
.tp-menu {
  position: absolute; z-index: 40; top: calc(100% + 6px); right: 0; min-width: 200px; padding: var(--s-1);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-lg);
}
.tp-menu__head { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--border); margin-bottom: var(--s-1); }
.tp-menu__item {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; height: 32px; padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-xs); background: none; color: var(--text); font-size: var(--fs-14);
  text-align: left; cursor: pointer;
}
.tp-menu__item:hover, .tp-menu__item:focus-visible { background: var(--surface-2); box-shadow: none; }
.tp-menu__item--danger { color: var(--err); }
.tp-menu__sep { height: 1px; margin: var(--s-1) 0; background: var(--border); }
/* ---------- 弹窗 ---------- */
.tp-dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--sh-lg);
}
.tp-dialog--wide { width: min(560px, calc(100vw - 32px)); }
.tp-dialog::backdrop { background: var(--scrim); }
.tp-dialog[open] { animation: tp-pop var(--dur) var(--ease); }
@keyframes tp-pop { from { opacity: 0; transform: translateY(6px); } }
/* 弹腾讯云滑块时登录框临时变成非模态：保持和模态时同样居中，不重播动画；非模态不在顶层，要靠 z-index 压住页面里的 sticky 导航和首屏文字（auth-common.js） */
.tp-dialog--held { position: fixed; inset: 0; z-index: 1000; margin: auto; }
.tp-dialog--still[open] { animation: none; }
.tp-dialog__inner { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.tp-dialog__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5) 0; }
.tp-dialog__title { font-size: var(--fs-16); font-weight: 600; margin-right: auto; }
.tp-dialog__body { padding: var(--s-4) var(--s-5) var(--s-5); overflow-y: auto; color: var(--text-2); }
.tp-dialog__foot {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); background: var(--surface);
}

/* ---------- 右侧抽屉 ---------- */
.tp-drawer {
  margin: 0 0 0 auto; width: min(560px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0;
  border: 0; border-left: 1px solid var(--border); border-radius: 0; background: var(--surface); color: var(--text); box-shadow: var(--sh-lg);
}
.tp-drawer::backdrop { background: var(--scrim); }
.tp-drawer[open] { animation: tp-slide 200ms var(--ease); }
@keyframes tp-slide { from { opacity: 0; transform: translateX(32px); } }
.tp-drawer__inner { display: flex; flex-direction: column; height: 100%; }
.tp-drawer__head { display: flex; align-items: center; gap: var(--s-3); height: 60px; padding: 0 var(--s-6); border-bottom: 1px solid var(--border); flex: none; }
.tp-drawer__title { margin-right: auto; font-size: var(--fs-18); font-weight: 700; }
.tp-drawer__body { flex: 1; overflow-y: auto; padding: var(--s-6); }
.tp-drawer__foot { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-6); border-top: 1px solid var(--border); background: var(--surface); flex: none; }

/* ---------- Toast ---------- */
.tp-toasts { position: fixed; z-index: 100; top: var(--s-4); right: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.tp-toast {
  display: flex; align-items: flex-start; gap: var(--s-2); max-width: 360px; padding: var(--s-3) var(--s-4);
  background: var(--text); color: var(--bg); border-radius: var(--r-md); box-shadow: var(--sh-md);
  font-size: var(--fs-13); pointer-events: auto; animation: tp-pop var(--dur) var(--ease);
}
.tp-toast::before { content: ""; width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.tp-toast--ok::before { background: #5CC48A; }
.tp-toast--err::before { background: #F0705F; }
.tp-toast.is-leaving { opacity: 0; transition: opacity 200ms; }

/* ---------- 提示条 ---------- */
.tp-callout {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-13); color: var(--text-2);
  box-shadow: var(--sh-sm);
}
.tp-callout--warn { background: var(--warn-soft); border-color: #F3D2A2; color: var(--text); }
.tp-callout--info { background: var(--info-soft); border-color: #C9D9F5; color: var(--text); }
.tp-callout__text { flex: 1; min-width: 0; }

/* ---------- 空 / 错误 / 加载 ---------- */
.tp-state { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-10) var(--s-6); text-align: center; }
.tp-state__title { font-size: var(--fs-14); font-weight: 600; color: var(--text); }
.tp-state__desc { max-width: 360px; font-size: var(--fs-13); color: var(--text-3); }
.tp-state .tp-btn { margin-top: var(--s-2); }
.tp-state--err .tp-state__title { color: var(--err); }
.tp-skel { display: block; height: 12px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: tp-shimmer 1.2s linear infinite; }
@keyframes tp-shimmer { to { background-position: -200% 0; } }
.tp-skel-rows { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-5); }

/* ---------- 指标条（一条横排，不是卡片） ---------- */
.tp-metrics { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden; }
.tp-metric { padding: var(--s-4) var(--s-5); min-width: 0; }
.tp-metric + .tp-metric { border-left: 1px solid var(--border); }
.tp-metric__label { font-size: var(--fs-12); color: var(--text-2); font-weight: 500; }
.tp-metric__value { margin-top: var(--s-1); font-size: var(--fs-24); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tp-metric__value small { margin-left: 4px; font-size: var(--fs-13); font-weight: 400; color: var(--text-3); }
.tp-metric__foot { margin-top: var(--s-1); font-size: var(--fs-12); color: var(--text-3); }
.tp-metric__foot .tp-link { font-size: var(--fs-12); }

/* ---------- 航线（步骤清单） ---------- */
.tp-route { list-style: none; margin: 0; padding: 0; }
.tp-route__step { position: relative; display: grid; grid-template-columns: 20px 1fr auto; gap: var(--s-3); padding-bottom: var(--s-5); }
.tp-route__step:last-child { padding-bottom: 0; }
.tp-route__step::before { content: ""; position: absolute; left: 9.5px; top: 22px; bottom: 2px; width: 1px; background: var(--border-strong); }
.tp-route__step:last-child::before { display: none; }
.tp-route__mark { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; }
.tp-route__step.is-done .tp-route__mark { border-color: var(--brand); background: var(--brand); }
.tp-route__step.is-done .tp-route__mark::after { content: ""; width: 8px; height: 4px; margin-top: -2px; border: solid #fff; border-width: 0 0 1.5px 1.5px; transform: rotate(-45deg); }
.tp-route__step.is-done::before { background: var(--brand-line); }
.tp-route__step.is-current .tp-route__mark { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tp-route__title { font-size: var(--fs-14); font-weight: 500; }
.tp-route__step.is-done .tp-route__title { color: var(--text-3); }
.tp-route__desc { margin-top: 2px; font-size: var(--fs-12); color: var(--text-3); }

.tp-kbd { display: inline-block; min-width: 18px; padding: 0 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-xs); font: 500 11px/16px var(--font-mono); color: var(--text-3); text-align: center; }

@media (max-width: 720px) {
  .tp-metrics { grid-template-columns: repeat(2, 1fr); }
  .tp-metric:nth-child(3) { border-left: 0; }
  .tp-metric:nth-child(n+3) { border-top: 1px solid var(--border); }
  .tp-table th, .tp-table td { padding: 0 var(--s-3); }
  .tp-toasts { left: var(--s-4); }
}
