/*
 * Gerber 治具生成器 · 样式表
 * Copyright (c) 2026 蒲俊杰 (Pu Junjie)
 * License: AGPL-3.0 (see LICENSE file)
 */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font: 14px/1.5 "Segoe UI", "Microsoft YaHei", sans-serif; background: #14171c; color: #dfe4ea; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

header { padding: 10px 16px; background: #1c2129; border-bottom: 1px solid #2b323d; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; position: relative; }
header h1 { font-size: 17px; color: #6fc3ff; white-space: nowrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@keyframes header-link-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(232,168,56,0.3), inset 0 0 4px rgba(232,168,56,0.05); }
  50% { box-shadow: 0 0 18px rgba(232,168,56,0.8), 0 0 30px rgba(255,180,50,0.4), inset 0 0 12px rgba(232,168,56,0.12); }
}
@keyframes header-link-shimmer {
  0% { background-position: -240% center; }
  100% { background-position: 240% center; }
}
.header-link {
  position: relative;
  display: inline-block;
  margin-left: auto;
  margin-right: 20px;
  color: #f5c542;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  padding: 6px 20px;
  border: 2px solid #e8a838;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 3px;
  animation: header-link-pulse 2.5s ease-in-out infinite;
  background: linear-gradient(90deg, transparent 30%, rgba(255,200,80,0.15) 48%, rgba(255,220,120,0.25) 50%, rgba(255,200,80,0.15) 52%, transparent 70%);
  background-size: 200% 100%;
  animation: header-link-pulse 2.5s ease-in-out infinite, header-link-shimmer 3s ease-in-out infinite;
  transition: color 0.2s;
}
.header-link:hover {
  color: #fff;
  border-color: #ffd060;
  background: linear-gradient(90deg, transparent 25%, rgba(255,200,80,0.25) 48%, rgba(255,220,120,0.4) 50%, rgba(255,200,80,0.25) 52%, transparent 75%);
  background-size: 200% 100%;
  animation: header-link-pulse 2.5s ease-in-out infinite, header-link-shimmer 1.2s ease-in-out infinite;
  text-shadow: 0 0 12px rgba(255,200,80,0.6);
}

/* 顶部品牌：域名与口号动态展示 */
.brand-top { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; white-space: nowrap; }
.brand-domain { font-size: 26px; font-weight: 800; letter-spacing: 1px; line-height: 1.05;
  background: linear-gradient(90deg, #6fc3ff, #1e7ec7); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; text-shadow: 0 0 14px rgba(111,195,255,0.25); }
.brand-slogan { font-size: 13px; color: #9fd0ff; letter-spacing: 4px; font-weight: 600; }

/* 底部品牌：右下常驻，域名放大加亮 */
.brand-bottom { position: fixed; right: 16px; bottom: 12px; z-index: 5; user-select: none; text-align: right; }
.brand-bottom-domain { display: block; font-size: 18px; font-weight: 800; letter-spacing: 1px; color: #6fc3ff; text-shadow: 0 0 10px rgba(111,195,255,0.3); }
.brand-bottom-slogan { display: block; font-size: 12px; color: #8494ab; letter-spacing: 2px; }

/* 可折叠区块（治具信息默认收缩，点击展开） */
.collapsible .sec-head { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.collapsible .sec-caret { transition: transform 0.15s; display: inline-block; }
.collapsible.collapsed .sec-caret { transform: rotate(-90deg); }
.collapsible.collapsed .sec-body { display: none; }

.btn { display: inline-block; padding: 6px 14px; background: #2b323d; color: #dfe4ea; border: 1px solid #3a4350; border-radius: 6px; cursor: pointer; font-size: 13px; transition: 0.15s; }
.btn:hover { background: #3a4350; }
.btn.primary { background: #1668a8; border-color: #1e7ec7; }
.btn.primary:hover { background: #1e7ec7; }
#status { color: #8ab4f8; font-size: 13px; }

main { flex: 1; display: flex; min-height: 0; }
#panel { width: 300px; min-width: 300px; overflow-y: auto; background: #1a1f27; border-right: 1px solid #2b323d; padding: 12px; }

/* 右侧常驻参数面板 */
#cfgPanel { width: 320px; min-width: 320px; display: flex; flex-direction: column; background: #1a1f27; border-left: 1px solid #2b323d; transition: width .18s ease, min-width .18s ease; }
#cfgPanel.collapsed { width: 0; min-width: 0; border-left: none; overflow: hidden; }
#cfgPanel.collapsed .cfg-panel-head,
#cfgPanel.collapsed .cfg-form,
#cfgPanel.collapsed .cfg-panel-actions,
#cfgPanel.collapsed .cfg-regen-status { opacity: 0; pointer-events: none; }
#cfgPanel .cfg-panel-head, #cfgPanel .cfg-form, #cfgPanel .cfg-panel-actions, #cfgPanel .cfg-regen-status { transition: opacity .12s ease; }
.cfg-panel-head { padding: 12px 14px 6px; border-bottom: 1px solid #2b323d; }
.cfg-panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cfg-panel-title h2 { font-size: 14px; color: #6fc3ff; margin-bottom: 4px; }
.cfg-collapse { flex: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  background: #222831; color: #9fd0ff; border: 1px solid #3a4350; border-radius: 6px; cursor: pointer;
  font-size: 13px; line-height: 1; transition: 0.13s; }
.cfg-collapse:hover { background: #2b323d; border-color: #4a5666; color: #6fc3ff; }
#cfgPanel .cfg-form { flex: 1; overflow-y: auto; display: block; padding: 10px 12px; }
.cfg-panel-actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #2b323d; }
.cfg-panel-actions .btn { flex: 1; text-align: center; }
.cfg-regen-status { min-height: 18px; padding: 0 12px 10px; font-size: 12px; color: #8ab4f8; }
.cfg-regen-status.err { color: #ff8a80; }

/* 参数面板收起后，右侧边缘的竖条把手 */
.cfg-reveal { display: none; position: fixed; right: 0; top: 50%; transform: translateY(-50%);
  background: #1a1f27; color: #9fd0ff; border: 1px solid #3a4350; border-right: none;
  border-radius: 8px 0 0 8px; padding: 12px 5px; writing-mode: vertical-rl; text-orientation: mixed;
  cursor: pointer; font-size: 12.5px; letter-spacing: 1px; z-index: 15; user-select: none;
  box-shadow: -2px 0 12px rgba(0,0,0,0.35); transition: background .13s, color .13s; }
.cfg-reveal:hover { background: #222831; color: #6fc3ff; }
.cfg-reveal.show { display: block; }
#panel section { margin-bottom: 16px; }
#panel h2 { font-size: 13px; color: #9aa8bb; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; border-bottom: 1px solid #2b323d; padding-bottom: 4px; }
.info { font-size: 12.5px; color: #c3ccd9; }
.info table { width: 100%; border-collapse: collapse; }
.info td { padding: 2px 4px; border-bottom: 1px dashed #262d38; vertical-align: top; }
.info td:first-child { color: #8494ab; white-space: nowrap; }
.tag { display: inline-block; padding: 1px 7px; margin: 1px; border-radius: 8px; font-size: 11px; background: #24405c; color: #9fd0ff; }
.tag.warn { background: #5c4a24; color: #ffd79f; }

.exports { display: flex; flex-wrap: wrap; gap: 6px; }
.exports a { padding: 4px 12px; background: #24405c; color: #9fd0ff; border-radius: 6px; text-decoration: none; font-size: 12px; }
.exports a:hover { background: #2d557c; }

.toggles { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.toggles.flow { flex-direction: row; flex-wrap: wrap; gap: 6px 10px; }
.toggles.flow label { background: #222831; border: 1px solid #2b323d; border-radius: 6px; padding: 3px 9px; }
.toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.zoombar { display: flex; gap: 6px; margin-top: 8px; }
.zoombar .btn { padding: 4px 10px; font-size: 12px; }
.exp-sub { width: 100%; font-size: 11px; color: #8494ab; margin: 4px 0 2px; }

/* 多板选项卡 */
.board-tabs { display: none; gap: 6px; padding: 6px 8px; background: #161b22; border-bottom: 1px solid #2b323d; flex-wrap: wrap; }
.board-tabs.show { display: flex; }
.board-tab { padding: 4px 12px; background: #222831; border: 1px solid #2b323d; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: #c3ccd9; }
.board-tab.active { background: #1668a8; border-color: #1e7ec7; color: #fff; }
.board-tab .bt-err { color: #ff8a80; margin-left: 4px; font-size: 11px; }

/* 上传进度遮罩 */
.upload-overlay { display: none; position: absolute; inset: 0; background: rgba(10,12,16,0.82); align-items: center; justify-content: center; z-index: 20; }
.upload-overlay.show { display: flex; }
.upload-box { width: min(420px, 80%); background: #1c2129; border: 1px solid #3a4350; border-radius: 10px; padding: 22px 24px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.upload-title { font-size: 15px; color: #6fc3ff; margin-bottom: 14px; }
.progress { height: 10px; background: #0f1318; border-radius: 6px; overflow: hidden; border: 1px solid #2b323d; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #1e7ec7, #6fc3ff); transition: width 0.2s; }
.upload-status { margin-top: 10px; font-size: 12.5px; color: #8ab4f8; }

/* 顶部居中轻提示 */
#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%) translateY(-8px); background: #1c2129; border: 1px solid #3a4350; border-radius: 8px; padding: 7px 16px; font-size: 13px; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 40; box-shadow: 0 6px 22px rgba(0,0,0,0.45); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 后端连接状态横幅（持续显示，自动重试） */
#connLostBanner {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: linear-gradient(0deg, #3d1515 0%, #4a1c1c 100%);
  border-top: 2px solid #d94535;
  padding: 14px 20px;
  align-items: center; justify-content: center; gap: 14px;
  font-size: 14px; color: #ffb3b0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.55);
  animation: connBannerIn 0.35s ease;
}
#connLostBanner.show { display: flex; }
@keyframes connBannerIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
#connLostBanner .conn-icon { font-size: 20px; line-height: 1; }
#connLostBanner .conn-msg { flex: 1; max-width: 640px; line-height: 1.5; }
#connLostBanner .conn-retry { flex: none; padding: 6px 18px; background: #d94535; color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
#connLostBanner .conn-retry:hover { background: #e85347; }
#connLostBanner .conn-status { flex: none; font-size: 12px; color: #d98a8a; min-width: 80px; }
/* 连接中状态：中性蓝灰，用户知道正在干活 */
#connLostBanner.connecting {
  background: linear-gradient(0deg, #1a2535 0%, #1f2d40 100%);
  border-top-color: #4a90d9;
  color: #a0c8f0;
}

/* 文件列表（默认折叠，可展开） */
.filelist { font-size: 12px; }
.filelist > .fl-head { display: flex; align-items: center; gap: 6px; cursor: pointer; color: #9fd0ff; user-select: none; }
.filelist > .fl-head .fl-caret { transition: transform 0.15s; }
.filelist.collapsed > .fl-head .fl-caret { transform: rotate(-90deg); }
.filelist > .fl-body { display: block; margin: 6px 0 0 14px; }
.filelist.collapsed > .fl-body { display: none; }
.filelist .fl-file { color: #c3ccd9; padding: 1px 0; }
.filelist .fl-file .fl-role { color: #8494ab; font-size: 11px; }

#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* 正/反治具分离显示：右侧悬浮控制 */
.side-sep { position: absolute; top: 10px; right: 10px; z-index: 12; display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  background: rgba(22,27,34,0.92); border: 1px solid #3a4350; border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 22px rgba(0,0,0,0.4); }
.side-sep .ss-toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #c3ccd9; cursor: pointer; user-select: none; }
.side-sep .ss-toggle input { accent-color: #1e7ec7; }
.side-sep .ss-modes { display: flex; gap: 6px; }
.side-sep .ss-mode { padding: 4px 14px; background: #222831; color: #9aa8bb; border: 1px solid #3a4350; border-radius: 6px; cursor: pointer; font-size: 12px; transition: 0.12s; }
.side-sep .ss-mode:hover { background: #2b323d; color: #c3ccd9; }
.side-sep .ss-mode.on { background: #1668a8; border-color: #1e7ec7; color: #fff; font-weight: 600; }
.side-sep .ss-status { font-size: 11.5px; color: #8ab4f8; max-width: 240px; }
.side-sep .ss-status.err { color: #ff8a80; }

/* 分页模式选项卡（合并 / 顶层治具 / 底层治具） */
.side-tabs { display: none; gap: 8px; padding: 6px 8px 0; flex-wrap: wrap; }
.side-tabs.show { display: flex; }
.side-tab { padding: 7px 22px; background: #222831; border: 1px solid #3a4350; border-left: 3px solid #3a4350; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 16px; font-weight: 600; color: #c3ccd9; transition: 0.12s; }
.side-tab:hover { background: #2b323d; color: #e6edf5; }
.side-tab.active { background: #1668a8; border-color: #1e7ec7; border-left-color: #6fc3ff; color: #fff; font-weight: 600; }
.side-tab[data-face="top"].active { border-left-color: #4a90d9; }
.side-tab[data-face="bottom"].active { border-left-color: #d98a4a; }

/* 分页模式下的图例说明条 */
.side-caption { display: none; gap: 18px; flex-wrap: wrap; align-items: center; padding: 5px 10px; background: rgba(22,27,34,0.9); border-top: 1px solid #2b323d; font-size: 12px; color: #c3ccd9; }
.side-caption.show { display: flex; }
.side-caption .sc-item { display: inline-flex; align-items: center; gap: 6px; }
.side-caption .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.side-caption .sw.s-top { background: #4a90d9; }
.side-caption .sw.s-bot { background: #d98a4a; }
#viewer3d { flex: 1; min-height: 0; position: relative; }
#viewer3d canvas { display: block; }
#views2d { display: none; height: 42%; background: #f4f6f8; border-top: 2px solid #2b323d; overflow-x: auto; white-space: nowrap; padding: 6px; }
#views2d.show { display: flex; gap: 6px; }
.view-card { display: inline-flex; flex-direction: column; height: 100%; min-width: 260px; flex: 1; background: #fff; border: 1px solid #d5dbe2; border-radius: 6px; overflow: hidden; }
.view-card .svg-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.view-card svg { width: 100%; height: auto; max-height: 100%; }

.hint { font-size: 12px; color: #8494ab; margin-bottom: 8px; }
.cfg-form .cfg-group { background: #161b22; border: 1px solid #2b323d; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.cfg-group h3 { font-size: 12.5px; color: #9fd0ff; margin-bottom: 6px; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 12.5px; }
.cfg-lbl { color: #c3ccd9; flex: 1; }
.cfg-row select, .cfg-row input[type=checkbox] { accent-color: #1e7ec7; }
.cfg-row select { background: #12151a; color: #dfe4ea; border: 1px solid #3a4350; border-radius: 5px; padding: 3px 6px; font-size: 12px; }
.cfg-hint { flex-basis: 100%; font-size: 11px; color: #7b8794; line-height: 1.4; margin: -2px 0 4px; padding-left: 2px; }
.cfg-ctl { display: flex; align-items: center; gap: 7px; min-width: 130px; }
.cfg-ctl input[type=range] { flex: 1; accent-color: #1e7ec7; }
.cfg-val { min-width: 34px; text-align: right; color: #9fd0ff; font-variant-numeric: tabular-nums; }

/* 凹口方案可点击切换（放在左侧面板最前，点击即重生成） */
.notch-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 6px; }
.notch-opt { display: flex; align-items: center; justify-content: center; padding: 5px 6px;
  background: #222831; color: #c3ccd9; border: 1px solid #3a4350; border-radius: 6px; cursor: pointer;
  text-align: center; transition: 0.13s; line-height: 1.3; }
.notch-opt:hover { background: #2b323d; border-color: #4a5666; }
.notch-opt.on { background: #1668a8; border-color: #1e7ec7; color: #fff; box-shadow: 0 0 0 1px #1e7ec7 inset; }
.notch-opt .nm { font-size: 11.5px; font-weight: 600; }
.notch-enable { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #c3ccd9; margin-top: 2px; cursor: pointer; }
.notch-enable input { accent-color: #1e7ec7; }

/* 凹口方案可点击切换按钮组（右侧参数面板内部仍可用，保持同步） */
.btn-group { display: flex; gap: 5px; flex-wrap: wrap; }
.btn-group button { flex: 1; min-width: 64px; padding: 6px 8px; background: #222831; color: #9aa8bb; border: 1px solid #3a4350; border-radius: 6px; cursor: pointer; font-size: 12px; transition: 0.12s; }
.btn-group button:hover { background: #2b323d; color: #c3ccd9; }
.btn-group button.on { background: #1668a8; border-color: #1e7ec7; color: #fff; font-weight: 600; }

/* 2D 工程图图例（视图区底部） */
.views-legend { display: none; gap: 14px; flex-wrap: wrap; padding: 4px 8px; background: #f4f6f8; border-top: 1px solid #d5dbe2; font-size: 11px; color: #4a525c; }
.views-legend.show { display: flex; }
.views-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.views-legend .sw { width: 16px; height: 0; border-top-width: 2px; border-top-style: solid; }
.lg .sw.s { border-color: #222; }
.lg .sw.hid { border-top-style: dashed; border-color: #888; }
.lg .sw.cen { border-top-style: dotted; border-color: #e0633a; }
.lg .sw.dim { border-color: #2c7; }
.lg .sw.cut { border-color: #222; border-top-width: 3px; }

/* AGPL-3.0 合规页脚：版权声明 + 源码链接 + 担保免责 */
footer {
  margin-top: 24px; padding: 10px 16px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px;
  font-size: 12px; color: #5a6470; border-top: 1px solid #1e2938;
}
footer a { color: #7a8ea0; text-decoration: none; transition: color 0.15s; }
footer a:hover { color: #a8c0d4; }
.footer-disclaimer { opacity: 0.6; }
