/* Project-specific overrides. Sneat is the base. */

/* confirmDialog() sets textContent with "\n"; keep those as visible line breaks. */
#cdss-confirm-message {
  white-space: pre-line;
}

/* Anchor for bindAutocomplete()'s (cdss.js) dropdown-menu results — Bootstrap's
   .dropdown-menu is `position: absolute`, so it needs a `position: relative`
   ancestor to float under the input instead of pushing page content down. */
.autocomplete-menu {
  position: relative;
  z-index: 1000;
}

/* Keyboard selection uses .active. Keep it ahead of :hover/:focus, including
   when the pointer rests on the same row. Colors are the dropdown tokens, so
   dark theme stays primary text on a primary tint. */
.autocomplete-menu .dropdown-item.active,
.autocomplete-menu .dropdown-item.active:hover,
.autocomplete-menu .dropdown-item.active:focus {
  color: var(--bs-dropdown-link-active-color);
  background-color: var(--bs-dropdown-link-active-bg);
}

/* vis-network sizes its canvas to the container, so the container needs an
   explicit height — inside base.html the tree card sits in a normal-flow
   .container-xxl, where percentage heights collapse to zero. Viewport-relative
   so the canvas grows on large screens, with a floor for small ones. */
#tree-canvas {
  height: calc(100vh - 300px);
  min-height: 420px;
}

/* Editor: persistent node-detail panel left of the canvas. min-width: 0 lets the
   canvas column shrink below vis-network's intrinsic canvas width.
   The card clips the stretched columns to its rounded corners. Dropdowns use
   Popper strategy "fixed", so they are not clipped by this overflow. */
.tree-editor-card {
  overflow: hidden;
}

.tree-editor-layout {
  display: flex;
  align-items: stretch;
}

.tree-detail-panel {
  display: flex;
  flex: 0 0 320px;
  flex-direction: column;
  align-self: stretch;
  min-height: 420px;
  /* overflow other than visible makes this flex item's minimum the specified
     min-height, so a long detail list scrolls in the body instead of growing
     the card. */
  overflow: hidden;
  border-right: var(--bs-border-width) solid var(--bs-border-color);
}

.tree-detail-panel-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 1.5rem;
  overflow-y: auto;
}

.tree-detail-placeholder {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.tree-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.tree-main-panes {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

/* Sneat gives every .tab-content 1.5rem of padding (core.css). That padding
   sits under the Struktura columns and under the canvas. Drop only the bottom
   so both tinted columns meet the card edge; the canvas size stays put. */
.tree-editor-layout > .tree-main > .tree-main-panes {
  padding-bottom: 0;
}

/* Keep the active pane in the flex column so #tree-canvas retains its height. */
.tree-main-panes > .tab-pane.active {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.tree-canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.tree-outline-shell {
  display: flex;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: calc(100vh - 300px);
  min-width: 0;
  overflow-x: hidden;
}

.tree-outline-tree-pane {
  display: flex;
  flex: 1 1 55%;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: var(--bs-border-width) solid var(--bs-border-color);
}

.tree-outline-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.65rem 1rem;
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
  background-color: var(--bs-body-bg);
}

.tree-outline-search-wrap {
  position: relative;
  flex: 1 1 12rem;
  min-width: 10rem;
  max-width: 24rem;
}

.tree-outline-search-wrap .form-control {
  padding-right: 2rem;
}

/* Keep only our #tree-outline-search-clear button; hide the native type=search "x". */
#tree-outline-search::-webkit-search-cancel-button,
#tree-outline-search::-webkit-search-decoration,
#tree-outline-search::-webkit-search-results-button,
#tree-outline-search::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

#tree-outline-search::-ms-clear {
  display: none;
}

/* Sneat `.btn:hover { transform: translateY(-1px) }` / `.btn:focus { translateY(0) }`
   replace the whole transform and would yank this absolute button out of the input. */
.tree-outline-search-clear {
  position: absolute;
  top: 50%;
  right: 0.15rem;
  z-index: 2;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  margin: 0;
  line-height: 1;
  color: var(--bs-secondary-color);
  background-color: transparent;
  border: 0;
  box-shadow: none;
  transform: translateY(-50%);
}

.tree-outline-search-clear:hover,
.tree-outline-search-clear:focus,
.tree-outline-search-clear:focus-visible,
.tree-outline-search-clear:active {
  top: 50%;
  right: 0.15rem;
  margin: 0;
  color: var(--bs-body-color);
  background-color: transparent;
  border: 0;
  box-shadow: none;
  transform: translateY(-50%);
}

.tree-outline-search-clear:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 1px;
}

