/* ==== css/app.css ==== */
/*
 * app.css - interface chrome for the VersaCAD .2D viewer.
 *
 * The drawing itself is painted on a canvas by vcad-render.js; nothing here
 * affects it apart from the sheet background, which the renderer owns.
 */
/* Theme.  The picker in the header writes data-theme on <html>:
 *   absent          - Auto:  follow the operating system
 *   data-theme=light - always light
 *   data-theme=dark  - always dark
 * The light palette lives on :root and is the fallback. The dark palette is
 * stated twice, once for "the OS is dark and the user has not forced light"
 * and once for "the user asked for dark"; the two lists must stay in step. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #5c6672;
  --line: #d8dde3;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --chip: #eef1f5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b; --panel: #1b1f24; --ink: #e6e9ee; --muted: #9aa4b0;
    --line: #2c333b; --accent: #4d8ef7; --accent-ink: #0b1220; --chip: #232a32;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171b; --panel: #1b1f24; --ink: #e6e9ee; --muted: #9aa4b0;
  --line: #2c333b; --accent: #4d8ef7; --accent-ink: #0b1220; --chip: #232a32;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}

header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none;
}
header h1 { font-size: 14px; margin: 0; font-weight: 650; letter-spacing: .01em; flex: none; }
header .sub {
  color: var(--muted); font-size: 12px;
  /* A long file name must ellipsise rather than shove the controls off-screen. */
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
header .spacer { flex: 1; }

/* Segmented picker (Light / Dark / Auto). The radios stay in the accessibility
   tree and keep arrow-key navigation; only the labels are visible. */
.seg {
  position: relative; display: inline-flex; flex: none;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.seg input {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.seg label {
  padding: 5px 10px; font-size: 12px; line-height: 1.5; cursor: pointer;
  color: var(--muted); background: var(--panel);
  border-left: 1px solid var(--line); user-select: none; white-space: nowrap;
}
.seg label:first-of-type { border-left: 0; }
.seg label:hover { color: var(--ink); background: var(--chip); }
.seg input:checked + label {
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.seg input:checked + label:hover { color: var(--accent-ink); background: var(--accent); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }

button, .btn {
  font: inherit; padding: 5px 11px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

main { flex: 1; display: flex; min-height: 0; }

#side {
  width: 268px; flex: none; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; padding: 12px;
  /* Column layout so the credit can sit at the foot of a short panel and
     simply follow the content once the panel scrolls. */
  display: flex; flex-direction: column;
}
#side.hidden { display: none; }

#credit {
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px; text-align: center; text-wrap: balance;
}
#credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#credit a:hover, #credit a:focus-visible { color: var(--accent); }
.grp { margin-bottom: 18px; }
.grp > h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 7px; font-weight: 600;
}
.row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.row .k { color: var(--muted); }
.row .v { text-align: right; font-variant-numeric: tabular-nums; word-break: break-all; }

label.chk {
  display: flex; align-items: center; gap: 7px; padding: 2px 0; cursor: pointer;
}
label.chk input { margin: 0; flex: none; }
label.chk .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.18); }
label.chk .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
label.chk .ct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }

.files { display: flex; flex-direction: column; gap: 3px; }
.files button {
  text-align: left; overflow: hidden; text-overflow: ellipsis;
  display: flex; justify-content: space-between; gap: 6px;
}
.files button[aria-current="true"] { background: var(--chip); border-color: var(--accent); }

.btns { display: flex; flex-wrap: wrap; gap: 6px; }
select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); width: 100%; }

#stage { flex: 1; position: relative; min-width: 0; background: var(--bg); }
#cv { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#cv.panning { cursor: grabbing; }
#cv.marquee { cursor: crosshair; }

#rect {
  position: absolute; border: 1px dashed var(--accent);
  background: rgba(31,111,235,.10); pointer-events: none; display: none;
}

#status {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 14px; padding: 4px 10px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  border-top: 1px solid var(--line); font-size: 12px;
  font-variant-numeric: tabular-nums; color: var(--muted);
  backdrop-filter: blur(3px);
}

#drop {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 24px; background: var(--bg); color: var(--muted);
}
#drop.hide { display: none; }
#drop.over { outline: 2px dashed var(--accent); outline-offset: -14px; }
#drop h2 { color: var(--ink); font-size: 17px; margin: 0; }
#drop p { margin: 0; max-width: 46ch; }

#warn {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: 70%; padding: 7px 12px; border-radius: 7px;
  background: var(--danger); color: #fff; font-size: 12px; display: none;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
kbd {
  background: var(--chip); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; font: 11px/1.6 ui-monospace, monospace;
}
