/**
 * 联签轻量化贴边气泡引导样式（方案 A）：
 * 遵循全站钢笔墨蓝 + 纸白商务直觉风格；
 * 高亮框与箭头严格 pointer-events: none，绝不阻塞任何业务操作。
 */

@import './guide-signing.css';

/* 工作台和汇总的练习入口放在文档流里，给实际工作区留出完整空间。 */
.guide-lesson.notice { display: block; flex: none; margin: 0 0 var(--sp-3); padding: var(--sp-3); }
.guide-lesson-head, .guide-lesson-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.guide-lesson-head { justify-content: space-between; }
.guide-lesson-head:not(:has([aria-expanded="false"])) { margin-bottom: var(--sp-2); }
.workbench:has(.guide-lesson) #doc-list { padding-bottom: var(--sp-2); }
.guide-lesson-body > p { margin: 0 0 var(--sp-2); }
.guide-lesson-body[hidden] { display: none; }

/* ======================== 通用导览贴边气泡（首页 / 签署 / 结果 / 汇总） ======================== */

.guide-bar {
  position: fixed;
  z-index: 99999;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(320px, calc(100vw - 24px));
  padding: 11px 13px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--accent, #2563eb);
  border-radius: var(--radius-md, 6px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14), 0 1px 3px rgba(15, 23, 42, 0.06);
  color: var(--text, #172033);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
}

.guide-bar.is-collapsed {
  width: auto;
  max-width: calc(100vw - 24px);
  padding: 6px 10px;
}

.guide-bar-arrow,
.guide-editor-arrow {
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--surface, #ffffff);
  border-left: 1px solid var(--accent, #2563eb);
  border-top: 1px solid var(--accent, #2563eb);
  pointer-events: none;
}

.guide-bar[data-placement="bottom"] > .guide-bar-arrow,
.guide-editor[data-placement="bottom"] > .guide-editor-arrow {
  top: -5px;
  left: var(--arrow-pos, 24px);
  transform: translateX(-50%) rotate(45deg);
}
.guide-bar[data-placement="top"] > .guide-bar-arrow,
.guide-editor[data-placement="top"] > .guide-editor-arrow {
  bottom: -5px;
  left: var(--arrow-pos, 24px);
  transform: translateX(-50%) rotate(225deg);
}
.guide-bar[data-placement="right"] > .guide-bar-arrow,
.guide-editor[data-placement="right"] > .guide-editor-arrow {
  left: -5px;
  top: var(--arrow-pos, 22px);
  transform: translateY(-50%) rotate(-45deg);
}
.guide-bar[data-placement="left"] > .guide-bar-arrow,
.guide-editor[data-placement="left"] > .guide-editor-arrow {
  right: -5px;
  top: var(--arrow-pos, 22px);
  transform: translateY(-50%) rotate(135deg);
}
.guide-bar[data-placement="float"] > .guide-bar-arrow,
.guide-editor[data-placement="float"] > .guide-editor-arrow,
.guide-bar.is-collapsed > .guide-bar-arrow {
  display: none;
}

.guide-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.guide-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft, #eff6ff);
  color: var(--accent, #2563eb);
  font-size: 11px;
  font-weight: 600;
}

.guide-exit-link {
  color: var(--muted, #667085);
  text-decoration: none;
  font-size: 11.5px;
  cursor: pointer;
}
.guide-exit-link:hover {
  color: var(--accent, #2563eb);
  text-decoration: underline;
}

.guide-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text, #172033);
}

.guide-body {
  margin: 0;
  color: var(--text-soft, #475467);
  font-size: 12.5px;
  line-height: 1.5;
}

.guide-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border, #e2e8f0);
}

.guide-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease;
}

.guide-btn-primary {
  background: var(--accent, #2563eb);
  color: #fff;
}
.guide-btn-primary:hover {
  background: #1d4ed8;
}

.guide-btn-outline {
  background: #fff;
  border-color: var(--border, #cbd5e1);
  color: var(--text, #172033);
}
.guide-btn-outline:hover {
  background: #f1f5f9;
}

/* 通用固定聚光环：指针完全穿透 */
.guide-spotlight {
  position: fixed;
  z-index: 99990;
  pointer-events: none !important;
  border: 1.5px solid var(--accent, #2563eb);
  border-radius: 5px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

/* ======================== 新建页文档流提示 ======================== */

.guide-new {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  flex: none;
  gap: 2px var(--sp-3);
  margin: 0 0 var(--sp-3);
  border-color: var(--accent);
  border-inline-start-width: 3px;
  background: var(--accent-soft);
}
.guide-new-message strong { color: var(--text); font-size: var(--text-sm); }
.guide-new-message p { margin: 2px 0 0; }
.guide-new .guide-exit-link { font-size: var(--text-xs); color: var(--accent); white-space: nowrap; }
.guide-new .form-error { grid-column: 1 / -1; margin: 0; }
.guide-new .form-error:empty { display: none; }
.import-page .guide-new-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 3px var(--accent-soft);
}
.import-page .guide-new-target:focus-visible { outline-offset: 1px; }
.import-page .guide-new-target.btn-primary { outline-offset: 2px; box-shadow: none; }

/* ======================== 编辑器极简贴边气泡（正式 & 练习共用） ======================== */

.guide-editor-spotlight {
  position: fixed;
  z-index: 1450;
  pointer-events: none !important;
  border: 1.5px solid var(--accent, #2563eb);
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.guide-editor-spotlight[hidden] {
  display: none;
}

.guide-editor {
  position: fixed;
  z-index: 1500;
  top: 72px;
  left: 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(304px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: visible;
  gap: 7px;
  padding: 11px 13px;
  border: 1px solid var(--accent, #2563eb);
  border-radius: var(--radius-md, 6px);
  background: var(--surface, #ffffff);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--text) 14%, transparent), 0 1px 3px color-mix(in srgb, var(--text) 7%, transparent);
}
.guide-editor[hidden] {
  display: none;
}
/* 加载遮罩与业务弹窗打开时隐避，不抢焦点和触控 */
body:has(#editor-loading, .modal.open) > .guide-editor,
body:has(#editor-loading, .modal.open) > .guide-editor-spotlight {
  visibility: hidden;
  pointer-events: none;
}

.guide-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.guide-editor-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.guide-editor-step-tag {
  flex: none;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.guide-editor-head .guide-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guide-editor-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.guide-editor-close:hover {
  background: var(--surface-2, #f3f5f8);
  color: var(--text);
}

.guide-editor-message {
  min-width: 0;
}
.guide-editor-message .guide-body {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-soft, #475467);
  line-height: 1.5;
}
.guide-editor-feedback {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 3px;
  background: color-mix(in srgb, #15803d 10%, transparent);
  color: #15803d;
  font-size: 11.5px;
  font-weight: 600;
}
.guide-editor-feedback[hidden] {
  display: none;
}

.guide-editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.guide-editor-actions-left,
.guide-editor-actions-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.guide-editor-actions .guide-link-btn {
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.guide-editor-actions .guide-link-btn:hover {
  text-decoration: underline;
}
.guide-editor-actions .guide-link-btn[hidden] {
  display: none;
}
.guide-editor .form-error { margin: 0; font-size: 12px; }
.guide-editor .form-error:empty { display: none; }

/* 顶栏「新手引导」唤醒按钮激活态 */
.topbar-editor #editor-intro-link.is-guide-open {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 目标内描边：不增加尺寸、不抢交互 */
.editor-shell .guide-editor-target {
  outline: 1.5px solid var(--accent);
  outline-offset: -1px;
}
.editor-shell .guide-editor-target:focus-visible { outline-offset: 1px; }

@media (max-width: 820px) {
  body:has(> .guide-editor) .editor-title { grid-template-columns: minmax(0, 1fr); }
  body:has(> .guide-editor) .editor-meta { min-width: 0; overflow: hidden; }
  body:has(> .guide-editor) .editor-shell #doc-code {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .guide-editor {
    width: min(300px, calc(100vw - 16px));
    padding: 10px 12px;
  }
  .guide-editor-actions .btn { min-height: 32px; }
}