.tree-outline-search-count {
  flex: 0 1 auto;
  white-space: nowrap;
}

.tree-outline-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.tree-outline-root {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.75rem 1.25rem 1rem;
  overflow: auto;
}

.tree-outline-details {
  flex: 1 1 45%;
  min-width: 0;
  padding: 1rem 1.25rem;
  overflow: auto;
}

/* Detalji čvora and the Struktura timeline column step off the card so they
   read as their own sections. Light darkens the paper; dark moves toward the
   page background. List items stay transparent, so they inherit this fill. */
.tree-detail-panel,
.tree-outline-details {
  background-color: color-mix(in srgb, var(--bs-paper-bg) 94%, black);
}

[data-bs-theme=dark] .tree-detail-panel,
[data-bs-theme=dark] .tree-outline-details {
  background-color: color-mix(in srgb, var(--bs-paper-bg) 70%, var(--bs-body-bg));
}

@media (max-width: 991.98px) {
  .tree-outline-shell {
    flex-direction: column;
  }

  .tree-outline-tree-pane {
    flex-basis: auto;
    max-height: 55vh;
    border-right: 0;
    border-bottom: var(--bs-border-width) solid var(--bs-border-color);
  }

  .tree-outline-toolbar-actions {
    margin-left: 0;
  }

  .tree-outline-details {
    flex-basis: auto;
  }
}

.tree-outline-item--match > .tree-outline-row {
  background-color: color-mix(in srgb, var(--bs-warning) 12%, var(--bs-body-bg));
}

.tree-outline-mark {
  padding: 0.05em 0.15em;
  color: inherit;
  background-color: color-mix(in srgb, var(--bs-warning) 45%, transparent);
  border-radius: 0.15rem;
}

.tree-outline-item:focus {
  outline: none;
}

.tree-outline-item:focus-visible > .tree-outline-row {
  outline: 2px solid var(--bs-primary);
  outline-offset: 1px;
}

.tree-outline-details-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.tree-outline-details-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tree-outline-details-heading {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
}

.tree-outline-details-subheading {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.tree-outline-details-section + .tree-outline-details-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: var(--bs-border-width) solid
    color-mix(in srgb, var(--bs-border-color) 70%, transparent);
}

.tree-path-timeline {
  position: relative;
  margin: 0;
  padding: 0 0 0 1.1rem;
}

.tree-path-timeline::before {
  position: absolute;
  top: 0.4rem;
  bottom: 0.4rem;
  left: 0.2rem;
  width: 1px;
  content: "";
  background-color: var(--bs-border-color);
}

.tree-path-timeline-item {
  position: relative;
  margin-bottom: 0.55rem;
  padding-left: 0.35rem;
}

.tree-path-timeline-item::before {
  position: absolute;
  top: 0.45rem;
  left: -1rem;
  width: 0.45rem;
  height: 0.45rem;
  content: "";
  border-radius: 50%;
  background-color: var(--bs-secondary);
}

.tree-path-dot-primary::before {
  background-color: var(--bs-primary);
}

.tree-path-dot-success::before {
  background-color: var(--bs-success);
}

.tree-path-dot-secondary::before {
  background-color: var(--bs-secondary);
}

.tree-path-timeline-item.active .tree-path-timeline-btn {
  font-weight: 600;
  color: var(--bs-primary);
}

.tree-path-timeline-btn,
.tree-outline-edge-btn {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  max-width: 100%;
  padding: 0;
  color: inherit;
  text-align: start;
  background: transparent;
  border: 0;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.tree-path-timeline-btn:hover,
.tree-outline-edge-btn:hover {
  text-decoration: underline;
}

.tree-path-timeline-condition {
  font-style: italic;
  color: var(--bs-secondary-color);
}

.tree-outline-edge-list > li {
  margin-bottom: 0.4rem;
}

.tree-outline-more-paths {
  text-decoration: none;
}

.tree-outline-tree,
.tree-outline-group {
  margin: 0;
  padding-left: 0;
}

.tree-outline-group {
  padding-left: 1.25rem;
}

.tree-outline-item {
  list-style: none;
}

.tree-outline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: var(--bs-border-radius);
  cursor: pointer;
  color: var(--bs-body-color);
}

.tree-outline-row:hover,
.tree-outline-row:focus-visible {
  background-color: var(--bs-tertiary-bg);
}

.tree-outline-row.active {
  background-color: color-mix(in srgb, var(--bs-primary) 16%, var(--bs-body-bg));
}

