/* ============================================================
   CDS Design Canvas — styling
   Matches the Copeland Design Studio dark workspace theme
   (navy / orange, dark surfaces) used by the portal + tools.
   ============================================================ */

:root {
  --navy:     #001F5B;
  --navy-dk:  #000D2B;
  --blue:     #003087;
  --orange:   #E8500A;
  --bg:       #080E1E;
  --surface:  #0F1729;
  --surface2: #162040;
  --border:   #1E2D50;
  --border2:  #2A3F70;
  --text:     #E2E8F4;
  --muted:    #8899BB;
  --white:    #FFFFFF;
}

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

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── NAV (mirrors portal) ─────────────────────────────────── */
.nav {
  flex: 0 0 auto;
  background: rgba(8,14,30,0.96);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 48px;
  gap: 16px;
}
.nav__brand {
  font-size: 11px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--white); white-space: nowrap;
}
.nav__brand span { color: var(--orange); }
.nav__title { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.5px; }
.nav__badge {
  margin-left: auto; background: var(--orange); color: #fff;
  font-size: 10px; font-weight: 700; padding: 3px 9px;
  border-radius: 3px; letter-spacing: 0.5px;
}
.nav__home { color: var(--muted); text-decoration: none; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }
.nav__home:hover { color: var(--orange); }

