/* 保函格式库 · 差异对照页样式 */

.gfd-main {
  position: relative;
  z-index: 1;
  /* 工作区已按视口限高，底部只留 16px 呼吸位，避免页面出现多余滚动 */
  padding: 20px 28px 16px;
}

.gfd-inner {
  width: 100%;
}

/* 返回链接放入控制栏后，去掉其在其他页面自带的上边距 */
.gfd-controls .gfd-back {
  margin-top: 0;
}

.gfd-sim-tag {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 999px;
}

/* 提示横幅 */
.gfd-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.6;
  border-radius: 10px;
}

.gfd-banner-problem {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-weight: 600;
}

/* 控制条 */
.gfd-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}

.gfd-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.gfd-switch + .gfd-switch { margin-left: 0; }

.gfd-switch input { accent-color: var(--primary); }

/* 双栏对照 */
.gfd-panes {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* 行高收紧到容器高度，避免随内容撑开把 .gfd-doc 顶出滚动区 */
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
}

.gfd-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(30, 107, 255, 0.05);
}

.gfd-pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 18px;
  background: #f8faff;
  border-bottom: 1px solid var(--border);
}

.gfd-pane-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gfd-pane-sub {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
}

.gfd-pane-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.gfd-pane-export,
.gfd-pane-copy {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.gfd-pane-export svg,
.gfd-pane-copy svg { width: 13px; height: 13px; }

.gfd-pane-export:hover,
.gfd-pane-copy:hover {
  background: #e3edff;
  border-color: var(--border-focus);
}

.gfd-doc {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink);
}

