/* ===== Global design tokens (added for Project section) ===== */
:root {
  --line: #e5e7eb; /* light gray border */
  --muted: #6b7280; /* slate-500 text */
  --accent: #0ea5e9; /* sky-500 gradient start */
}

.pm-copyright {
  margin-left: 6px;
  font-size: 1rem;
  color: #888;
  vertical-align: middle;
}

/* ========== NAVIGATION BAR ========== */
#navBar {
  display: flex;
  flex-direction: column;
  background-color: #f5f5f5;
  border-bottom: none;
  position: relative;
  padding: 0 12px;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 0;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

#navBar button,
.file-action-group button {
  margin-left: 0.5em;
  padding: 0.5em 1em;
  font-size: 0.95em;
  cursor: pointer;
  white-space: nowrap;
  font-family: system-ui, sans-serif;
  line-height: 1.2em;
}

#navBar button:hover,
.file-action-group button:hover {
  background-color: #eee;
}

#navBar .nav-left button:first-child,
#navBar .nav-right button:first-child,
.file-action-group button:first-child {
  margin-left: 0;
}

/* ======== added for debugging ======== */
#navTopRow button.nav-debug-button {
  margin-left: auto; /* push to the right edge */
  padding: 4px 10px;
  font-size: 0.85rem;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

#navTopRow button.nav-debug-button:hover {
  background-color: #ddd;
}
/* ======== end of debugging ======== */

#modeLabel {
  font-weight: bold;
  font-size: 16px;
  color: #444;
  margin-left: 8px;
}

#navBar .app-title {
  font-weight: bold;
  font-size: 1.75em;
  color: #222;
}

#solutionStatus {
  margin: 0 12px;
  font-weight: bold;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* ===== STATUS GROUP ===== */
.status-group {
  flex: 1; /* expands to fill middle */
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

/* Make status messages bigger and clearer */
#statusGroup span {
  font-weight: 600;
  font-size: 1.05rem;
  color: #444;
}

/* Apply colors only to solution-specific status */
.solution-valid {
  color: green;
}

.solution-invalid {
  color: red;
}

/* --------- navBar PM and Sponsor Identity ------------ */
/* ===== Identity Block ===== */
.nav-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

/* ===== Retailer Identity ===== */
.retailer-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #555;
}

.sponsor-text {
  font-style: italic;
  opacity: 0.85;
}

.retailer-identity img {
  height: 48px;
  width: auto;
}

/* ======== Startup Screen ======== */

/* Startup header row */
.welcome-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px 0 20px;
}

#welcomeTopRow {
  gap: 32px; /* was ~24 — gives sponsor room to breathe */
}

/* Title: controls BOTH text and logo scale */
.welcome-title {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-size: 2rem;
  font-weight: 700;
}

/* PNG/SVG logo image */
.wm-logo {
  height: 5.5em;
  width: auto;
  vertical-align: middle;
}

.wm-word {
  line-height: 1.1;
}

#welcomeTopRow {
  gap: 24px;
}

/* Sponsor block */
.sponsor-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sponsor-block {
  align-items: center;
  margin-top: 4px;
}

.sponsor-text {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.8;
}

#retailerLogo {
  height: 80px; /* sponsor prominence */
  width: auto;
}

/* Shrink PlyMiser logo when sponsored */
#brandingBlock.sponsored .wm-logo {
  height: 4em; /* smaller than default 5.5em */
  transition: height 0.3s ease;
}

/* Small screens */
@media (max-width: 420px) {
  .welcome-title {
    font-size: 1.5rem;
  }
}

/* ========== FILE ACTION GROUPS ========== */
.file-action-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-left: 0.5em;
}

.file-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Products file actions: blue buttons with blue border */
.file-action-group.theme-products button {
  background-color: #f0f7ff;
  border: 1px solid #66aaff;
  border-radius: 4px;
}

/* Pieces file actions: NO surrounding bar border, individual buttons with hard green border */
#piecesSection .file-action-container,
#piecesSection .file-action-group.theme-pieces {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

/* Individual Pieces buttons: hard green border */
#piecesSection .file-action-group.theme-pieces button {
  background-color: #f4fff0;
  border: 2px solid #2e7d32; /* hard green */
  border-radius: 4px;
  padding: 6px 12px;
}

/* ========== SECTION THEMES ========== */

.theme-pieces {
  background-color: #f4fff0;
}

.theme-project {
  background-color: #fffaf0;
}

.theme-results {
  background-color: #fef0f7;
}

.section-theme {
  padding: 12px;
  border-radius: 8px;
}

#piecesSection {
  background-color: #f4fff0;

  height: calc(100vh - 120px); /* 🔥 force constraint */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== NAV BUTTON HIGHLIGHTING ========== */