.tree-outline-toggle,
.tree-outline-toggle-spacer {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  line-height: 1.25rem;
  color: var(--bs-secondary-color);
}

.tree-outline-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
}

.tree-outline-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.15rem 0.35rem;
}

.tree-outline-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tree-outline-answer-text {
  font-style: italic;
  color: var(--bs-secondary-color);
}

.tree-outline-backref {
  font-style: italic;
}

.tree-outline-unreachable > .tree-outline-row {
  cursor: default;
}

/* Separator sits on the row itself so it hides with the row (data-field-row toggles d-none). */
.node-detail-attr {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: var(--bs-border-width) solid
    color-mix(in srgb, var(--bs-border-color) 60%, transparent);
}

.node-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.node-detail-toolbar:not(:has(> :not(.d-none))) {
  display: none;
}

.node-detail-answers-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

#node-detail-answers .node-detail-answer-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.node-detail-answer-main {
  flex: 1 1 8rem;
  min-width: 0;
}

.node-detail-answer-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

#node-detail-answers .node-detail-answer-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.node-detail-answer-destination {
  color: var(--bs-secondary-color);
}

.node-detail-answer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-left: auto;
}

.node-detail-icon-btn {
  --bs-btn-padding-y: 0.2rem;
  --bs-btn-padding-x: 0.35rem;
  line-height: 1;
}

/* Unset destination only. The plus is out of flow, so the button stays the
   same size as the other icon buttons. */
.node-detail-set-target {
  position: relative;
  --bs-btn-color: color-mix(in srgb, var(--bs-primary) 42%, var(--bs-secondary-color));
  --bs-btn-border-color: color-mix(in srgb, var(--bs-primary) 28%, var(--bs-border-color));
  --bs-btn-hover-color: color-mix(in srgb, var(--bs-primary) 65%, var(--bs-body-color));
  --bs-btn-hover-bg: color-mix(in srgb, var(--bs-primary) 12%, transparent);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--bs-primary) 40%, var(--bs-border-color));
  --bs-btn-active-color: color-mix(in srgb, var(--bs-primary) 65%, var(--bs-body-color));
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 18%, transparent);
  --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 40%, var(--bs-border-color));
  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

.node-detail-set-target-plus {
  position: absolute;
  top: 0;
  right: 0;
  width: 0.45rem;
  height: 0.45rem;
  font-size: 0.45rem;
  pointer-events: none;
}

/* The destination is the jump control. Theme colours keep it readable in dark mode. */
#node-detail-answers .node-detail-answer-jump {
  display: inline;
  width: auto;
  padding: 0;
  color: var(--bs-secondary-color);
  text-align: start;
  background: transparent;
  border: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

#node-detail-answers .node-detail-answer-jump:hover,
#node-detail-answers .node-detail-answer-jump:focus-visible {
  color: var(--bs-body-color);
  text-decoration: underline;
}

/* Menus use Popper strategy "fixed" so the panel's overflow-y does not clip them. */
.tree-detail-panel .dropdown-menu {
  z-index: 1080;
}

/* vis-network injects its own stylesheet at runtime (after this file), so the
   #tree-canvas prefix is what outranks `.vis-network div.vis-navigation div.vis-button`.
   Theme variables only — the same rules hold under data-bs-theme="dark". Sneat's
   --bs-secondary-bg equals --bs-border-color, so border and hover shades are mixed
   toward the body text colour to stay visible against the fill. */
#tree-canvas .vis-network div.vis-navigation div.vis-button {
  box-sizing: border-box;
  background-color: var(--bs-tertiary-bg);
  background-position: center;
  border: var(--bs-border-width) solid
    color-mix(in srgb, var(--bs-border-color) 80%, var(--bs-body-color));
  border-radius: var(--bs-border-radius);
  box-shadow: none;
  /* The arrow/zoom icons are vis-network's built-in green PNGs; desaturate them
     to match the neutral frame (background-image can't be recoloured otherwise). */
  filter: grayscale(1);
  transition: background-color 0.15s ease-in-out;
}

#tree-canvas .vis-network div.vis-navigation div.vis-button:hover {
  background-color: color-mix(in srgb, var(--bs-tertiary-bg) 88%, var(--bs-body-color));
  box-shadow: var(--bs-box-shadow-sm);
}

#tree-canvas .vis-network div.vis-navigation div.vis-button:active {
  background-color: color-mix(in srgb, var(--bs-tertiary-bg) 78%, var(--bs-body-color));
  box-shadow: none;
}

