/* Link Editor — styles (../styles.css base) */

:root {
  --le-radius: 8px;
  --le-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --le-panel-bg: var(--surface);
}

/* Shared: links list, badges, structure tree, canvas, toast */
.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
}

.link-list li {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.link-list li:hover {
  background: var(--accent-soft);
}

.link-list li.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.link-list li.auto-imported {
  border-left: 3px solid #ffc107;
}

.link-type-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  text-transform: uppercase;
  margin-right: 0.35rem;
}

.link-type-references { background: #cfe2ff; color: #084298; }
.link-type-prerequisite { background: #ffe5d0; color: #984c0c; }
.link-type-part_of { background: #d1e7dd; color: #0f5132; }
.link-type-cross_domain { background: #e2d9f3; color: #432874; }

.structure-tree {
  list-style: none;
  padding: 0.25rem 0 0 0;
  margin: 0;
}

.structure-tree ul {
  list-style: none;
  padding-left: 1.25rem;
  margin: 0.25rem 0;
}

.structure-tree li {
  padding: 0.35rem 0.5rem;
  margin: 0.2rem 0;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.85rem;
  cursor: grab;
}

.structure-tree li.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-soft);
}

.status-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--text);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
  pointer-events: none;
}

.status-toast.show {
  opacity: 1;
}

.canvas-workbench {
  display: grid;
  grid-template-columns: 160px 1fr;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  min-height: 420px;
}

.canvas-sidebar {
  border-right: 1px solid var(--border);
  background: #f1f3f5;
  padding: 0.65rem;
  font-size: 0.8rem;
}

.canvas-sidebar h4 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.palette-group {
  margin-bottom: 0.75rem;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: grab;
  user-select: none;
}

.palette-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.palette-shape {
  width: 28px;
  height: 18px;
  border: 2px solid #495057;
  border-radius: 2px;
  flex-shrink: 0;
}

.palette-shape.ellipse {
  border-radius: 50%;
  width: 26px;
  height: 20px;
}

.palette-shape.diamond {
  transform: rotate(45deg);
  width: 16px;
  height: 16px;
  margin: 4px 6px;
}

.canvas-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.canvas-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: #e9ecef;
}

.canvas-topbar .tb-group {
  display: flex;
  gap: 0.15rem;
  padding-right: 0.5rem;
  margin-right: 0.35rem;
  border-right: 1px solid #ced4da;
}

.canvas-topbar .tb-group:last-of-type {
  border-right: none;
}

.tb-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--text);
}

.tb-btn:hover {
  background: #fff;
  border-color: var(--border);
}

.tb-btn.active {
  background: #fff;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.canvas-stage {
  flex: 1;
  position: relative;
  min-height: 360px;
  background-color: #fafbfc;
  background-image: radial-gradient(circle, #ced4da 1px, transparent 1px);
  background-size: 16px 16px;
}

.graph-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.canvas-statusbar {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #f1f3f5;
}

.inspector-field {
  margin-bottom: 0.5rem;
}

.inspector-field label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.inspector-field input,
.inspector-field select,
.inspector-field textarea {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.8rem;
  background: var(--surface);
}

/* Unified layout & tenant-config UX */

main.unified-editor {
  max-width: 1680px;
  padding: 1rem 1.5rem 1.5rem;
}

.editor-intro {
  margin-bottom: 1rem;
}

.unified-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: stretch;
  min-height: calc(100vh - 230px);
}

.unified-grid.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

@media (max-width: 1200px) {
  .unified-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.panel-card {
  background: var(--le-panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--le-radius);
  box-shadow: var(--le-shadow);
}

.panel-title,
.panel-subtitle {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.panel-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Buttons */
.le-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}

.le-btn:hover {
  background: var(--accent-soft);
  border-color: #b6d4fe;
}

.le-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.le-btn-primary:hover {
  background: #0b5ed7;
  border-color: #0b5ed7;
}

.le-btn-ghost {
  background: transparent;
}

.le-btn.sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
}

/* Structure panel */
.structure-panel {
  padding: 0.85rem;
  font-size: 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.structure-panel h3 {
  margin: 0;
  font-size: 0.9rem;
}

.structure-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.structure-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.structure-hint,
.palette-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.35;
}

.structure-tree li {
  border-style: solid;
  border-color: #e9ecef;
  transition: background 0.15s, border-color 0.15s;
}

