/*
 * brückeMind - application styles.
 * Colors follow the colour concept ("Farbkonzept 2020") of
 * Brücke Rendsburg-Eckernförde e.V. (primary blue #164194), the angular
 * look and the font Open Sans its website.
 * Fonts are taken from the local system only; nothing is downloaded.
 */
:root {
  --bm-blue: #164194;
  --bm-blue-dark: #0f2d68;
  --bm-blue-light: #0075bf;
  --bm-orange: #f39200;
  --bm-red: #e30613;
  --bm-yellow: #fdc300;
  --bm-bordeaux: #a62341;
  --bm-magenta: #e6007e;
  --bm-green: #adaf1b;
  --bm-purple: #8c1d82;
  --bm-grey: #878787;
  --bm-text: #262626;
  --bm-muted: #6b6466;
  --bm-surface: #fefefe;
  --bm-surface-alt: #f4f4f4;
  --bm-border: #d9d5d6;
  --bm-font: "Open Sans", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  height: 100dvh; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; overflow: hidden;
  font-family: var(--bm-font); font-size: 14px; line-height: 1.35;
  color: var(--bm-text); background: var(--bm-surface);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid var(--bm-orange); outline-offset: 1px; }

/* ---- header ------------------------------------------------------------ */
#app-header {
  display: flex; align-items: center; gap: 16px;
  /* env(): room for the status bar and rounded corners of an iPad when running as an app */
  padding: calc(8px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 8px calc(14px + env(safe-area-inset-left));
  background: var(--bm-blue); color: #fefefe; flex: 0 0 auto;
}
.bm-brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.bm-brand-mark { display: block; flex: 0 0 auto; }
.bm-brand-name { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.bm-version { margin-top: auto; padding: 6px 12px; font-size: 11px; color: var(--bm-grey); }
.bm-title-input {
  flex: 1 1 auto; min-width: 80px; max-width: 520px; padding: 5px 9px;
  border: 1px solid transparent; border-bottom-color: rgba(255, 255, 255, .5);
  background: transparent; color: #fefefe; font-size: 16px; font-weight: 600;
}
.bm-title-input:hover, .bm-title-input:focus { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .6); outline: none; }
.bm-header-actions { margin-left: auto; display: flex; gap: 6px; }
.bm-header-button {
  padding: 5px 10px; border: 1px solid rgba(255, 255, 255, .55); background: transparent;
  color: #fefefe; text-decoration: none; font-size: 13px; white-space: nowrap;
}
.bm-header-button:hover { background: #fefefe; color: var(--bm-blue); }

/* ---- toolbar ----------------------------------------------------------- */
#toolbar {
  display: flex; flex-wrap: wrap; gap: 2px 0; padding: 4px 8px; flex: 0 0 auto;
  background: var(--bm-surface); border-bottom: 1px solid var(--bm-border);
}
.bm-toolbar-group { display: flex; padding: 0 6px; border-right: 1px solid var(--bm-border); }
.bm-toolbar-group:last-child { border-right: 0; }
.bm-tool {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px;
  border: 1px solid transparent; background: transparent; color: var(--bm-blue); font-size: 13px; white-space: nowrap;
}
.bm-tool:hover:not(:disabled) { background: var(--bm-blue); color: #fefefe; }
.bm-tool.is-active { background: var(--bm-blue); color: #fefefe; }
.bm-caret { font-size: 10px; }
.bm-icon { flex: 0 0 auto; }

.bm-menu {
  position: fixed; z-index: 60; min-width: 230px; padding: 4px 0;
  background: var(--bm-surface); border: 1px solid var(--bm-border); box-shadow: 0 6px 18px rgba(10, 10, 10, .22);
}
.bm-menu-item { display: block; width: 100%; padding: 8px 14px; border: 0; background: transparent; text-align: left; }
.bm-menu-item:hover:not(:disabled) { background: var(--bm-blue); color: #fefefe; }
.bm-menu-separator { height: 1px; margin: 4px 0; background: var(--bm-border); }

/* ---- workspace --------------------------------------------------------- */
#workspace { display: flex; flex: 1 1 auto; min-height: 0; }
#sidebar, #panel {
  flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; background: var(--bm-surface-alt);
}
#sidebar { width: 230px; border-right: 1px solid var(--bm-border); }
#panel { width: 300px; border-left: 1px solid var(--bm-border); }
.bm-sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.bm-sidebar-header h2 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--bm-blue); }
#map-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 0 1 auto; min-height: 0; }
.bm-map-item { display: flex; align-items: center; border-left: 4px solid transparent; border-bottom: 1px solid var(--bm-border); }
.bm-map-item.is-active { border-left-color: var(--bm-orange); background: var(--bm-surface); }
.bm-map-open { flex: 1 1 auto; min-width: 0; padding: 8px 6px 8px 8px; border: 0; background: transparent; text-align: left; }
.bm-map-open:hover .bm-map-title { color: var(--bm-blue); text-decoration: underline; }
.bm-map-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-map-date { display: block; font-size: 11px; color: var(--bm-muted); }
.bm-icon-button { flex: 0 0 auto; display: inline-flex; padding: 5px; border: 0; background: transparent; color: var(--bm-muted); }
.bm-icon-button:hover { color: var(--bm-blue); }

