/* ==========================================================================
   path_canvas.css — Styles for Interactive Path Model & DAG Canvas Builder
   ========================================================================== */

.path-builder-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.path-builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.path-builder-toolbar__left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.path-builder-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #1e293b;
}

.path-builder-status-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 600;
}

.path-builder-status-badge--success {
  background: #dcfce7;
  color: #15803d;
}

.path-builder-status-badge--error {
  background: #fee2e2;
  color: #b91c1c;
}

.path-builder-status-badge--info {
  background: #e0f2fe;
  color: #0369a1;
}

.path-builder-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.path-btn {
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.path-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.path-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.path-btn--tidy {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.path-btn--tidy:hover:not(:disabled) {
  background: #dbeafe;
  border-color: #93c5fd;
}

.path-btn--primary {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
}

.path-btn--primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.path-btn--danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
}

.path-btn--danger:hover:not(:disabled) {
  background: #ffe4e6;
}

/* Templates Dropdown */
.path-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.path-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 50;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  padding: 0.25rem;
}

.path-dropdown-menu.hidden {
  display: none;
}

.path-dropdown-menu button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  border-radius: 5px;
  cursor: pointer;
  color: #334155;
}

.path-dropdown-menu button:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.path-dropdown-menu button.danger {
  color: #dc2626;
  border-top: 1px solid #f1f5f9;
}

.path-dropdown-menu button.danger:hover {
  background: #fef2f2;
}

/* Variable Palette Tray */
.path-variable-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 0.85rem;
}

.path-tray-label {
  font-weight: 700;
  color: #475569;
}

.path-tray-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.path-tray-chip {
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.path-tray-chip:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.path-tray-chip.is-on-canvas {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.path-btn-chip-add {
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background: #e2e8f0;
  border: 1px dashed #94a3b8;
  color: #475569;
  font-size: 0.8rem;
  cursor: pointer;
}

.path-btn-chip-add:hover {
  background: #cbd5e1;
}

/* Guide Bar */
.path-guide-bar {
  padding: 0.45rem 0.85rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #166534;
}

.guide-port-badge {
  display: inline-block;
  background: #2563eb;
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  text-align: center;
  line-height: 16px;
  font-size: 10px;
}

/* Stage & SVG */
.path-stage-container {
  width: 100%;
  height: 440px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.path-svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  cursor: default;
}

/* SVG Node Elements */
.path-node-shape,
.path-node-circle,
.path-node-square {
  cursor: grab;
  transition: stroke 0.15s, stroke-width 0.15s;
}

.path-node-shape:active,
.path-node-circle:active,
.path-node-square:active {
  cursor: grabbing;
}

.path-node-item.is-selected .path-node-shape,
.path-node-item.is-selected .path-node-circle,
.path-node-item.is-selected .path-node-square {
  stroke: #ea580c;
  stroke-width: 3.5px;
}

/* Canvas SVG Legend */
.path-legend-group {
  pointer-events: none;
  user-select: none;
}

.path-port-handle {
  cursor: crosshair;
  transition: transform 0.15s ease;
}

.path-port-handle:hover circle {
  fill: #1d4ed8;
  r: 11px;
}

.path-mod-handle {
  cursor: crosshair;
}

.path-mod-handle:hover circle {
  fill: #047857;
  r: 11px;
}

.path-node-delete-badge {
  cursor: pointer;
}

.path-node-delete-badge:hover circle {
  fill: #dc2626;
  r: 11px;
}

/* SVG Edge Elements */
.path-hit-line {
  cursor: pointer;
}

.path-edge-item:hover line:first-of-type {
  stroke: #3b82f6;
  stroke-width: 3.5px;
}

/* Prominent Path Midpoint Dot for Moderators */
.path-midpoint-dot {
  cursor: pointer;
  transition: transform 0.15s, r 0.15s, stroke-width 0.15s;
}

.path-midpoint-dot:hover {
  r: 9.5px;
  stroke: #059669;
  stroke-width: 3px;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.5));
}

.path-midpoint-dot.is-moderated {
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.4));
}

