/* ADA.Tools theme – mirrors lib/GUI/Resources/WPF_styles.xaml and lib/GUI/ReportTheme.py */
:root {
  --bg:          #1E1E1E;  /* header_background */
  --bg-row:      #171512;  /* alternating row shade */
  --bg-viewer:   #262626;
  --bg-hover:    #2c2a25;
  --text:        #E5E4E2;  /* text_white */
  --gold:        #f6c955;  /* text_magenta / border_magenta */
  --gold-check:  #deb64d;  /* checkbox fill */
  --gold-dark:   #c5a144;  /* button_bg_normal */
  --gold-hover:  #ae8e3c;  /* button_bg_hover */
  --gray:        #808080;
  --font: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
}
.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: 44px 1fr 28px; }
.empty { color: var(--gray); margin: 4px 0; font-size: 14px; }

/* ---------- HEADER ---------- */
.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--gold-dark);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 900; font-size: 15px; justify-self: start; }
.brand img { border-radius: 3px; }
.brand:hover span { color: var(--gold); }
.title { font-size: 16px; color: var(--text); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { justify-self: end; }

/* ---------- BUTTON ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  color: #fff;
  background: var(--gold-dark);
  border: 0;
  border-radius: 8px;
  padding: 5px 16px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--gold-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-block { width: 100%; }
.btn-small { font-size: 12px; padding: 2px 10px; font-weight: 400; }

/* ---------- MAIN ---------- */
.main { display: grid; grid-template-columns: 290px 1fr 300px; min-height: 0; }

.sidebar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-left { padding-right: 0; }
.sidebar-right { padding-left: 0; }
.panel {
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 8px 10px 10px;
}
.panel-grow { flex: 1; min-height: 140px; }
.label {
  color: var(--gold);
  font-weight: 700;
  padding-bottom: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--gold);
}
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.props { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 14px; }
.props dt { color: var(--gold); }
.props dd { margin: 0; word-break: break-word; }

