/* ============================================================
   DRAWING LAYOUT  (Viewport + Mid Controls + Right Info Panel)
   ============================================================ */

#drawingSection {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fff;
}

/* Leftmost: SVG Viewport */
#viewport {
  flex: 1 1 auto; /* take all remaining width */
  min-width: 0; /* prevents overflow cutoff */
  border-right: 1px solid #ccc;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   MIDDLE CONTROL TOWER
   (Zoom, Pan, View, and Legend Panels)
   ============================================================ */

#drawMidPanel {
  width: 170px; /* slightly wider for balanced proportions */
  background: #f7f7f7;
  border-right: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.75rem 0.5rem;
  box-sizing: border-box;
  gap: 1rem;
}

/* ---------- Zoom Controls ---------- */
#panelZoomCtls {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem;
  gap: 4px;
  width: 80%;
}

#inpZoomPct {
  width: 60px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 2px 0;
  font-size: 0.9rem;
}

#panelZoomCtls button {
  width: 28px;
  height: 28px;
  line-height: 1;
  font-weight: bold;
}

/* ---------- Pan Controls ---------- */
#panelPanCtls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem;
  width: 80%;
}

.pan-middle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 4px 0;
}

/* Base buttons */
#panelPanCtls button {
  width: 28px;
  height: 28px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

#panelPanCtls button:hover {
  background: #e8f0ff;
  border-color: #99b4e8;
}

/* Home button styling */
#btnPanHome {
  background: #f9fafb;
  border: 1px solid #bbb;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 600;
}

#btnPanHome:hover {
  background: #fff6e5;
  border-color: #f0b429;
  box-shadow: 0 0 4px rgba(255, 200, 0, 0.5);
}

#btnPanHome:active {
  background: #ffe9a8;
  border-color: #e0a700;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.15);
}

/* ---------- Edge Legend ---------- */
#panelLegend {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  width: 80%;
  gap: 0.25rem;
}

.legend-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 2px solid #333;
}

/* Individual line colors */
.legend-line.factory {
  border-color: #000;
}
.legend-line.driveway {
  border-color: #d00;
}
.legend-line.chopsaw {
  border-top: 2px dashed #000;
}
.legend-line.ripfence {
  border-color: #4caf50;
}
.legend-line.mitergauge {
  border-color: #a00;
}
.legend-line.sled {
  border-color: #c45ee0;
}

/* ============================================================
   RIGHT PANEL  (Info & Navigation)
   ============================================================ */

#drawRightPanel {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.5rem 1rem;
  background-color: #f8f8f8;
  box-sizing: border-box;
  overflow-y: auto;
  border-left: 1px solid #ccc;
  gap: 0.75rem; /* space between stacked boxes */
}

/* Unified box styling for panelSheet, panelSequencer, panelPiece */
.right-panel-box {
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  box-shadow: inset 0 0 0 1px #fff;
}

/* ============================================================
   PANEL OPTIONS  (Label + checkboxes)
   ============================================================ */

#panelOptions {
  display: flex;
  flex-direction: column; /* stacked label + row of checkboxes */
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  background: #fafafa;
  box-shadow: inset 0 0 0 1px #fff;
}

/* Header label */
#lblOptions {
  font-weight: 600;
  font-size: 1rem;
  color: #333;
  margin: 0;
}

/* Container for the checkboxes */
.options-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap; /* wraps neatly on narrow screens */
  gap: 0.8rem;
  width: 100%;
}

/* Each checkbox + label pair */
.option-entry {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.option-entry input[type='checkbox'] {
  transform: scale(1.1);
  cursor: pointer;
}

.option-entry label {
  cursor: pointer;
  color: #222;
  font-size: 0.95rem;
}

/* ============================================================
   SHEET PANEL
   ============================================================ */

#panelSheet {
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  box-shadow: inset 0 0 0 1px #fff;
}

.sheet-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.sheet-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
}

#lblSheet {
  font-weight: 600;
}

#textSheet {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  height: 180px; /* fixed height, scrollable */
  overflow-y: auto;
  padding: 0.5rem;
  font-size: 0.9em;
  color: #333;
  box-sizing: border-box;
}

/* ============================================================
   PANEL SEQUENCE  (Match look of Sheet and Piece)
   ============================================================ */

#panelSequence {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  background: #fafafa;
  box-shadow: inset 0 0 0 1px #fff;
}

/* Top row: label, counter, and buttons on one line */
#panelSequence .seq-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

/* Label and counter styling */
#lblSequence {
  font-weight: 600;
  font-size: 1rem;
  color: #333;
  font-style: normal !important; /* override italics */
}

#lblSeqNum {
  font-size: 0.9rem;
  color: #333;
  margin-left: 0.5rem;
}

/* Navigation buttons */
.seq-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  margin-left: auto; /* keep buttons on the right */
}

#panelSequence button {
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
}

/* ============================================================
   PIECE PANEL
   ============================================================ */

#panelPiece {
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  box-shadow: inset 0 0 0 1px #fff;
}

.piece-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.piece-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
}

#lblPiece {
  font-weight: 600;
}

#textPiece {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  height: 180px; /* fixed height, scrollable */
  overflow-y: auto;
  padding: 0.5rem;
  font-size: 0.9em;
  color: #333;
  box-sizing: border-box;
}

/* ============================================================
   SHARED TWEAKS
   ============================================================ */

.panel-textbox::-webkit-scrollbar {
  width: 6px;
}
.panel-textbox::-webkit-scrollbar-thumb {
  background-color: #ccc;
  border-radius: 3px;
}
/* Decorations: selection highlights */
.highlightRect {
  fill: none;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none; /* clicks pass through */
}

/* Panel (sheet) highlight — bright cyan */
#panelHighlightRect {
  stroke: cyan;
  filter: drop-shadow(0 0 6px rgba(0, 255, 255, 0.6));
}

/* Piece highlight — cyan contrast */
#pieceHighlightRect {
  stroke: cyan;
  filter: drop-shadow(0 0 6px rgba(0, 255, 255, 0.6));
}

/* Remnant highlight — cyan contrast */
#remnantHighlightRect {
  stroke: cyan;
  filter: drop-shadow(0 0 6px rgba(0, 255, 255, 0.6));
}

/* Hidden state */
.hidden {
  display: none;
}

/* ============================================================
   KEYBOARD SHORTCUT PANEL — Overlay on Drawing Section
   ============================================================ */
#keyShortcutPanel {
  position: fixed; /* detach from flex layout entirely */
  inset: 0; /* fill viewport */
  display: none; /* hidden by default */
  justify-content: center; /* center modal box */
  align-items: center;
  background-color: rgba(0, 0, 0, 0.45); /* translucent overlay */
  z-index: 9999; /* higher than viewport & other modals */
}

#keyShortcutPanel:not(.hidden) {
  display: flex; /* show when .hidden removed */
}

#keyShortcutPanel .wm-modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  width: 480px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  text-align: left;
}

#keyShortcutPanel .wm-modal-title {
  font-weight: bold;
  font-size: 1.2rem;
}

#keyShortcutPanel .wm-modal-close {
  float: right;
  font-size: 1.1rem;
  cursor: pointer;
  border: none;
  background: none;
}

.key-shortcut-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.key-shortcut-table td {
  padding: 4px 8px;
  vertical-align: top;
}

.key-shortcut-table td.keys {
  font-weight: bold;
  width: 35%;
  white-space: nowrap;
}
/* Optional smooth fade-in/out */
#keyShortcutPanel {
  opacity: 0;
  transition: opacity 0.2s ease;
}
#keyShortcutPanel:not(.hidden) {
  opacity: 1;
}