.structure-tree li:hover {
  border-color: #ced4da;
  background: #f8f9fa;
}

.structure-tree li.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.structure-folder > .tree-label {
  font-weight: 600;
}

.tree-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.tree-ref-label {
  align-items: flex-start;
}

.tree-ref-name {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
  word-break: break-word;
}

.tree-icon.folder-icon {
  color: #fd7e14;
  font-size: 0.7rem;
  width: 0.75rem;
  flex-shrink: 0;
}

.type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.35rem;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.type-dot.doc-dot {
  background: #868e96;
  border-radius: 2px;
}

.type-chip {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-color, #adb5bd) 18%, white);
  color: color-mix(in srgb, var(--chip-color, #495057) 85%, black);
  border: 1px solid color-mix(in srgb, var(--chip-color, #adb5bd) 35%, white);
}

.type-chip.unknown {
  --chip-color: #adb5bd;
}

.structure-inspector {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.structure-inspector h4 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
}

.structure-inspector label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.structure-inspector input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.struct-ref-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

/* Palette */
.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.palette-head h4 {
  margin: 0;
}

.palette-item {
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  transition: transform 0.1s, box-shadow 0.15s;
}

.palette-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--le-shadow);
}

.palette-item.active {
  box-shadow: 0 0 0 2px var(--type-color, var(--accent));
}

.palette-label {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
}

.palette-empty {
  text-align: center;
  padding: 0.75rem 0.35rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: #fff;
}

.palette-empty p {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.canvas-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}

.unified-canvas.canvas-workbench {
  min-height: 560px;
  grid-template-columns: 168px 1fr;
  border-radius: var(--le-radius);
  box-shadow: var(--le-shadow);
  border-color: var(--border);
}

.unified-canvas .canvas-sidebar {
  padding: 0.75rem 0.65rem;
}

.unified-canvas .canvas-stage {
  min-height: 480px;
}

.canvas-topbar .tb-btn {
  min-width: auto;
  height: auto;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
}

.canvas-topbar .tb-label {
  font-size: 0.72rem;
  font-weight: 500;
}

.tb-btn.tb-danger:hover {
  background: #fff5f5;
  border-color: #f1aeb5;
  color: #842029;
}

/* Links panel */
.links-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  overflow-y: auto;
}

.links-panel .link-list {
  max-height: 220px;
  flex-shrink: 0;
}

.links-panel .link-list li {
  border-radius: 6px;
  line-height: 1.35;
}

.links-panel .form-mock label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.links-panel .form-mock select,
.links-panel .inspector-field input,
.links-panel .inspector-field select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
}

.links-panel .inspector-block {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.15rem;
}

.form-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.insp-empty {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  padding: 0.5rem 0;
}

.links-panel .inspector-block .btn-action.primary {
  cursor: pointer;
  width: 100%;
  margin-top: 0.35rem;
}

.btn-action.sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
}

/* Dialogs */
.proto-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 540px;
  width: calc(100% - 2rem);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.proto-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.proto-dialog form {
  padding: 1.1rem 1.25rem 1.25rem;
}

.proto-dialog h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.dialog-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.types-dialog-actions {
  justify-content: space-between;
}

.bind-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.bind-tab {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
}

.bind-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.bind-search {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.bind-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.bind-list-item {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
  font-size: 0.82rem;
}

.bind-list-item:last-child {
  border-bottom: none;
}

.bind-list-item:hover,
.bind-list-item.selected {
  background: var(--accent-soft);
}

.bind-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bind-list-row strong {
  font-weight: 600;
  min-width: 0;
}

.bind-list-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.bind-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  margin: 0.65rem 0 0;
}

.types-dialog {
  max-width: 680px;
}

.types-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.types-table th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.types-table th,
.types-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  text-align: left;
}

.types-table tr:last-child td {
  border-bottom: none;
}

.types-table input[type="text"],
.types-table select {
  width: 100%;
  font-size: 0.78rem;
  padding: 0.3rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.types-table input[type="color"] {
  width: 2.25rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.type-add-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin: 0;
  background: #f8f9fa;
}

.type-add-fieldset legend {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.35rem;
}

.type-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.type-add-row input[type="text"] {
  flex: 1 1 90px;
  min-width: 72px;
  padding: 0.35rem 0.45rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.type-add-row select {
  padding: 0.35rem;
  font-size: 0.78rem;
  border-radius: 6px;
}