.gfd-clause {
  position: relative;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.gfd-clause-no {
  display: inline-block;
  margin-right: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

/* 工作区：双栏对照 + 右侧差异清单 */
.gfd-workspace {
  display: flex;
  align-items: stretch;
  gap: 14px;
  /* 占满首屏剩余高度（顶部偏移 150px + 底部留白 16px），文档区不悬空 */
  height: calc(100vh - 166px);
  min-height: 420px;
}

.gfd-panes {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* 差异三色标识：
   绿＝库内模板有、客户无（右侧整条）；红＝客户有、库内无（左侧整条）；
   橘＝双方表述不同，不铺整条，仅给差异片段（.gfd-word-diff）铺橘底 */
.gfd-clause.diff-added-right {
  background: #ccf7f3;
}

.gfd-clause.diff-added-right .gfd-clause-no {
  color: #0f766e;
}

.gfd-clause.diff-missing-left {
  background: #ffe5e5;
}

.gfd-clause.diff-missing-left .gfd-clause-no {
  color: #b91c1c;
}

.gfd-clause.diff-missing-left.ignored {
  background: #f9fafb;
}

.gfd-clause.diff-missing-left.ignored .gfd-clause-no {
  color: var(--muted);
}

/* 缺侧透明锚点：不显示文字/衬底，仅作联线落点 */
.gfd-clause.diff-anchor {
  background: none;
  border: none;
}

/* 差异片段：橘底铺在具体词句上（含库内模板的 {{变量}} 占位符） */
.gfd-word-diff {
  padding: 1px 3px;
  border-radius: 3px;
  background: #fce6b7;
  color: inherit;
}

/* 红色多出条款整条已铺红，内部关键词不再二次标色 */
.gfd-clause.diff-missing-left .gfd-word-diff {
  padding: 0;
  background: none;
}

/* 当前定位差异：用该类型的深色边框框住对应条款（点击差异片段/右侧卡片时才出现）
   红＝客户多出；绿＝库内新增；橘黄＝表述差异（两侧同时框住） */
.gfd-clause.diff-modified.current {
  outline: 1px solid #d97706;
  outline-offset: 0;
}

.gfd-clause.diff-missing-left.current {
  outline: 1px solid #dc2626;
  outline-offset: 0;
}

.gfd-clause.diff-added-right.current {
  outline: 1px solid #0f766e;
  outline-offset: 0;
}

/* 差异条款/片段可点击 */
.gfd-clause.diff-modified,
.gfd-clause.diff-missing-left,
.gfd-clause.diff-added-right {
  cursor: pointer;
}

/* 关闭「定位框」开关后，文档内不显示选中边框与联线（卡片选中态、定位滚动不受影响） */
body.gfd-hide-current .gfd-clause.current {
  outline: none;
}

body.gfd-hide-current .gfd-link-layer {
  display: none;
}

/* 红色虚线联线层：客户多出条款 → 对侧锚点，常驻显示 */
.gfd-link-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.gfd-link-path {
  fill: none;
  stroke: #ef4444;
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  animation: gfd-dash-flow-rg 0.5s linear infinite;
}

/* 客户多出（红）/ 库内新增（绿）：对侧用同色水平实线标识锚点位置（虚线联到此后接实线） */
.gfd-link-anchor {
  stroke: #ef4444;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.gfd-link-path-green {
  fill: none;
  stroke: #14b8a6;
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  animation: gfd-dash-flow-rg 0.5s linear infinite;
}

.gfd-anchor-green {
  stroke: #14b8a6;
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* 表述差异：橘黄流动虚线（允许直角弯折），连接左右两侧标识框中心，点击选中后显示 */
.gfd-link-path-amber {
  fill: none;
  stroke: #f59e0b;
  stroke-width: 1.5;
  stroke-dasharray: 8 5;
  stroke-linecap: round;
  animation: gfd-dash-flow 0.7s linear infinite;
}

@keyframes gfd-dash-flow {
  to { stroke-dashoffset: -26; }
}

/* 红/绿虚线周期为 6 4（10），偏移取 -20 保证无缝循环 */
@keyframes gfd-dash-flow-rg {
  to { stroke-dashoffset: -20; }
}

@media (prefers-reduced-motion: reduce) {
  .gfd-link-path-amber,
  .gfd-link-path,
  .gfd-link-path-green { animation: none; }
}

/* ---------- 右侧差异清单 ---------- */
.gfd-panel {
  position: relative;
  flex-shrink: 0;
  width: 300px;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(30, 107, 255, 0.05);
  overflow: hidden;
  transition: width 0.2s ease;
}

.gfd-panel-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.gfd-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.gfd-panel-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.gfd-panel-collapse {
  display: inline-flex;
  padding: 3px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.gfd-panel-collapse svg { width: 16px; height: 16px; }

.gfd-panel-collapse:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.gfd-panel-filters {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.gfd-filter {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--ink-secondary);
  background: #f6f8fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.gfd-panel-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
}

.gfd-panel-list:empty::after {
  content: "当前筛选下暂无差异";
  display: block;
  padding: 32px 0;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}

.gfd-diff-card {
  position: relative;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gfd-diff-card:hover {
  border-color: var(--border-focus);
}

.gfd-diff-card.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 107, 255, 0.15);
}

.gfd-diff-card.ignored {
  opacity: 0.55;
  background: #f9fafb;
}

.gfd-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
}

.gfd-card-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.gfd-card-type i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.gfd-card-type.t-modified { color: #b45309; }
.gfd-card-type.t-modified i { background: #f59e0b; }
.gfd-card-type.t-missing { color: #b91c1c; }
.gfd-card-type.t-missing i { background: #ef4444; }
.gfd-card-type.t-extra { color: #0f766e; }
.gfd-card-type.t-extra i { background: #14b8a6; }

.gfd-card-ignore {
  flex-shrink: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
}

.gfd-card-ignore:hover { text-decoration: underline; }

.gfd-card-line {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-secondary);
}

.gfd-card-line + .gfd-card-line { margin-top: 3px; }

.gfd-card-line b {
  margin-right: 4px;
  font-weight: 700;
  color: var(--ink);
}

.gfd-card-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gfd-card-line.is-empty { color: var(--muted); font-style: italic; }

/* 折叠态：只剩一条竖排按钮 */
.gfd-panel-expand {
  display: none;
}

.gfd-panel.collapsed {
  width: 34px;
}

.gfd-panel.collapsed .gfd-panel-inner {
  display: none;
}

.gfd-panel.collapsed .gfd-panel-expand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  padding: 12px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--ink-secondary);
  background: #f8faff;
  border: none;
  cursor: pointer;
  writing-mode: vertical-rl;
}

.gfd-panel.collapsed .gfd-panel-expand:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* 三色图例 */
.gfd-legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-wrap: wrap;
}

.gfd-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.gfd-legend-item i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid;
}

.gfd-legend-item.lg-green i { background: #ccf7f3; border-color: #8fe3d6; }
.gfd-legend-item.lg-red i { background: #ffe5e5; border-color: #fca5a5; }
.gfd-legend-item.lg-amber i { background: #fce6b7; border-color: #f3cf86; }
.gfd-legend-item.lg-gray i { background: #f9fafb; border-color: var(--border); }

.gfd-removed {
  color: #9ca3af;
  background: #f9fafb;
}

/* 响应式 */
@media (max-width: 900px) {
  .gfd-main { padding: 16px 14px 48px; }
  .gfd-workspace { flex-direction: column; height: auto; min-height: 0; }
  .gfd-panes { grid-template-columns: 1fr; }
  .gfd-panel,
  .gfd-panel.collapsed { width: 100%; }
  .gfd-panel.collapsed .gfd-panel-expand { width: 100%; writing-mode: horizontal-tb; letter-spacing: 2px; }
  .gfd-doc { height: auto; max-height: 60vh; }
  .gfd-legend,
  .gfd-switch { margin-left: 0; }
  .gfd-link-layer { display: none; }
}