#btnNavProducts {
  background-color: #f0f7ff;
  border: 1px solid #66aaff;
}

#btnNavPieces {
  background-color: #f4fff0;
  border: 1px solid #66cc66;
}

#btnNavProject {
  background-color: #fffaf0;
  border: 1px solid #e6b800;
}

#btnNavResults {
  background-color: #fef0f7;
  border: 1px solid #cc6699;
}

/* ========== INPUT CONTROL GROUPS ========== */
.sectionInputControls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 1.5em;
  margin-top: 1.5em;
}

.model-actions {
  display: flex;
  flex-direction: row;
  gap: 10px;
  padding: 6px 0;
}

/* ========== SANDBOX PANEL ========== */
.sandboxPanel {
  margin-top: 20px;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background-color: #fefefe;
  max-width: 800px;
}

/* ========== STARTUP SCREEN ========== */
#startupScreen {
  text-align: center;
  padding: 4em 2em;
  background-color: #f9f9f9;
  border: 1px solid #ccc;
  border-radius: 8px;
  max-width: 600px;
  margin: 4em auto;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#startupScreen p {
  font-size: 1.2em;
  color: #333;
}

#startupScreen button {
  margin: 0.5em;
  padding: 0.6em 1.4em;
  font-size: 1em;
  cursor: pointer;
  border-radius: 5px;
  border: 1px solid #bbb;
  background-color: #fff;
  transition: background-color 0.2s ease;
}

#startupScreen button:hover {
  background-color: #f0f0f0;
}

/* ========== MODE WARNING BANNER ========== */
.mode-banner {
  background-color: #fff4ce;
  color: #333;
  padding: 12px 16px;
  margin: 0 10px 12px 10px;
  border-left: 6px solid #ffa500;
  font-weight: bold;
  font-size: 0.95rem;
  border-radius: 6px;
}

/* ========== ALERT / MODAL ========== */
.wm-alert {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.wm-alert-content {
  background-color: #ffffff; /* clean white */
  color: #222; /* neutral text */
  border: 1px solid #ddd; /* subtle edge */
  padding: 2em 2.2em;
  border-radius: 8px;
  max-width: 520px;
  font-size: 1.05em;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.wm-alert-button {
  margin-top: 1.8em;
  padding: 0.6em 1.6em;
  font-size: 0.95em;
  font-weight: 600;
  background-color: #ffffff;
  border: 1px solid #ccc;
  color: #333;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wm-alert-button:hover {
  background-color: #f5f5f5;
  border-color: #999;
}

.wm-modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* semi-transparent background */
  justify-content: center;
  align-items: center;
}

.wm-modal.show {
  display: flex; /* Makes the dialog visible */
}

.wm-modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 400px;
  max-width: 90%;
  text-align: center;
}

.wm-modal-buttons {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
}

/* ========= wm-model key confirmation ========= */
#wmConfirmKey .wm-modal-content {
  text-align: center;
}

#wmConfirmKey input {
  margin-top: 0.5em;
  margin-bottom: 1em;
  width: 60%;
  padding: 0.4em;
  font-size: 1em;
  text-align: center;
}

#wmConfirmKey .wm-modal-buttons {
  display: flex;
  justify-content: center;
  gap: 1em;
}

#wmConfirmKey button {
  padding: 0.5em 1.2em;
  border-radius: 6px;
  font-size: 1em;
}

.wm-modal-title {
  margin-top: 0;
  margin-bottom: 0.5em;
  font-size: 1.25em;
  font-weight: bold;
  text-align: center;
}

/* ========== STATUS HIGHLIGHTING ========== */
.stranded-product {
  background-color: #ffe5e5;
}

.warning-product {
  background-color: #fff3cd;
}

/* Disabled Table State */
.table-disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* =====================================================================
   PIECES: bring visuals/behavior in line with Products without duplication
   ===================================================================== */

/* Shared filter controls for both sections */
.piece-filter-controls fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  border: none;
  padding: 0;
  margin: 0;
}

/* “x of y” message for Pieces (parallel to Products) */
.pieces-displayed-msg {
  margin-top: 6px;
  font-style: italic;
  font-size: 0.95em;
  color: #444;
}

/* ===== Pieces Input Fields (mirror of Products) ===== */
#pieceInputs {
  margin-left: 0;
  padding-left: 12px; /* match products */
}

.pieceInputRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
  margin-left: 0;
}

.pieceInputRow label {
  width: 120px;
  text-align: right;
  font-weight: normal;
}

.pieceInputRow input,
.pieceInputRow select,
.pieceInputRow textarea {
  width: 150px;
  padding: 4px 6px;
  font-size: 0.95em;
}
.piecedesignation-group {
  display: flex;
  align-items: center;
  gap: 4px; /* tighten spacing between all children */
}

