/* stanley.mfautomations.ai — blueprint annotator styles (owner: annotator task)
   Uses the design tokens defined in styles.css (:root, dark-mode overrides). This file only
   sets structure + color for the .sa-* tree that annotate.js builds; it never sets SVG
   geometry (stroke-width/r/font-size), which annotate.js computes per image scale and sets as
   inline attributes — CSS declaring those would win the cascade and break that scaling. */

.sa-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--font-body, sans-serif);
  color: var(--ink, #17231C);
}

/* ---------- Toolbar ---------- */
.sa-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.sa-toolbar-spacer { flex: 1 1 auto; }
.sa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line, #D5DBD3);
  background: var(--surface, #FFFFFF);
  color: var(--ink, #17231C);
  border-radius: var(--radius, 4px);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 11px;
  cursor: pointer;
  min-height: 36px;
}
.sa-btn:hover { background: var(--line, #D5DBD3); }
.sa-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.sa-btn:focus-visible {
  outline: 2px solid var(--accent-2, #1F7A93);
  outline-offset: 2px;
}

/* ---------- Viewport (pan/zoom stage) ---------- */
.sa-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--radius, 4px);
  border: 1px solid var(--line, #D5DBD3);
  background: var(--line, #D5DBD3);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.sa-inner {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}
.sa-image {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.sa-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Hint line ---------- */
.sa-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted, #5C6B62);
  min-height: 16px;
}

/* ---------- Slot rail ---------- */
.sa-rail { display: flex; flex-direction: column; }
.sa-rail-group-label {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #5C6B62);
  margin: 10px 0 2px;
}
.sa-rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--line, #D5DBD3);
  background: transparent;
  padding: 10px 6px;
  min-height: 44px;
  cursor: pointer;
  color: var(--ink, #17231C);
  font: inherit;
}
.sa-rail-item.sa-active { background: rgba(46, 107, 59, 0.1); }
.sa-rail-item:focus-visible {
  outline: 2px solid var(--accent-2, #1F7A93);
  outline-offset: -2px;
}
.sa-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--line, #D5DBD3);
  background: transparent;
  flex: none;
}
.sa-rail-item[data-status="filled"] .sa-dot { background: var(--ok, #2E6B3B); border-color: var(--ok, #2E6B3B); }
.sa-rail-item[data-status="partial"] .sa-dot { background: var(--warn, #B26A00); border-color: var(--warn, #B26A00); }
.sa-rail-id {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--muted, #5C6B62);
  width: 28px;
  flex: none;
}
.sa-rail-name { font-size: 13.5px; flex: 1; }

/* ---------- Summary ---------- */
.sa-summary { border-top: 1px solid var(--line, #D5DBD3); padding-top: 6px; }
.sa-summary-toggle {
  background: none; border: none; padding: 6px 0;
  color: var(--accent-2, #1F7A93); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.sa-summary-list { margin: 4px 0 0; padding: 0; list-style: none; }
.sa-summary-list li {
  font-size: 12.5px; color: var(--muted, #5C6B62);
  padding: 4px 0; border-bottom: 1px dashed var(--line, #D5DBD3);
}

/* ---------- JSON export/import panel ---------- */
.sa-json-panel { border-top: 1px solid var(--line, #D5DBD3); padding-top: 8px; }
.sa-json-text {
  width: 100%;
  min-height: 140px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--ink, #17231C);
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--line, #D5DBD3);
  border-radius: var(--radius, 4px);
  padding: 8px;
  resize: vertical;
}
.sa-json-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---------- SVG element coloring (geometry set inline by annotate.js) ---------- */
.sa-pin-dot { fill: var(--accent-2, #1F7A93); stroke: var(--surface, #FFFFFF); }
.sa-pin-arrow { stroke: var(--accent-2, #1F7A93); }
.sa-pin-arrowhead { fill: var(--accent-2, #1F7A93); }
.sa-pin-label {
  fill: var(--ink, #17231C);
  paint-order: stroke;
  stroke: var(--surface, #FFFFFF);
  stroke-linejoin: round;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
}
.sa-pin-hit { fill: transparent; pointer-events: all; cursor: grab; }
.sa-pin-handle { fill: var(--warn, #B26A00); stroke: var(--surface, #FFFFFF); pointer-events: all; cursor: grab; }
.sa-pin.sa-pin-active .sa-pin-dot { stroke: var(--critical, #B3261E); }

.sa-path-line { stroke: var(--accent, #2E6B3B); fill: none; }
.sa-path-arrowhead { fill: var(--accent, #2E6B3B); }
.sa-path-start { fill: var(--critical, #B3261E); stroke: var(--surface, #FFFFFF); }
.sa-path-end { fill: var(--ink, #17231C); stroke: var(--surface, #FFFFFF); }
.sa-path-point { fill: var(--accent, #2E6B3B); stroke: var(--surface, #FFFFFF); }
.sa-path-label {
  fill: var(--ink, #17231C);
  paint-order: stroke;
  stroke: var(--surface, #FFFFFF);
  stroke-linejoin: round;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
}
.sa-path.sa-path-active .sa-path-line { stroke: var(--accent-2, #1F7A93); }

/* ---------- Responsive: tablet/desktop ---------- */
@media (min-width: 760px) {
  .sa-viewport { aspect-ratio: 3 / 2; }
  .sa-root { max-width: 100%; }
}

/* Never let the widget cause page overflow at 390px */
.sa-root, .sa-viewport, .sa-rail-item { max-width: 100%; }