.bm-resizer { flex: 0 0 5px; margin: 0 -2px; z-index: 6; cursor: col-resize; background: transparent; touch-action: none; }
.bm-resizer:hover, .bm-resizer.is-dragging, .bm-resizer:focus-visible { background: var(--bm-orange); outline: none; }
body.bm-resizing { cursor: col-resize; user-select: none; }

#canvas-wrap { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
#canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; outline: none; }
#canvas.bm-panning { cursor: grabbing; }
#canvas text { pointer-events: none; }
.bm-node { cursor: pointer; }
.bm-selection { fill: none; stroke: var(--bm-orange); stroke-width: 2.5; stroke-dasharray: 6 4; pointer-events: none; }
.bm-drop-target > :first-child { filter: drop-shadow(0 0 5px #0075bf); }
.bm-ghost { fill: rgba(22, 65, 148, .15); stroke: var(--bm-blue); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }
.bm-toggle { cursor: pointer; }
.bm-toggle .bm-toggle-hit { fill: transparent; stroke: none; }
.bm-toggle circle { fill: #fefefe; stroke: var(--bm-grey); stroke-width: 1.5; }
.bm-toggle:hover circle:not(.bm-toggle-hit) { stroke: var(--bm-blue); }
.bm-toggle text { font-size: 10px; font-family: var(--bm-font); font-weight: 700; fill: var(--bm-blue); }
.bm-node-editor {
  position: absolute; z-index: 5; padding: 6px 10px; resize: none; overflow: hidden;
  border: 2px solid var(--bm-orange); background: #fefefe; color: var(--bm-text);
  box-shadow: 0 4px 14px rgba(10, 10, 10, .25); outline: none; line-height: 1.3;
}

#fixed-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#fixed-layer > * { position: absolute; }
#fixed-layer img { display: block; height: auto; }
#status-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 14px;
  padding: 3px calc(10px + env(safe-area-inset-right)) calc(3px + env(safe-area-inset-bottom)) 10px;
  font-size: 11px; color: var(--bm-muted); background: rgba(254, 254, 254, .85); border-top: 1px solid var(--bm-border); pointer-events: none;
}
#zoom-indicator { flex: 0 0 auto; white-space: nowrap; }
.bm-hint { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The "?" sits at the right end of the status bar, where it cannot cover fixed elements. */
.bm-help-button {
  flex: 0 0 auto; margin-left: auto; width: 18px; height: 18px; padding: 0; pointer-events: auto;
  border: 1px solid var(--bm-blue); border-radius: 50%; background: #fefefe; color: var(--bm-blue);
  font-size: 12px; font-weight: 700; line-height: 1;
}
.bm-help-button:hover { background: var(--bm-blue); color: #fefefe; }
.bm-shortcuts { width: 100%; border-collapse: collapse; }
.bm-shortcuts td { padding: 5px 6px; border-bottom: 1px solid var(--bm-border); vertical-align: top; }
.bm-shortcuts td:first-child { white-space: nowrap; }
.bm-shortcuts kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; margin-right: 3px; text-align: center;
  font-family: inherit; font-size: 12px; background: var(--bm-surface-alt); border: 1px solid var(--bm-grey); border-bottom-width: 2px;
}

/* ---- panel and forms --------------------------------------------------- */
#panel-tabs { display: flex; flex: 0 0 auto; border-bottom: 2px solid var(--bm-blue); }
.bm-tab { flex: 1 1 0; padding: 9px 6px; border: 0; background: transparent; color: var(--bm-blue); font-weight: 600; }
.bm-tab.is-active { background: var(--bm-blue); color: #fefefe; }
#panel-body { flex: 1 1 auto; overflow-y: auto; padding: 10px 12px 24px; }
.bm-empty { color: var(--bm-muted); font-style: italic; }
.bm-doc-link { display: inline-block; font-size: 12px; font-style: normal; color: var(--bm-blue); white-space: nowrap; }
.bm-doc-link::after { content: ' \2197'; }
.bm-doc-link:hover { color: var(--bm-blue-dark); }
.bm-section { border-bottom: 1px solid var(--bm-border); padding: 6px 0; }
.bm-section > summary { padding: 4px 0; font-weight: 700; color: var(--bm-blue); cursor: pointer; }
.bm-subheading { margin: 10px 0 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--bm-muted); }
.bm-field { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.bm-field > span:first-child { flex: 0 0 104px; font-size: 13px; }
.bm-field.is-block { display: block; }
.bm-field.is-block > span:first-child { display: block; margin-bottom: 4px; }
.bm-field.is-overridden > span:first-child { font-weight: 700; color: var(--bm-blue); }
.bm-field-control { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.bm-input, .bm-field select, .bm-field input[type="number"], .bm-field input[type="text"],
.bm-field input[type="date"], .bm-field textarea {
  width: 100%; padding: 4px 6px; border: 1px solid var(--bm-grey); border-radius: 0; background: #fefefe;
}
.bm-field textarea { min-height: 70px; resize: vertical; }
.bm-field input[type="number"] { width: 78px; }
.bm-field input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--bm-grey); background: #fefefe; }
.bm-field input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--bm-blue); }
.bm-swatches { display: flex; flex-wrap: wrap; gap: 3px; }
.bm-swatch { width: 16px; height: 16px; padding: 0; border: 1px solid var(--bm-grey); }
.bm-swatch:hover { transform: scale(1.25); }
.bm-swatches.is-choice { gap: 4px; flex-wrap: nowrap; }
.bm-swatches.is-choice .bm-swatch { width: 19px; height: 22px; }
.bm-swatch.is-selected { outline: 2px solid var(--bm-text); outline-offset: 1px; }
.bm-inline-label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--bm-muted); }
.bm-button-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.bm-button {
  padding: 6px 12px; border: 1px solid var(--bm-blue); background: #fefefe; color: var(--bm-blue); font-weight: 600;
}
.bm-button:hover:not(:disabled) { background: var(--bm-blue); color: #fefefe; }
.bm-button.is-primary { background: var(--bm-blue); color: #fefefe; }
.bm-button.is-primary:hover:not(:disabled) { background: var(--bm-blue-dark); }
.bm-button.is-danger { border-color: var(--bm-red); background: var(--bm-red); color: #fefefe; }
.bm-button.is-small { padding: 3px 8px; font-size: 12px; }
.bm-card { margin: 8px 0; padding: 6px 8px; border: 1px solid var(--bm-border); background: #fefefe; }
.bm-card-header { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.bm-preview-image { max-width: 100%; max-height: 60px; border: 1px dashed var(--bm-border); }

/* ---- modal dialogs and toasts ------------------------------------------ */
.bm-modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(15, 45, 104, .45);
}
.bm-modal {
  display: flex; flex-direction: column; width: 440px; max-width: 100%; max-height: 100%;
  background: var(--bm-surface); border-top: 5px solid var(--bm-blue); box-shadow: 0 12px 40px rgba(10, 10, 10, .35);
}
.bm-modal.is-wide { width: 720px; }
.bm-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; }
.bm-modal-header h2 { margin: 0; font-size: 18px; color: var(--bm-blue); }
.bm-modal-body { padding: 8px 16px; overflow-y: auto; }
.bm-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; }
.bm-template-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--bm-border); }
.bm-template-name { flex: 1 1 160px; font-weight: 600; }
.bm-badge { margin-left: 6px; padding: 1px 6px; font-size: 11px; font-weight: 400; background: var(--bm-blue); color: #fefefe; }
.bm-badge.is-accent { background: var(--bm-orange); }

#toast-root { position: fixed; z-index: 90; left: 50%; bottom: calc(36px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.bm-toast { padding: 9px 16px; background: var(--bm-blue-dark); color: #fefefe; box-shadow: 0 4px 14px rgba(10, 10, 10, .3); }
.bm-toast.is-error { background: var(--bm-red); }
.bm-toast { display: flex; align-items: center; gap: 12px; }
.bm-toast-action { padding: 5px 12px; border: 1px solid #fefefe; background: #fefefe; color: var(--bm-blue-dark); font-weight: 700; }
.bm-toast-close { padding: 0 4px; border: 0; background: transparent; color: #fefefe; font-size: 18px; line-height: 1; }

/* ---- printing ----------------------------------------------------------- */
#print-root { display: none; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  body { display: block; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; box-sizing: border-box; overflow: hidden; break-inside: avoid; }
  #print-root svg { display: block; }
}

/* ---- tablets and other touch screens ----------------------------------- */
/* Narrow screens (e.g. tablets in portrait): the columns overlay the canvas. */
@media (max-width: 1024px) {
  #workspace { position: relative; }
  #sidebar, #panel {
    position: absolute; top: 0; bottom: 0; z-index: 20; max-width: 85vw;
    box-shadow: 0 0 22px rgba(10, 10, 10, .28);
  }
  #sidebar { left: 0; }
  #panel { right: 0; }
  .bm-resizer { display: none; }
  .bm-brand-name { font-size: 17px; }
  /* Compact toolbar: icon above a small label, so everything fits in one row. */
  #toolbar { padding: 2px 4px; }
  .bm-toolbar-group { padding: 0 2px; }
  .bm-tool { flex-direction: column; gap: 2px; min-width: 50px; padding: 6px 4px; font-size: 10.5px; }
  .bm-caret { display: none; }
}
@media (max-width: 700px) {
  .bm-tool-label { display: none; }
  .bm-hint { display: none; }
  .bm-brand-name { display: none; }
}
/* Finger-sized controls on touch devices. */
@media (pointer: coarse) {
  .bm-tool { padding-top: 9px; padding-bottom: 9px; }
  .bm-header-button { padding: 9px 12px; }
  .bm-title-input { padding: 8px 9px; }
  .bm-icon-button { padding: 11px; }
  .bm-menu-item { padding: 13px 16px; }
  .bm-tab { padding: 13px 6px; }
  .bm-map-open { padding: 12px 6px 12px 10px; }
  .bm-section > summary { padding: 10px 0; }
  .bm-button { padding: 10px 14px; }
  .bm-button.is-small { padding: 8px 11px; font-size: 13px; }
  .bm-swatch, .bm-swatches.is-choice .bm-swatch { width: 28px; height: 28px; }
  .bm-swatches.is-choice { flex-wrap: wrap; }
  .bm-swatches { gap: 5px; }
  .bm-field { margin: 9px 0; }
  .bm-input, .bm-field select, .bm-field input[type="number"], .bm-field input[type="text"], .bm-field textarea {
    min-height: 40px; font-size: 16px;
  }
  .bm-field input[type="color"] { width: 46px; height: 38px; }
  .bm-field input[type="checkbox"] { width: 24px; height: 24px; }
  .bm-help-button { width: 34px; height: 34px; font-size: 17px; }
  #status-bar { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .bm-resizer { flex-basis: 14px; margin: 0 -6px; }
  .bm-modal-footer .bm-button { min-width: 88px; }
}