.piecedesignation-group > label:first-child {
  margin-right: 5px; /* space after "Designation:" label */
}

.piecedesignation-group .radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 0px; /* space between button and label */
  margin: 0;
  padding: 0;
}

/* ===== Pieces Table (mirror of Products) ===== */

/* ========== Piece Table Wrapper (Scrollable) ========== */
.piece-table-wrapper {
  /* max-height: calc(100vh - 260px);  */
  /* max-height: calc(100vh - 360px);  */
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ccc;
  margin-top: 10px;
}

#pieceTable {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9em;
  margin-top: 10px;
}

#pieceTable th {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
  background-color: #f0f0f0;
  font-weight: bold;
  white-space: nowrap; /* headers stay single-line */
}

#pieceTable td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;

  /* ✅ wrapping behavior */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;

  /* optional: remove ellipsis */
  overflow: visible;
  text-overflow: clip;
}

#pieceTable th {
  background-color: #f0f0f0;
  font-weight: bold;
}

/* Highlight selected row */
#pieceTable tbody tr.selected-row {
  background-color: #ffffcc !important;
}

/* Hover highlight */
#pieceTable tr:hover {
  background-color: #eef;
  cursor: pointer;
}

.matchable-yes {
  color: green;
  font-weight: bold;
}

.matchable-no {
  color: red;
  font-weight: bold;
}

/* pieceTable icons */
#pieceTable td.piece-ok {
  text-align: center;
  width: 3rem;
}

#pieceTable td.piece-ok .ok {
  color: #16a34a;
  font-weight: 700;
}

#pieceTable td.piece-ok .x {
  color: #dc2626;
  font-weight: 700;
}

/* ===== Pieces heading + notes sizing to match Products ===== */
#piecesSection h2 {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

#piecesSection .section-subheading {
  margin-top: 0;
  margin-bottom: 0.25em;
}

#inpPieceNotes {
  width: 600px;
  min-height: 2.5em;
  resize: vertical;
  font-size: 1.2em;
  line-height: 1.4;
}

.pieceNotesRow .notesWrapper {
  position: relative;
  display: inline-block;
}

.pieceCanRotateLabel.moved {
  position: absolute;
  right: -150px; /* adjust left/right spacing from Notes box */
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 1em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pm-logo {
  height: 50px; /* tweak until it looks right */
  width: auto;
  vertical-align: middle;
  margin-right: 6px;
}

.usable-yes {
  color: green;
  font-weight: bold;
}

.usable-no {
  color: red;
  font-weight: bold;
}

/* ===== Material Help Button ===== */
.material-help-btn {
  margin-left: 6px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  padding: 2px 6px;
  border: 2px solid #000; /* darker, thicker frame */
  background: #fff;
  color: #000;
  border-radius: 4px;
  line-height: 1;
}

.material-help-btn:hover {
  background: #eee;
}

/* Ensure all file-action groups take up identical space */
.file-action-group {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  display: flex;
  align-items: center; /* keeps buttons vertically aligned */
  gap: 8px;
}

.file-action-group button {
  padding: 6px 12px; /* consistent across all sections */
  font-size: 0.95rem;
  border-radius: 4px;
  border: 1px solid #ccc; /* if you want theme color, override only border-color */
}

/* ===== Parameterized Piece Fields ===== */

/* Parameterized & resolved */
#piecesSection input.param-ok {
  background-color: #f0f7ff; /* soft neutral / derived */
}

/* Parameterized & error (missing, circular, etc.) */
#piecesSection input.param-error {
  background-color: #ffe5e5; /* consistent with stranded-product */
}

/* =====================================================
   Parameterized Piece Table Cells (scoped to Pieces only)
   ===================================================== */

/* Base safety: do NOT affect other tables */
#piecesSection #pieceTable td.param-ok,
#piecesSection #pieceTable td.param-error {
  font-weight: 600; /* subtle emphasis */
}

/* Parameterized & resolved (green, calm) */
#piecesSection #pieceTable td.param-ok {
  background-color: #e8f5e9; /* soft green */
  color: #14532d; /* dark green text */
}

/* Parameterized & error (red, readable) */
#piecesSection #pieceTable td.param-error {
  background-color: #fdecea; /* soft red */
  color: #7f1d1d; /* dark red text */
}

/* Optional visual cue (safe, non-intrusive) */
#piecesSection #pieceTable td.param-error::after {
  content: ' ⚠';
  font-size: 0.85em;
}

/* Ensure selected row always wins over cell-level coloring */
#pieceTable tbody tr.selected-row td {
  background-color: #ffffcc !important;
}
