/* ===========================================================
   C4 MODELER STYLES — Batch 1
   Tabs (Elements / Relationships / Views), trees, side panels.
   Canvas styles come in batch 2.
=========================================================== */
.c4-root .c4-body {
  flex-direction: row;
  gap: 4px;
  padding: 4px;
  flex: 1;
  min-height: 0;
}

/* Tab strip */
.c4-tabs {
  display: flex;
  background: #c0c0c0;
  border-top: 1px solid #808080;
  border-bottom: 1px solid #808080;
  flex-shrink: 0;
}
.c4-tab {
  background: #c0c0c0;
  border: none;
  border-right: 1px solid #808080;
  padding: 5px 16px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  color: #404040;
  cursor: pointer;
}
.c4-tab:hover { background: #d8d8d8; }
.c4-tab.active {
  background: #ffffff;
  color: #000080;
  font-weight: bold;
}

/* Panes */
.c4-pane {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  min-height: 0;
}
.c4-tree-pane    { flex: 0 0 45%; min-width: 280px; }
.c4-detail-pane  { flex: 1; min-width: 280px; }
.c4-rel-pane     { flex: 1; min-width: 0; }
.c4-views-pane   { flex: 0 0 35%; min-width: 240px; }

.c4-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to right, #000080, #1084d0);
  color: #ffffff;
  padding: 3px 8px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}
.c4-pane-head .t-btn {
  font-size: 10px;
  padding: 1px 8px;
}

