/* SIS-style assembly page: three-column layout with yellow-highlight tree,
 * Group Part info block, and clean parts table.
 * Loaded AFTER style.css so it overrides the default look.
 */

/* ===== Layout ===== */
.asm-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
  margin-top: 0;
  height: calc(100vh - 120px);
  overflow: hidden;
}

/* ===== Left: System Groups tree — SIS style, expands DOWN not right ===== */
.tree-panel {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  border-radius: 0;
  box-shadow: none;
  font-size: 12px;
  overflow-y: auto;
  max-height: 100%;
  position: static;
  top: auto;
}

.tree-panel-header {
  padding: 8px 12px;
  font-weight: 700;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: #333;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}

.tree-body { padding: 0; }

.tree-loading, .tree-empty {
  padding: 10px 12px;
  color: #666;
  font-size: 12px;
}

/* Reset the global sidebar .tree-node rules (padding 5px 16px, flex, gap)
 * that leaked into this panel — indent must come ONLY from .tree-row. */
#asm-tree .tree-node {
  padding: 0;
  display: block;
  gap: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.tree-node { user-select: none; }

/* Three-level indent: top 8px, child +14 (22px), assembly +28 (36px).
 * Each level lists DOWN vertically; sub-levels indent RIGHT one step. */
.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 0;
  cursor: pointer;
  line-height: 1.3;
  overflow: hidden;
  min-width: 0;
}

