/* openconformity concept mockup
   Brand per docs/brand.md. Fonts vendored in assets/fonts, see ORIGIN.md. */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/IBMPlexSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --slate: #475569;
  --ink: #3A3A3A;
  --paper: #FAFAFA;
  --border: #DDDDDD;
  --white: #FFFFFF;

  /* Pillar colors: draw.io defaults, matching the metamodel diagram.
     Placeholder until brand.md defines dedicated pillar colors. */
  --structure-bg: #DAE8FC;
  --structure-line: #6C8EBF;
  --legislative-bg: #FFE6CC;
  --legislative-line: #D79B00;
  --requirements-bg: #F8CECC;
  --requirements-line: #B85450;
  --hazard-bg: #D5E8D4;
  --hazard-line: #82B366;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: "IBM Plex Sans", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

body.resizing-v { cursor: col-resize; user-select: none; }
body.resizing-h { cursor: row-resize; user-select: none; }

/* ---------- Menu bar ---------- */

.menubar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
  flex: none;
}

.logo {
  height: 20px;
  display: block;
}

.menu {
  display: flex;
  gap: 2px;
}

.menu-wrap {
  position: relative;
}

.menu-item {
  display: inline-block;
  padding: 4px 10px;
  color: var(--ink);
  cursor: default;
  border-radius: 4px;
  user-select: none;
}

.menu-item:hover,
.menu-item.open {
  background: var(--paper);
}

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  padding: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(58, 58, 58, 0.12);
}

.dropdown.open {
  display: block;
}

.dd-item {
  display: block;
  padding: 5px 10px;
  border-radius: 3px;
  color: var(--ink);
  white-space: nowrap;
  cursor: default;
}

.dd-item:hover {
  background: var(--paper);
}

.dd-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* Menu bar buttons: metamodel and mockup badge share one style */

.bar-btn {
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  color: var(--slate);
  background: var(--white);
  border: 1px solid var(--slate);
  border-radius: 4px;
  cursor: pointer;
}

.bar-btn:hover {
  background: var(--slate);
  color: var(--white);
}

.metamodel-btn {
  margin-left: auto;
}

/* ---------- Panes ---------- */

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex: none;
}

.pane-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
}

.pane-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
}

/* Splitters */

.splitter-v {
  width: 5px;
  flex: none;
  cursor: col-resize;
  background: var(--border);
}

.splitter-v:hover {
  background: var(--slate);
}

.splitter-h {
  height: 5px;
  flex: none;
  cursor: row-resize;
  background: var(--border);
}

.splitter-h:hover {
  background: var(--slate);
}

/* ---------- Navigator pane ---------- */

.navigator {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.nav-search {
  position: relative;
  margin-bottom: 10px;
}

#nav-filter {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  padding: 5px 24px 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
}

#nav-filter:focus {
  outline: none;
  border-color: var(--slate);
}

.nav-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--slate);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

/* Tree */

.node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: default;
  white-space: nowrap;
}

.node:hover {
  background: var(--paper);
}

.node-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-id {
  font-size: 11px;
  color: var(--slate);
  flex: none;
}

.twisty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--white);
  color: var(--slate);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.root {
  font-weight: 500;
}

/* Connector lines */

.children {
  position: relative;
  margin-left: 11px;
  padding-left: 16px;
}

.children::before {
  content: "";
  position: absolute;
  left: 0;
  top: -4px;
  bottom: 10px;
  border-left: 1px solid var(--border);
}

.children > .node::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 13px;
  border-top: 1px solid var(--border);
}

.children.collapsed {
  display: none;
}

.lvl1 .node-label {
  font-weight: 500;
}

.pillar-structure .twisty { border-color: var(--structure-line); color: var(--structure-line); }
.pillar-legislative .twisty { border-color: var(--legislative-line); color: var(--legislative-line); }
.pillar-requirements .twisty { border-color: var(--requirements-line); color: var(--requirements-line); }
.pillar-hazard .twisty { border-color: var(--hazard-line); color: var(--hazard-line); }

.leaf {
  padding-left: 23px;
}

.node.selected,
.node.selected:hover {
  background: var(--slate);
  color: var(--white);
  font-weight: 500;
}

.node.selected .node-id {
  color: var(--white);
  opacity: 0.75;
}

.hit-hidden {
  display: none;
}

/* ---------- Editor pane ---------- */

.editor {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.entity-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.entity-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}

.badge-hazard {
  background: var(--hazard-bg);
  border-color: var(--hazard-line);
}

.entity-name {
  font-size: 17px;
  font-weight: 500;
}

.attributes {
  border-collapse: collapse;
  width: 100%;
  max-width: 720px;
}

.attributes td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  vertical-align: top;
}

.attr-label {
  width: 140px;
  color: var(--slate);
  background: var(--white);
}

.attr-value {
  background: var(--white);
}

/* ---------- Relationship pane ---------- */

.relationships {
  height: 260px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.rel-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.toggle-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 3px 14px;
  border: none;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--slate);
  color: var(--white);
}

.hidden {
  display: none;
}

/* List view */

.rel-table {
  border-collapse: collapse;
  width: 100%;
}

.rel-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.rel-table-head td {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  border-bottom: 1px solid var(--slate);
}

.rel-type {
  font-weight: 500;
  width: 140px;
}

.rel-dir {
  color: var(--slate);
  width: 100px;
}

.rel-id {
  color: var(--slate);
  width: 90px;
}

.type-label {
  font-size: 12px;
  font-weight: 500;
}

.pillar-structure-text { color: var(--structure-line); }
.pillar-legislative-text { color: var(--legislative-line); }
.pillar-requirements-text { color: var(--requirements-line); }
.pillar-hazard-text { color: var(--hazard-line); }

/* Graph view */

.graph-svg {
  width: 100%;
  max-width: 900px;
  display: block;
  margin: 0 auto;
}

.g-structure { fill: var(--structure-bg); stroke: var(--structure-line); }
.g-legislative { fill: var(--legislative-bg); stroke: var(--legislative-line); }
.g-requirements { fill: var(--requirements-bg); stroke: var(--requirements-line); }
.g-hazard { fill: var(--hazard-bg); stroke: var(--hazard-line); }

.g-selected {
  stroke-width: 2;
}

.g-type {
  font-family: inherit;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  fill: var(--slate);
}

.g-id {
  font-family: inherit;
  font-size: 10px;
  fill: var(--slate);
}

.g-name {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  fill: var(--ink);
}

.g-label {
  font-family: inherit;
  font-size: 11px;
  fill: var(--slate);
  text-anchor: middle;
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 58, 58, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1100px;
  max-height: 100%;
  background: var(--white);
  border-radius: 6px;
  overflow: hidden;
}

.modal-narrow {
  max-width: 460px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.modal-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
}

.modal-close {
  border: none;
  background: none;
  color: var(--slate);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

.modal-body img {
  display: block;
  width: 100%;
  height: auto;
}

.modal-text {
  line-height: 1.6;
}

.modal-text p {
  margin-bottom: 10px;
}

.modal-text p:last-child {
  margin-bottom: 0;
}

.modal-text a {
  color: var(--slate);
}