/* ── TOOLBAR ──────────────────────────────────────────────── */
.toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tb-group { display: flex; gap: 6px; align-items: center; }
.tb-sep { width: 1px; height: 24px; background: var(--border2); margin: 0 4px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border2); border-radius: 5px;
  padding: 7px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.tb-btn:hover { background: #1d2c52; border-color: var(--orange); }
.tb-btn:active { transform: translateY(1px); }
.tb-btn--primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.tb-btn--primary:hover { background: #ff6a24; border-color: #ff6a24; }
.tb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tb-btn:disabled:hover { background: var(--surface2); border-color: var(--border2); }
.tb-icon { font-size: 14px; line-height: 1; }
.upload-error {
  display: none; margin-left: 8px; color: #FF6A6A; font-size: 12px;
  font-weight: 600; background: rgba(204,34,0,0.12);
  border: 1px solid rgba(204,34,0,0.4); padding: 5px 10px; border-radius: 4px;
}

/* ── LAYOUT ───────────────────────────────────────────────── */
.workspace { flex: 1 1 auto; display: grid; grid-template-columns: 200px 1fr 260px; min-height: 0; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.sidebar--right { border-right: none; border-left: 1px solid var(--border); }
.side-head {
  padding: 12px 16px 8px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px; color: var(--orange);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline;
}
.side-count { color: var(--muted); font-size: 10px; letter-spacing: 0.5px; }

/* ── PALETTE ──────────────────────────────────────────────── */
.palette { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 8px 10px; cursor: grab; text-align: left;
  color: var(--text); transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.palette-item:hover { border-color: var(--orange); background: #1d2c52; transform: translateX(2px); }
.palette-item.is-armed { border-color: var(--orange); background: #24345c;
  box-shadow: 0 0 0 1px var(--orange) inset; }
.palette-item:active { cursor: grabbing; }
.palette-icon { width: 34px; height: 34px; flex: 0 0 auto;
  background: #fff; border-radius: 5px; padding: 2px; }
.palette-name { font-size: 12px; font-weight: 600; }
.palette-hint { padding: 4px 14px 14px; font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ── CANVAS ───────────────────────────────────────────────── */
.canvas-wrap { position: relative; min-width: 0; background:
  var(--navy-dk)
  repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(0,48,135,0.10) 31px, rgba(0,48,135,0.10) 32px)
  repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(0,48,135,0.10) 31px, rgba(0,48,135,0.10) 32px);
}
#svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#svg.is-placing { cursor: crosshair; }
#svg:active { cursor: grabbing; }

.placed { cursor: move; }
.sym-label {
  font: 700 11px -apple-system, 'Segoe UI', Arial, sans-serif;
  fill: #fff; paint-order: stroke; stroke: #0A1122; stroke-width: 3px;
  stroke-linejoin: round; pointer-events: none;
}
.sel-box { fill: none; stroke: var(--orange); stroke-width: 1.5px; stroke-dasharray: 5 4; }
.handle { fill: var(--orange); stroke: #fff; stroke-width: 1.5px; }
.handle--resize { cursor: nwse-resize; }
.handle--rotate { cursor: grab; fill: #fff; stroke: var(--orange); }

.canvas-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); pointer-events: none; text-align: center; padding: 24px;
}
.canvas-empty__icon { font-size: 40px; opacity: 0.6; }
.canvas-empty__title { font-size: 15px; font-weight: 700; color: var(--text); }
.canvas-empty__sub { font-size: 12px; max-width: 320px; line-height: 1.6; }

/* ── SCHEDULE (right sidebar top) ─────────────────────────── */
.schedule { flex: 1 1 auto; overflow-y: auto; padding: 8px; min-height: 120px; }
.sched-empty { color: var(--muted); font-size: 12px; padding: 16px 8px; text-align: center; }
.sched-row {
  display: flex; align-items: center; gap: 7px; padding: 5px 7px;
  border-radius: 5px; cursor: pointer; border: 1px solid transparent;
}
.sched-row:hover { background: var(--surface2); }
.sched-row.is-active { background: #24345c; border-color: var(--orange); }
.sched-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.sched-ref { font-family: 'Consolas','Monaco',monospace; font-size: 11px;
  font-weight: 700; color: var(--muted); flex: 0 0 auto; min-width: 48px; }
.sched-label {
  flex: 1 1 auto; min-width: 0; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px; color: var(--text);
  font-size: 12px; padding: 3px 6px;
}
.sched-label:focus { outline: none; border-color: var(--orange); }
.sched-del {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 4px;
  background: transparent; border: 1px solid var(--border2); color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.sched-del:hover { background: rgba(204,34,0,0.18); border-color: #CC2200; color: #FF6A6A; }

/* ── PROPERTIES (right sidebar bottom) ────────────────────── */
.props { border-top: 1px solid var(--border); padding: 12px 14px; }
.prop-empty { color: var(--muted); font-size: 12px; line-height: 1.5; }
.prop-form { display: flex; flex-direction: column; gap: 10px; }
.prop-type {
  font-size: 12px; font-weight: 700; color: var(--white);
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.prop-row { display: flex; flex-direction: column; gap: 3px; }
.prop-row--split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prop-label { font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted); }
.prop-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 12px; padding: 6px 8px; width: 100%;
}
.prop-input:focus { outline: none; border-color: var(--orange); }
.prop-del {
  margin-top: 4px; width: 100%; background: transparent;
  border: 1px solid rgba(204,34,0,0.5); color: #FF6A6A; border-radius: 5px;
  padding: 7px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.prop-del:hover { background: rgba(204,34,0,0.15); }

/* ── FOOTER ───────────────────────────────────────────────── */
.footer {
  flex: 0 0 auto; background: var(--navy-dk); border-top: 1px solid var(--border);
  padding: 8px 24px; font-size: 11px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.footer__brand { font-weight: 700; color: var(--white); }
.footer__brand em { color: var(--orange); font-style: normal; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 150px 1fr 220px; }
  .nav__title { display: none; }
}

/* ── MAP MODE PICKER (modal) ──────────────────────────────── */
.mapmodal {
  position: fixed; inset: 0; z-index: 1000;
  width: 100vw; height: 100vh;   /* explicit — body is a flex container */
  background: rgba(4,8,18,0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.mapmodal__panel {
  width: min(1100px, 96vw); height: min(760px, 92vh);
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.mapmodal__bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.mapmodal__title {
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--white);
}
.mapmodal__title::before { content: '\25C9'; color: var(--orange); margin-right: 7px; }
.mapmodal__search { display: flex; gap: 6px; align-items: center; }
.mapmodal__search input {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border2); border-radius: 5px;
  padding: 7px 10px; font-size: 12px; width: 170px;
}
.mapmodal__search input:focus { outline: none; border-color: var(--orange); }
.mapmodal__layers { display: flex; gap: 6px; }
.mapmodal__msg { font-size: 12px; font-weight: 600; color: var(--muted); min-height: 16px; }
.mapmodal__msg.is-err { color: #FF6A6A; }
.mapmodal__actions { margin-left: auto; display: flex; gap: 6px; }
.mapmodal__hint {
  flex: 0 0 auto; padding: 8px 16px; font-size: 11.5px; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.mapmodal__hint strong { color: var(--text); }
.mapmodal__map { flex: 1 1 auto; min-height: 0; background: #dfe3e6; }
/* Leaflet renders its own light controls; keep attribution legible. */
.mapmodal__map .leaflet-control-attribution {
  font-size: 10px; background: rgba(255,255,255,0.7);
}