.tree-row .tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.tree-row:hover { background: #f0f4f8; }

/* Blue arrows like SIS */
.tree-row .arrow {
  width: 12px;
  color: #0066cc;
  flex-shrink: 0;
  font-size: 10px;
  text-align: center;
  font-weight: 700;
}

.tree-node.top > .tree-row {
  font-weight: 700;
  font-size: 12px;
  color: #222;
  padding-left: 8px;
}

.tree-node.child > .tree-row {
  font-weight: 500;
  font-size: 12px;
  color: #444;
  padding-left: 22px;
}

.tree-node.asm > .tree-row {
  font-size: 11px;
  color: #555;
  padding: 3px 8px 3px 36px;
}

.tree-node.asm .tree-name { font-weight: 500; }
.tree-node.asm .tree-sub {
  display: block;
  color: #888;
  font-size: 10px;
  padding-left: 26px;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Assembly-level part rows jump straight to their own assembly page */
.pn-link.asm-link { color: #1565c0; }
.pn-link.asm-link::after {
  content: '\21D2';
  font-size: 11px;
  margin-left: 3px;
  vertical-align: 1px;
  color: #1565c0;
}

/* Part dimension modifier, e.g. "(10-32X0.75-IN)" */
.mod { color: #666; font-size: 12px; }

/* Ref/note badge in part name cell */
.tag {
  display: inline-block;
  background: #333;
  color: #fff;
  border-radius: 3px;
  font-size: 10px;
  padding: 0 5px;
  line-height: 15px;
  margin-right: 4px;
  font-weight: 600;
}

/* Current path: light-blue highlight (SIS style) */
.tree-node.top.current > .tree-row,
.tree-node.child.current > .tree-row,
.tree-node.asm.current > .tree-row {
  background: #E8F0FE;
  color: #1A73E8;
}

.tree-node.top.current > .tree-row:hover,
.tree-node.child.current > .tree-row:hover,
.tree-node.asm.current > .tree-row:hover {
  background: #E8F0FE;
}

.tree-row.dim {
  color: #999;
  cursor: default;
}
.tree-row.dim:hover { background: transparent; }
.tree-row.dim .tree-name { opacity: 0.6; }

.tree-children {
  display: none;
  padding-left: 0;
}
.tree-children.open { display: block; }

.tree-badge {
  background: #e9ecef;
  color: #666;
  border-radius: 8px;
  font-size: 10px;
  padding: 0 6px;
  line-height: 15px;
  flex-shrink: 0;
  margin-left: auto;
}

.tree-node.current > .tree-row .tree-badge {
  background: #1A73E8;
  color: #fff;
}

.pn-mono { font-family: ui-monospace, Consolas, monospace; }
.tree-row .pn-mono { font-size: 12px; font-weight: 600; }

/* ===== Middle: Figure ===== */
.asm-figure {
  flex: 1;
  min-width: 0;
  padding: 8px;
  overflow-y: auto;
  max-height: 100%;
}

/* No-image placeholder */
.no-image{display:flex;align-items:center;justify-content:center;min-height:300px;border:1px dashed #ccc;border-radius:6px;background:#fafafa}
.no-image-text{color:#999;font-size:14px}

.img-main {
  position: relative;
  overflow: hidden;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-main img, .img-main canvas.raw-cgm {
  display: block;
  max-width: none;
  max-height: none;
}

.img-nav {
  display: flex;
  flex-wrap: wrap;        /* user: no scrollbar — show all thumbs */
  align-items: flex-start; /* per-drawing adaptive heights, top-aligned */
  gap: 6px;
  margin-top: 6px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

/* Assembly thumb strip: width fixed, HEIGHT follows each drawing's own
   aspect ratio (portrait tall / landscape short) — whole drawing, never
   cropped, no dead margins. Scoped to img.img-thumb so part-page anchor
   cards (.part-thumbs .img-thumb) are untouched. User-approved 2026-09-08. */
img.img-thumb {
  width: 64px;
  height: auto;
  max-height: 110px;      /* sanity cap for extreme ratios */
  object-fit: contain;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  background: #f8f9fa;
  display: block;
}

img.img-thumb:hover { border-color: #999; }
img.img-thumb.active { border-color: #1A73E8; }

.zoom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  width: max-content;
}

.zoom-bar button {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 3px;
  padding: 1px 8px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
}

.zoom-bar button:hover { background: #f0f0f0; }
.zoom-pct { min-width: 44px; text-align: center; font-size: 12px; color: #666; }

/* ===== Right: Parts info ===== */
.asm-parts {
  width: 380px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  border-radius: 0;
  box-shadow: none;
  overflow-y: auto;
  max-height: 100%;
  position: static;
  top: auto;
  padding: 12px;
}

/* Group Part header */
.group-part-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #333;
}

.group-part-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin: 0 0 4px;
  line-height: 1.3;
}

/* Group title note line (2nd <BR> segment, e.g. "S/N HWA1-UP") */
.group-part-title .t-sub {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: #666;
  margin-top: 2px;
}

.group-part-subtitle {
  font-size: 13px;
  color: #666;
  margin: 0;
}

/* Parts table */
.asm-parts table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0;
}

.asm-parts th {
  text-align: left;
  padding: 8px 6px;
  font-weight: 600;
  font-size: 12px;
  color: #333;
  border-bottom: 2px solid #333;
  background: #f8f9fa;
}

.asm-parts td {
  padding: 6px;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: top;
}

.asm-parts tr:hover td { background: #f8f9fa; }

/* Part number: click-to-expand. Copy lives in a fixed right column. */
.pn-cell {
  position: relative;
  white-space: nowrap;
  padding-right: 8px !important;
}

.pn-link {
  color: #0066cc;
  text-decoration: none;
  font-weight: 500;
  font-family: ui-monospace, Consolas, monospace;
  cursor: pointer;
}

.pn-link:hover { text-decoration: underline; }
.pn-link.open { color: #137333; }

td.copy-cell {
  width: 40px;
  text-align: right;
  white-space: nowrap;
  padding-right: 8px !important;
}

/* Override the old hover-in-cell copy button (display:none + absolute). */
td.copy-cell .copy-btn {
  display: inline-flex;
  position: static;
  transform: none;
  right: auto;
  top: auto;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: #fff;
  color: #5f6b7a;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}
td.copy-cell .copy-btn:hover {
  color: #1A73E8;
  border-color: #1A73E8;
  background: #fff;
}
td.copy-cell .copy-btn.copied {
  color: #137333;
  border-color: #137333;
}

/* Expand card on the light SIS assembly table */
.asm-parts tr.part-info-row td.part-info-cell {
  background: #f0f6ff;
  padding: 0;
}
.asm-parts .part-info-card {
  padding: 10px 14px;
  font-size: 13px;
  border-left: 3px solid #1A73E8;
  background: #f8fbff;
  color: #1a1a2e;
}
.asm-parts .part-info-head .pn { color: #1a1a2e; }
.asm-parts .part-info-head .name { color: #5f6b7a; }
.asm-parts .part-info-head a { color: #1A73E8; }
.asm-parts .kv .k,
.asm-parts .sec-label { color: #6b7280; }
.asm-parts .kv .v { color: #1a1a2e; font-weight: 600; }
.asm-parts .chip {
  background: #E8F0FE;
  color: #1A73E8;
  border: 1px solid #c6dafc;
}
.asm-parts a.chip:hover { background: #d2e3fc; text-decoration: none; }
.asm-parts .chip .d { color: #5f6b7a; }

.pi-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  max-width: 560px;
}
.pi-head {
  padding: 9px 14px;
  background: #f8fafc;
  font-weight: 600;
  font-size: 13px;
  color: #1a1a2e;
  border-bottom: 1px solid #e5e7eb;
}
.pi-kv .k { color: #6b7280; }
.pi-kv .v { color: #1a1a2e; }

/* Ref row highlight */
tr[data-ref-row].ref-hit td {
  background: #fff3c4;
  transition: background 1s;
}

/* Responsive */
@media (max-width: 1200px) {
  .asm-layout { flex-direction: column; height: auto; overflow: visible; }
  .tree-panel { width: 100%; max-height: 300px; border-right: none; border-bottom: 1px solid #e0e0e0; }
  .asm-figure { max-height: none; }
  .asm-parts { width: 100%; max-height: none; border-left: none; border-top: 1px solid #e0e0e0; }
}

/* Assembly pages: families sidebar collapsed by default but expandable via ☰ */
body:has(.tree-panel) .tree-sidebar.collapsed { display: none; }
body:has(.tree-panel) .main-with-tree.expanded { margin-left: 0; padding-left: 0; }

/* Assembly pages: drop the 1100px container cap so the three columns use
 * the full window width (no wasted side margins on wide screens). */
body:has(.tree-panel) .container { max-width: none; padding: 8px 10px; }

/* Annotation styles (keep existing) */
.anno-layer { position: absolute; inset: 0; pointer-events: none; }
.anno {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 18px;
  height: 18px;
  padding: 0 3px;
  border-radius: 9px;
  background: #fff;
  border: 1.5px solid #d32f2f;
  color: #d32f2f;
  font: 700 11px/15px sans-serif;
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  z-index: 5;
}
.anno:hover { background: #d32f2f; color: #fff; }
/* Light-theme empty note (SIS pages) */
.asm-parts .empty-note,
.pi-card .empty-note { color: #94a3b8; }
.asm-parts .more,
.pi-card .more { color: #6b7280; font-size: 12px; }

/* ===== Column splitter handles (drag to resize, 2026-09-04) ===== */
.asm-layout { position: relative; }
.spl-l, .spl-r {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16px;            /* generous hit area (user: "点不太上") */
  margin-left: -8px;      /* center the hit area on the column border */
  cursor: col-resize;
  z-index: 40;
  touch-action: none;
}
.spl-l::after, .spl-r::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;              /* visual 4px bar centered in the 16px hit area */
  width: 4px;
  background: transparent;
  transition: background .12s;
}
.spl-l:hover::after, .spl-r:hover::after,
.spl-l:active::after, .spl-r:active::after {
  background: #1A73E8;
}
body.col-resizing {
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
}
body.col-resizing iframe { pointer-events: none; }

/* Vertical (narrow) layout: no splitters */
@media (max-width: 1200px) {
  .spl-l, .spl-r { display: none; }
}