/* Snap hover state when dragging an arrow onto the midpoint dot */
.path-midpoint-dot--snap-hover {
  r: 12px !important;
  stroke: #10b981 !important;
  stroke-width: 4px !important;
  fill: #ecfdf5 !important;
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.85)) !important;
  animation: pathDotPulse 0.7s infinite alternate ease-in-out;
}

@keyframes pathDotPulse {
  0% { r: 10px; }
  100% { r: 13.5px; }
}

.path-midpoint-hit {
  cursor: crosshair;
}

/* Results & Decomposition Panel */
.path-results-panel {
  margin-top: 1rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
}

.path-results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.path-results-header h4 {
  margin: 0;
  font-size: 1.05rem;
  color: #0f172a;
}

.path-results-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.path-resamples-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.path-resamples-control select {
  padding: 0.35rem 0.65rem;
  font-size: 0.825rem;
  font-weight: 500;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background-color: #ffffff;
  color: #1e293b;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.path-resamples-control select:hover {
  border-color: #94a3b8;
}

.path-resamples-control select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.path-results-tables {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.path-results-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.path-results-card h5 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  color: #334155;
}

.path-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.path-data-table th,
.path-data-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #f1f5f9;
}

.path-data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

.path-data-table tr:hover td {
  background: #f8fafc;
}

.path-table-total-row td {
  background: #eff6ff !important;
  font-weight: 700;
  border-top: 2px solid #bfdbfe;
}

.path-eq-block {
  margin-bottom: 1rem;
}

.path-eq-block:last-child {
  margin-bottom: 0;
}

.path-eq-header {
  padding: 0.35rem 0.65rem;
  background: #f8fafc;
  border-left: 3px solid #2563eb;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

/* ==========================================================================
   Variable Scale & Node Property Inspector Bar
   ========================================================================== */

.path-node-inspector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.path-inspector-empty {
  color: #64748b;
  font-size: 0.85rem;
  line-height: 1.4;
}

.path-inspector-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.path-inspector-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.path-inspector-var-title {
  font-size: 0.95rem;
  color: #1e293b;
}

.path-inspector-role {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
}

.role-badge-x {
  background: #dbeafe;
  color: #1d4ed8;
}

.role-badge-y {
  background: #dbeafe;
  color: #1d4ed8;
}

.role-badge-m {
  background: #fef3c7;
  color: #b45309;
}

.role-badge-w {
  background: #d1fae5;
  color: #047857;
}

.path-inspector-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.path-inspector-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.path-inspector-field.hidden {
  display: none;
}

.path-inspector-field label {
  font-weight: 600;
  color: #475569;
  font-size: 0.8rem;
}

.path-select {
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
}

.path-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Categorical Badges & Tags */
.path-node-cat-badge {
  pointer-events: none;
}

.path-tray-chip-tag.cat {
  display: inline-block;
  background: #7c3aed;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 9999px;
  margin-left: 0.3rem;
  vertical-align: middle;
}

/* Integrated Data Strip */
.path-data-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.path-data-strip__left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.path-data-strip__right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.path-data-strip__badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  background: #ffffff;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.path-data-strip__badge--active {
  color: #15803d;
  background: #dcfce7;
  border-color: #86efac;
}

.path-data-strip__hint {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
}

.path-pill-btn {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.path-pill-btn:hover {
  background: #f8fafc;
  border-color: #2563eb;
  color: #2563eb;
}

.path-btn--upload {
  cursor: pointer;
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #1d4ed8;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  border-radius: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s ease;
}

.path-btn--upload:hover {
  background: #1d4ed8;
}

/* Diagnostic Error Card & Pedagogical Callouts */
.path-diag-card {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid #d97706;
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.path-diag-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.path-diag-title {
  font-weight: 700;
  font-size: 1rem;
  color: #92400e;
  margin: 0;
}

.path-diag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.path-diag-badge--theory {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.path-diag-badge--scope {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.path-diag-section {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #fcd34d;
}

.path-diag-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78350f;
  margin: 0 0 0.35rem 0;
}

.path-diag-list {
  margin: 0.35rem 0 0.5rem 1.25rem;
  padding: 0;
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.5;
}

.path-diag-list code {
  background: #ffffff;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  font-weight: 600;
  color: #0f172a;
}