@media (max-width: 991.98px) {
  .tree-editor-layout {
    flex-direction: column;
  }

  .tree-detail-panel {
    flex-basis: auto;
    height: auto;
    min-height: 12rem;
    max-height: 50vh;
    border-right: 0;
    border-bottom: var(--bs-border-width) solid var(--bs-border-color);
  }
}

/* Theme switcher on auth pages: a small card-like chip in the top-right corner,
   above the centred login card. Theme variables keep it readable in both modes. */
.auth-theme-switcher {
  z-index: 1030;
  background-color: var(--bs-paper-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow-sm);
}

.auth-theme-switcher #theme-switcher {
  padding: 0.5rem;
  color: var(--bs-heading-color);
}

/* Runtime walkthrough: tablet tap targets and readable question size. */
.runtime-question {
  font-size: 1.75rem;
  line-height: 1.3;
}

.runtime-answer-btn {
  min-height: 3.5rem;
  font-size: 1.125rem;
  white-space: normal;
  text-align: left;
}

.runtime-copy-block {
  white-space: pre-wrap;
  font-size: 0.875rem;
  margin-bottom: 0;
}

/* Brand primary #2092ec over Sneat's #696cff. Vendored core.css stays untouched;
   this file loads after it. Most components (bg/text/border-primary, form focus
   and checks, nav pills/tabs, pagination, menu active, label tints) read
   --bs-primary / --bs-primary-rgb, so only the theme's hardcoded hex needs
   restating below. Derived shades follow Sneat's own ratios (subtle = 84% tint,
   hover = 90% shade, active = 80% shade). */
:root,
[data-bs-theme=light] {
  --bs-primary: #2092ec;
  --bs-primary-rgb: 32, 146, 236;
  --bs-primary-text-emphasis: #0d3a5e;
  --bs-primary-bg-subtle: #dbeefc;
  --bs-primary-border-subtle: #bcdef9;
  --bs-link-color: #2092ec;
  --bs-link-color-rgb: 32, 146, 236;
  --bs-link-hover-color: #1d83d4;
  --bs-link-hover-color-rgb: 29, 131, 212;
}

[data-bs-theme=dark] {
  --bs-primary: #2092ec;
  --bs-primary-rgb: 32, 146, 236;
  --bs-primary-text-emphasis: #79bef4;
  --bs-primary-bg-subtle: #293c5c;
  --bs-primary-border-subtle: #27507c;
  --bs-link-color: #79bef4;
  --bs-link-color-rgb: 121, 190, 244;
  --bs-link-hover-color: #87c4f5;
  --bs-link-hover-color-rgb: 135, 196, 245;
}

.apexcharts-theme-dark {
  --bs-primary: #2092ec;
}

.btn-primary {
  --bs-btn-bg: #2092ec;
  --bs-btn-border-color: #2092ec;
  --bs-btn-hover-bg: #1d83d4;
  --bs-btn-hover-border-color: #1a75bd;
  --bs-btn-focus-shadow-rgb: 32, 146, 236;
  --bs-btn-focus-box-shadow: 0 0 0 0.05rem rgba(32, 146, 236, 0.4);
  --bs-btn-active-bg: #1a75bd;
  --bs-btn-active-border-color: #186eb1;
  --bs-btn-disabled-bg: #2092ec;
  --bs-btn-disabled-border-color: #2092ec;
}

.btn-outline-primary {
  --bs-btn-color: #2092ec;
  --bs-btn-border-color: #2092ec;
  --bs-btn-hover-bg: #2092ec;
  --bs-btn-hover-border-color: #2092ec;
  --bs-btn-focus-shadow-rgb: 32, 146, 236;
  --bs-btn-active-bg: #2092ec;
  --bs-btn-active-border-color: #2092ec;
  --bs-btn-disabled-color: #2092ec;
  --bs-btn-disabled-border-color: #2092ec;
}

.progress,
.progress-stacked {
  --bs-progress-bar-bg: #2092ec;
}

.bg-label-primary,
.badge.bg-label-primary {
  background-color: rgba(32, 146, 236, 0.16) !important;
  color: #2092ec !important;
}

/* Brief mark on the answer card a tree-check row pointed at. */
.node-detail-answer-card.is-tree-check-target {
  animation: tree-check-highlight 1.2s ease;
}

@keyframes tree-check-highlight {
  0% {
    box-shadow: inset 0 0 0 2px var(--bs-primary);
  }
  100% {
    box-shadow: inset 0 0 0 2px transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .node-detail-answer-card.is-tree-check-target {
    animation: none;
    box-shadow: inset 0 0 0 2px var(--bs-primary);
  }
}