/* Element tree */
.c4-tree {
  flex: 1;
  overflow: auto;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  min-height: 0;
}
.c4-tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 8px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
}
.c4-tree-node:hover { background: #ffffe1; }
.c4-tree-node.selected {
  background: #d0e0ff !important;
  outline: 2px solid #000080;
  outline-offset: -2px;
}
.c4-tn-type {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  color: #ffffff;
  font-family: Verdana, sans-serif;
  flex-shrink: 0;
}
.c4-tn-name {
  font-weight: bold;
  color: #000;
  overflow: hidden;
  text-overflow: ellipsis;
}
.c4-tn-tech {
  font-family: "Courier New", monospace;
  color: #606060;
  font-size: 10px;
  font-style: italic;
}
.c4-add-child {
  background: #008000;
  color: #ffffff;
  border: 1px outset #4ec04e;
  width: 18px; height: 18px;
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
}
.c4-add-child:hover { background: #006000; }
.c4-add-child:active { border-style: inset; }

/* Per-type colors on type-pills, tree nodes, and member badges. */
.c4-type-person         { background: #08427b; }
.c4-type-softwareSystem { background: #1168bd; }
.c4-type-external       { background: #999999; }
.c4-type-container      { background: #438dd5; }
.c4-type-component      { background: #85bbf0; color: #000080 !important; }

.c4-tree-node.c4-type-person          { border-left: 3px solid #08427b; }
.c4-tree-node.c4-type-softwareSystem  { border-left: 3px solid #1168bd; }
.c4-tree-node.c4-type-external        { border-left: 3px solid #999999; }
.c4-tree-node.c4-type-container       { border-left: 3px solid #438dd5; }
.c4-tree-node.c4-type-component       { border-left: 3px solid #85bbf0; }

/* Detail pane — form */
.c4-detail {
  flex: 1;
  overflow: auto;
  padding: 8px 10px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  min-height: 0;
}
.c4-form { margin-bottom: 12px; }
.c4-form-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.c4-form-label {
  flex: 0 0 120px;
  font-weight: bold;
  color: #404040;
  padding-top: 4px;
}
.c4-form-control { flex: 1; min-width: 0; }
.c4-form-control input[type=text],
.c4-form-control textarea,
.c4-form-control select {
  width: 100%;
  box-sizing: border-box;
  border: 2px inset #ffffff;
  background: #ffffff;
  padding: 3px 6px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  color: #000;
}
.c4-form-control textarea {
  font-family: Verdana, sans-serif;
  resize: vertical;
  min-height: 36px;
}
.c4-form-note {
  font-style: italic;
  color: #606060;
  margin: 6px 0;
  padding: 4px 8px;
  background: #f8f8f8;
  font-size: 11px;
}
.c4-form-section {
  margin-top: 10px;
  border-top: 1px solid #d0d0d0;
  padding-top: 8px;
}
.c4-form-section-title {
  font-weight: bold;
  color: #000080;
  font-size: 11px;
  margin-bottom: 6px;
}

.c4-detail-actions {
  padding: 8px 0 4px 0;
  border-top: 1px solid #d0d0d0;
  margin-top: 8px;
}
.c4-detail-actions .t-btn {
  background: #c04040 !important;
  color: #ffffff !important;
}

/* Relationships table */
.c4-rel-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.c4-rel-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Verdana, sans-serif;
  font-size: 11px;
}
.c4-rel-table th {
  background: #000080;
  color: #ffffff;
  text-align: left;
  padding: 4px 8px;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: bold;
  font-size: 11px;
}
.c4-rel-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #e8e8e8;
  vertical-align: middle;
}
.c4-rel-table tr:nth-child(even) td { background: #f8f8f8; }
.c4-rel-table tr:hover td { background: #ffffe1; }
.c4-rel-table select,
.c4-rel-table input[type=text] {
  width: 100%;
  box-sizing: border-box;
  border: 1px inset #d0d0d0;
  background: #ffffff;
  padding: 2px 4px;
  font-family: "Courier New", monospace;
  font-size: 11px;
}
.c4-rel-table .c4-arrow {
  width: 24px;
  text-align: center;
  color: #808080;
  font-weight: bold;
}
.c4-x {
  background: #c0c0c0;
  border: 1px solid #808080;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-family: Verdana, sans-serif;
  color: #800000;
  font-weight: bold;
  font-size: 14px;
}
.c4-x:hover { background: #ffcccc; }

/* Views list */
.c4-view-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.c4-view-row {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid #e8e8e8;
}
.c4-view-row:hover { background: #ffffe1; }
.c4-view-row.selected {
  background: #d0e0ff !important;
  outline: 2px solid #000080;
  outline-offset: -2px;
}
.c4-view-row-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 2px;
}
.c4-view-type {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  background: #000080;
  color: #ffffff;
  border-radius: 2px;
}
.c4-view-name {
  font-weight: bold;
  color: #000;
}
.c4-view-row-meta {
  font-size: 10px;
  color: #606060;
  font-family: "Courier New", monospace;
}

/* Member list (which elements are in a view) */
.c4-member-list {
  border: 1px inset #d0d0d0;
  background: #ffffff;
  max-height: 240px;
  overflow: auto;
  padding: 4px 6px;
}
.c4-member {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 11px;
}
.c4-member:hover { background: #ffffe1; }
.c4-member input[type=checkbox] { margin: 0; }
.c4-member-type {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  color: #ffffff;
  font-family: Verdana, sans-serif;
}
.c4-member-name { color: #000; font-weight: bold; }

/* Empty states */
.c4-empty {
  padding: 20px;
  text-align: center;
  color: #808080;
  font-style: italic;
  font-family: Verdana, sans-serif;
}

/* ===========================================================
   CANVAS TAB — Batch 2
=========================================================== */
.c4-canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  min-height: 0;
}
.c4-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 10px;
  background: #c0c0c0;
  border-bottom: 1px solid #808080;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  flex-shrink: 0;
}
.c4-canvas-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.c4-canvas-toolbar select {
  border: 2px inset #ffffff;
  background: #ffffff;
  padding: 2px 6px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  min-width: 240px;
}
.c4-canvas-hint {
  margin-left: auto;
  color: #606060;
  font-style: italic;
  font-size: 10px;
}

.c4-canvas-stage {
  flex: 1;
  overflow: auto;
  min-height: 0;
  /* subtle dotted grid background so the diagram has visible "paper" */
  background-color: #fafafa;
  background-image:
    radial-gradient(circle, #d0d0d0 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 10px 10px;
}

.c4-canvas-empty {
  padding: 40px 20px;
  text-align: center;
  color: #808080;
  font-style: italic;
  font-family: Verdana, sans-serif;
}

.c4-svg {
  display: block;
  /* keep the SVG at its natural pixel size so the canvas scrolls when the
     diagram is larger than the viewport */
}

/* Element groups */
.c4-box rect { transition: filter 0.1s; }
.c4-box:hover rect { filter: brightness(1.08); }
.c4-arrow line { transition: stroke-width 0.1s; }
.c4-arrow:hover line { stroke-width: 2.5; stroke: #000080; }

/* ===========================================================
   CANVAS TAB — Batch 3 additions (drag positioning)
=========================================================== */
.c4-canvas-toolbar input[type=checkbox] {
  vertical-align: middle;
  margin-right: 4px;
}
.c4-canvas-toolbar .t-btn {
  padding: 2px 10px;
  font-size: 11px;
}

/* All boxes get a move cursor */
.c4-box { cursor: move; }
.c4-box rect { transition: filter 0.1s; }

/* Visual feedback during drag */
.c4-box-dragging rect {
  filter: brightness(1.15) drop-shadow(0 3px 6px rgba(0,0,0,0.4));
}
.c4-box-dragging { opacity: 0.92; }

/* Disable text selection during drag — without this, the browser tries
   to select label text and the drag feels janky */
.c4-svg, .c4-svg * {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

/* ===========================================================
   CANVAS TAB — Batch 5 additions (in-canvas editing)
=========================================================== */

/* Visual divider in canvas toolbar */
.c4-canvas-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: #808080;
  margin: 0 4px;
  vertical-align: middle;
}

/* Mode buttons toggle when active */
.c4-mode-btn {
  font-weight: bold;
}
.c4-mode-btn.c4-mode-active {
  background: #ffd700 !important;
  color: #000 !important;
  border-style: inset !important;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
}

/* Selection feedback on canvas elements */
.c4-box.c4-selected rect {
  stroke: #ff6600;
  stroke-width: 3;
  filter: drop-shadow(0 0 4px rgba(255, 102, 0, 0.6));
}
.c4-arrow.c4-selected path {
  stroke: #ff6600;
  stroke-width: 2.5;
}

/* Arrow-mode highlight on the chosen source */
.c4-box.c4-arrow-source rect {
  stroke: #008000;
  stroke-width: 3;
  stroke-dasharray: 6 3;
}

/* Floating popovers shared style */
.c4-popover {
  background: #fefefe;
  border: 2px outset #ffffff;
  border-bottom-color: #404040;
  border-right-color: #404040;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.35);
  z-index: 10000;
  font-family: Verdana, sans-serif;
  font-size: 12px;
  min-width: 160px;
  user-select: none;
}
.c4-popover-title {
  background: linear-gradient(to right, #000080, #1084d0);
  color: #ffffff;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: bold;
}

/* Type picker */
.c4-type-picker {
  min-width: 260px;
  padding: 4px 0;
}
.c4-type-btn {
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  color: #000;
}
.c4-type-btn:hover { background: #d0e0ff; }
.c4-type-btn:active { background: #000080; color: #ffffff; }
.c4-type-btn:active .c4-type-btn-desc { color: #ccc; }
.c4-type-swatch {
  grid-row: 1 / span 2;
  width: 12px; height: 12px;
  align-self: center;
  border: 1px solid #404040;
}
.c4-type-btn-label {
  font-weight: bold;
  color: #000080;
}
.c4-type-btn-desc {
  grid-column: 2;
  color: #606060;
  font-size: 10px;
  font-style: italic;
}

/* Context menu */
.c4-context-menu {
  padding: 4px 0;
  min-width: 200px;
}
.c4-ctx-item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  padding: 5px 14px;
  cursor: pointer;
  text-align: left;
  font-family: Verdana, sans-serif;
  font-size: 11px;
  color: #000;
}
.c4-ctx-item:hover { background: #d0e0ff; }
.c4-ctx-item.danger { color: #a00000; }
.c4-ctx-item.danger:hover { background: #ffcccc; }
.c4-ctx-item.highlight {
  background: #fff4d0;
  font-weight: bold;
  border-left: 3px solid #c08000;
}
.c4-ctx-item.highlight:hover { background: #ffe9a0; }

/* Inline rename input */
.c4-inline-rename {
  position: fixed;
  z-index: 10000;
  border: 2px solid #ff6600;
  background: #ffffff;
  padding: 2px 6px;
  font-family: Verdana, sans-serif;
  font-size: 13px;
  color: #000080;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(255, 102, 0, 0.5);
  text-align: center;
  outline: none;
}

/* ===========================================================
   CANVAS TAB — Batch 6 (boundaries)
=========================================================== */

/* Boundary group — the dashed-line wrapper around grouped elements */
.c4-boundary { cursor: default; }
.c4-boundary rect {
  pointer-events: visibleStroke;   /* clicks only on the dashed border + label area */
  transition: filter 0.1s;
}
.c4-boundary text {
  pointer-events: auto;
  user-select: none;
}
.c4-boundary:hover rect {
  filter: brightness(0.95);
  stroke-width: 2;
}
.c4-boundary.c4-selected rect {
  stroke: #ff6600 !important;
  stroke-width: 2.5;
  stroke-dasharray: 8 5;
  filter: drop-shadow(0 0 4px rgba(255, 102, 0, 0.5));
}
.c4-boundary.c4-selected text {
  fill: #cc4400 !important;
}

/* ===========================================================
   MERMAID EXPORT MODAL — Batch 8
=========================================================== */

.c4-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
}
.c4-modal {
  position: fixed;
  z-index: 10001;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  min-width: 480px;
}
.c4-modal-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}
.c4-modal-body textarea {
  flex: 1;
  min-height: 280px;
  font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px;
  border: 2px inset #ffffff;
  background: #fbfbfb;
  color: #000080;
  resize: vertical;
  outline: none;
}
.c4-modal-body textarea:focus {
  background: #ffffff;
  border-color: #000080;
}
.c4-modal-hint {
  font-size: 11px;
  color: #404040;
  line-height: 1.4;
}
.c4-modal-hint code {
  font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
  background: #e8e8e8;
  padding: 1px 4px;
  border: 1px solid #c0c0c0;
  border-radius: 2px;
  font-size: 11px;
}
.c4-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #d8d8d8;
  border-top: 1px solid #808080;
}
.c4-modal-spacer { flex: 1; }
.c4-modal-link {
  text-decoration: none;
  color: #000;
  display: inline-block;
}
.c4-modal-link:hover { color: #000080; }

/* ===========================================================
   EXPORT MENU + dropdown — Batch 9
=========================================================== */
.c4-export-menu {
  min-width: 280px;
  padding: 4px 0;
}
.c4-ctx-item-sub {
  color: #808080;
  font-size: 10px;
  font-style: italic;
  margin-left: 8px;
}
.c4-ctx-item:active .c4-ctx-item-sub { color: #ccc; }
.c4-menu-sep {
  height: 1px;
  background: #c0c0c0;
  margin: 4px 0;
}

/* ===========================================================
   VALIDATION + MERGE — Batch 10
=========================================================== */

/* --- Validation modal --- */
.c4-validate-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 20px;
  text-align: center;
  font-family: Verdana, sans-serif;
}
.c4-validate-empty-icon {
  font-size: 48px;
  color: #009900;
  line-height: 1;
}
.c4-validate-summary {
  display: flex;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #c0c0c0;
  margin-bottom: 8px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
}
.c4-validate-err-count {
  background: #ffcccc;
  color: #a00000;
  padding: 2px 8px;
  border: 1px solid #a00000;
  font-weight: bold;
}
.c4-validate-warn-count {
  background: #fff4d0;
  color: #806000;
  padding: 2px 8px;
  border: 1px solid #c08000;
  font-weight: bold;
}
.c4-validate-list {
  max-height: 50vh;
  overflow-y: auto;
}
.c4-validate-group { margin-bottom: 12px; }
.c4-validate-cat {
  font-family: Verdana, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #000080;
  padding: 4px 0;
  border-bottom: 1px dotted #c0c0c0;
  margin-bottom: 4px;
}
.c4-validate-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
}
.c4-validate-bullet {
  font-weight: bold;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.c4-validate-error .c4-validate-bullet { color: #a00000; }
.c4-validate-warning .c4-validate-bullet { color: #c08000; }
.c4-validate-msg { flex: 1; }
.c4-validate-jump {
  font-size: 10px;
  padding: 1px 6px;
  background: #e0e0e0;
  border: 1px outset #ffffff;
  cursor: pointer;
  font-family: Verdana, sans-serif;
  color: #000080;
}
.c4-validate-jump:hover { background: #d0e0ff; }
.c4-validate-jump:active { border-style: inset; }

/* --- Merge modal --- */
.c4-merge-summary {
  padding-bottom: 8px;
  border-bottom: 1px solid #c0c0c0;
  margin-bottom: 8px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
}
.c4-merge-counts {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.c4-merge-add {
  background: #ccffcc;
  color: #005500;
  padding: 2px 8px;
  border: 1px solid #008000;
  font-weight: bold;
}
.c4-merge-skip {
  background: #f0f0f0;
  color: #606060;
  padding: 2px 8px;
  border: 1px solid #909090;
}
.c4-merge-section { margin-bottom: 10px; }
.c4-merge-sec-title {
  font-family: Verdana, sans-serif;
  font-size: 11px;
  font-weight: bold;
  color: #000080;
  padding: 2px 0;
  border-bottom: 1px dotted #c0c0c0;
}
.c4-merge-empty {
  color: #808080;
  font-style: italic;
  font-size: 10px;
  padding: 4px 8px;
}
.c4-merge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  font-family: Verdana, sans-serif;
  font-size: 11px;
}
.c4-merge-row.add { color: #005500; }
.c4-merge-row.skip { color: #808080; }
.c4-merge-row.skip i { color: #c08000; font-style: italic; }
.c4-merge-bullet {
  font-weight: bold;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.c4-merge-apply {
  background: #ccffcc !important;
  font-weight: bold;
}
.c4-merge-apply:disabled {
  background: #e0e0e0 !important;
  color: #808080 !important;
  cursor: not-allowed;
}

/* Undo/Redo button disabled state */
.t-btn:disabled,
.t-btn[disabled] {
  color: #808080;
  cursor: not-allowed;
  background: #e0e0e0;
}