/* ---------- PROPERTY SETS ---------- */
.psets { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.psets details { border: 1px solid #3a3a3a; border-radius: 6px; }
.psets summary {
  cursor: pointer; padding: 3px 8px; color: var(--gold); font-size: 14px;
  list-style: none; display: flex; gap: 6px; align-items: center;
}
.psets summary::-webkit-details-marker { display: none; }
.psets summary::before { content: "▸"; color: var(--gold-dark); transition: transform .15s; }
.psets details[open] summary::before { transform: rotate(90deg); }
.psets summary:hover { background: var(--bg-hover); }
.psets .props { padding: 4px 8px 6px; font-size: 13px; border-top: 1px solid #3a3a3a; }
.psets .props dt { color: #cdb27a; }

/* ---------- CHECKBOX (gold, like WPF template) ---------- */
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  flex: none;
  width: 15px; height: 15px; border-radius: 2px;
  background: var(--gold-check);
  display: grid; place-items: center;
}
.check:hover .box { background: var(--gold); }
.check .box::after {
  content: ""; width: 4px; height: 8px;
  border: solid var(--bg-row); border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  visibility: hidden;
}
.check input:checked + .box::after { visibility: visible; }
.check input:focus-visible + .box { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- FILTER (like SelectFromDict.xaml) ---------- */
.filter { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.filter-icon { font-size: 13px; }
.filter input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 14px;
  color: var(--gold);
  background: var(--bg);
  border: 1px solid var(--gold);
  border-radius: 5px;
  padding: 2px 8px;
}
.filter input::placeholder { color: #8a7a52; }
.filter input:focus { outline: none; box-shadow: 0 0 0 1px var(--gold); }

/* ---------- CONTAINMENT TREE ---------- */
.panel-tree { display: flex; flex-direction: column; min-height: 0; }
.tree-wrap { flex: 1; min-height: 0; overflow: auto; margin: 0 -6px; font-size: 14px; }
.tree, .tree ul, .results { list-style: none; margin: 0; padding: 0; }
.tree .children { display: none; }
.tree .node.open > .children { display: block; }
.row {
  display: flex; align-items: center; gap: 4px;
  height: 24px; padding-right: 4px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.row:hover { background: var(--bg-hover); }
.row.active { background: var(--gold-hover); color: #fff; }
.row.active .type, .row.active .count { color: #f3e6c4; }
.row.is-hidden .name, .row.is-hidden .type { opacity: .4; }
.twisty, .eye {
  flex: none; width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0; border: 0; background: none; color: var(--gold);
  cursor: pointer; border-radius: 3px;
}
.twisty { transition: transform .12s; font-size: 11px; }
.node.open > .row .twisty { transform: rotate(90deg); }
.twisty.leaf { visibility: hidden; }
.name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.type { color: var(--gray); font-size: 12px; flex: none; }
.count { color: var(--gold-dark); font-size: 12px; flex: none; }
.row .spacer { flex: 1; }
.eye { color: var(--gray); opacity: 0; }
.row:hover .eye, .row.is-hidden .eye, .eye:focus-visible { opacity: 1; }
.eye:hover { color: var(--gold); }
.eye svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.eye .slash { display: none; }
.row.is-hidden .eye { color: var(--gold-dark); }
.row.is-hidden .eye .slash { display: inline; }
.results .row { padding-left: 6px; }
.results-more { color: var(--gray); font-size: 13px; padding: 4px 6px; }

/* ---------- VIEWER ---------- */
.viewer {
  position: relative;
  margin: 10px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-viewer);
  min-height: 0;
}
#canvas { display: block; width: 100%; height: 100%; }
.viewer.measuring #canvas { cursor: crosshair; }
.label-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* ---------- MEASURE TOOLBAR ---------- */
.toolbar {
  position: absolute; top: 10px; left: 10px;
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 4px;
  background: rgba(30, 30, 30, .9);
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
}
.tool {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 13px;
  color: var(--gold);
  background: transparent;
  border: 0; border-radius: 7px;
  padding: 4px 10px;
  cursor: pointer;
}
.tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tool:hover:not(:disabled) { background: var(--bg-hover); }
.tool.active { background: var(--gold-dark); color: #fff; }
.tool:disabled { opacity: .4; cursor: default; }

.hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 4px 12px;
  background: rgba(30, 30, 30, .92);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  color: var(--text); font-size: 13px;
  text-align: center;
  pointer-events: none;
}
.hint[hidden] { display: none; }
.hint b { color: var(--gold); font-weight: 700; }

.measure-label {
  padding: 1px 7px;
  background: rgba(23, 21, 18, .9);
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font: 700 13px/1.4 var(--font);
  white-space: nowrap;
}
.measure-label.draft { border-style: dashed; color: var(--text); }
.measure-label.pin { margin-top: -28px; } /* sit above the point instead of covering it */

/* ---------- MEASUREMENT LIST ---------- */
.measure-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.measure-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px;
  padding: 3px 4px 3px 8px;
  border-left: 3px solid var(--gold-dark);
  background: var(--bg-row);
  border-radius: 4px;
}
.measure-item .m-name { font-size: 13px; color: var(--gray); }
.measure-item .m-value { color: var(--gold); font-weight: 700; }
.measure-item .m-coords { font-size: 13px; word-break: break-word; }
.measure-item .m-detail { grid-column: 1; font-size: 12px; color: var(--gray); }
.measure-item .m-del {
  grid-row: 1 / span 3; grid-column: 2;
  width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 5px; background: none;
  color: var(--gray); font-size: 16px; cursor: pointer;
}
.measure-item .m-del:hover { color: #fff; background: var(--gold-hover); }

/* ---------- RELOCATE ---------- */
.relocate-form[hidden] { display: none; }
.relocate-form {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px;
  background: var(--bg-row);
  border-left: 3px solid var(--gold-dark);
  border-radius: 4px;
}
.field-caption { font-size: 13px; color: var(--gray); }
.coords { color: var(--gold); font-weight: 700; font-size: 13px; margin-bottom: 4px; word-break: break-word; }
.fields { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 6px; font-size: 14px; }
.fields label { color: var(--gold); }
.fields input {
  min-width: 0;
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--gold-dark);
  border-radius: 5px;
  padding: 2px 6px;
}
.fields input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.fields .unit { color: var(--gray); font-size: 13px; }
.field-note { margin: 2px 0 0; font-size: 12px; color: var(--gray); }
.field-note[hidden] { display: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }
.btn-ghost { background: transparent; border: 1px solid var(--gold-dark); color: var(--gold); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }

/* ---------- DROPZONE / LOADER ---------- */
.dropzone {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(30, 30, 30, .94);
  transition: background .15s;
}
.dropzone.hidden { display: none; }
.dropzone.dragover { background: rgba(30, 30, 30, .97); outline: 2px dashed var(--gold); outline-offset: -12px; }
.dropzone-inner { text-align: center; max-width: 460px; width: 100%; }
.dropzone .logo { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.dropzone hr { border: none; border-top: 2px solid var(--gold-dark); margin: 12px 0 16px; }
.dropzone p { margin: 0 0 12px; color: var(--gold); font-size: 16px; }
.dropzone .hint-text { margin-top: 14px; color: var(--gray); font-size: 13px; }

.loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(30, 30, 30, .85);
  color: var(--gold);
}
.loader[hidden] { display: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--gold-hover); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- FOOTER ---------- */
.footer {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 12px;
  background: var(--bg);
  border-top: 1px solid var(--gold-dark);
  font-size: 13px;
}
.footer-left { color: var(--gray); }
.footer-center { color: var(--gold); }
.footer-right { justify-self: end; }
.footer-right a { color: var(--gold-hover); font-weight: 500; text-decoration: none; }
.footer-right a:hover { color: var(--gold); text-decoration: underline; }

/* ---------- SCROLLBARS ---------- */
.sidebar::-webkit-scrollbar, .tree-wrap::-webkit-scrollbar, .measure-list::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar::-webkit-scrollbar-thumb, .tree-wrap::-webkit-scrollbar-thumb, .measure-list::-webkit-scrollbar-thumb { background: #505050; border-radius: 8px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1200px) {
  .main { grid-template-columns: 250px 1fr 260px; }
}
@media (max-width: 860px) {
  .app { height: auto; min-height: 100dvh; }
  .main { grid-template-columns: 1fr; grid-template-rows: 60vh auto auto; }
  .viewer { grid-row: 1; margin: 8px 8px 0; }
  .sidebar { padding: 8px !important; overflow: visible; }
  .sidebar-left { grid-row: 2; }
  .sidebar-right { grid-row: 3; }
  .panel-tree { height: 50vh; }
  .footer-left { display: none; }
  .footer { grid-template-columns: 1fr auto; }
  .brand span { display: none; }
  .tool { padding: 4px 7px; }
}
