/* ---------- Global ---------- */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               sans-serif;
  font-size: 14px;
  color: #222;
}

body {
  display: flex;
  flex-direction: column;   /* header on top, content below */
}

/* ---------- Header bar ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid #ccc;
  background: #f4f4f4;
}

.app-title input {
  font-size: 16px;
  padding: 2px 4px;
  width: 240px;
}

.app-header-buttons button {
  margin-left: 6px;
  padding: 4px 10px;
}

/* ---------- Main layout (three columns) ---------- */

.app-layout {
  flex: 1;                      /* fill remaining vertical space */
  display: flex;                /* three columns: left, middle, right */
  min-height: 0;                /* allow children to use overflow correctly */
}

/* generic sidebar styles */

.sidebar {
  width: 260px;
  padding: 8px;
  box-sizing: border-box;
  background: #fafafa;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
}

.sidebar-right {
  border-right: none;
  border-left: 1px solid #ddd;
}

.sidebar h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 15px;
}

.sidebar-filter {
  margin-bottom: 8px;
  font-size: 13px;
}

/* list of virtual tables */

.table-list-wrapper {
  flex: 1;                /* fill vertical space in sidebar */
  overflow: auto;         /* scroll list if long */
}

.grid {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.grid th,
.grid td {
  border: 1px solid #ccc;
  padding: 3px 4px;
}

.grid thead th {
  background: #eee;
  position: sticky;
  top: 0;
  z-index: 1;
}

.cell-tenant {
  color: #6a2ca0;
  font-weight: bold;
}

.cell-actions {
  text-align: center;
}

.btn-add-node {
  padding: 2px 6px;
  font-size: 11px;
}

/* ---------- Canvas area ---------- */

.canvas-wrapper {
  flex: 1;                 /* takes all remaining horizontal space */
  position: relative;      /* reference for absolutely positioned children */
  overflow: auto;
  background: #ffffff;
}

/* the jsPlumb container, sized to fill the wrapper */

#diagram-canvas {
  position: relative;
  width: 2000px;           /* large “virtual sheet”; tweak to taste */
  height: 1600px;
  background-image: linear-gradient(#f6f6f6 1px, transparent 1px),
                    linear-gradient(90deg, #f6f6f6 1px, transparent 1px);
  background-size: 20px 20px;  /* light grid */
}

/* ---------- Diagram nodes ---------- */

.eav-node {
  position: absolute;      /* jsPlumb will change left/top */
  min-width: 180px;
  max-width: 260px;
  background: #fffdf8;
  border: 1px solid #c8a96a;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  font-size: 12px;
}

.eav-node.selected {
  border-color: #0074d9;
  box-shadow: 0 0 0 2px rgba(0,116,217,0.3);
}

.node-title {
  background: #f3e4c4;
  padding: 4px 6px;
  border-bottom: 1px solid #c8a96a;
  font-weight: bold;
  cursor: move;            /* indicates draggable */
  user-select: none;
}

.node-fields {
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.field-row {
  padding: 2px 3px;
  border-radius: 2px;
  margin-bottom: 1px;
  background: #ffffff;
  border: 1px solid transparent;
  cursor: crosshair;       /* indicates “connectable” */
  user-select: none;
}

.field-row:hover {
  background: #eef7ff;
  border-color: #b0d4ff;
}

/* You can color fields differently based on type (E/I/A/V) by adding extra
   classes in PHP, e.g. field-type-id, field-type-value, etc. */

.field-type-id {
  font-weight: bold;
  background: #f0f9ff;
}

.field-type-value {
  font-style: italic;
}

/* ---------- Right sidebar: fields panel ---------- */

#node-fields-panel {
  flex: 1;
  border: 1px solid #ddd;
  background: #fff;
  padding: 6px;
  overflow: auto;
  font-size: 12px;
}

/* ---------- jsPlumb connections / labels ---------- */

.edge-label {
  font-size: 11px;
  background: #fff;
  padding: 1px 3px;
  border-radius: 2px;
  border: 1px solid #ccc;
}

/* Optional: small buttons etc */

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}
