/* 15-ui.css — the shared D.ui widget kit + cross-screen shell furniture.
 * Buttons, rings, badges, gate chips, selects/inputs, fields, modal, toast,
 * the nav row + breadcrumb zoom-spine, tile grids and the empty-state hints.
 * Colors come strictly from css/00-tokens.css.
 */

/* ---- nav row + breadcrumb (chrome that screens render under) --------- */
.nav-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 49px; z-index: 4;
}
.group-chip {
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2);
}

.breadcrumb {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.crumb {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; color: var(--ink-dim);
  transition: background .12s, color .12s, border-color .12s;
}
.crumb:hover { background: var(--surface-2); color: var(--ink); }
.crumb.active {
  color: var(--ink); border-color: var(--line); background: var(--surface);
}
.crumb-name { font-weight: 600; font-size: 13px; }
.crumb-sep { color: var(--ink-faint); padding: 0 2px; user-select: none; }

/* ---- the screen host ------------------------------------------------- */
.screen { flex: 1; padding: 20px 16px; max-width: 1180px; width: 100%; margin: 0 auto; }
.screen-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.screen-head h2 { margin: 0; font-size: 20px; letter-spacing: .01em; }
.screen-head h3 { margin: 0; font-size: 15px; }
.screen-head.sub { margin: 22px 0 10px; }
.screen-head .sub { font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.muted { color: var(--ink-dim); }
.empty-hint {
  grid-column: 1 / -1; padding: 22px; border: 1px dashed var(--line);
  border-radius: var(--r); background: var(--surface);
  font-size: 14px; text-align: center;
}

/* ---- buttons --------------------------------------------------------- */
.btn {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 14px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
}
.btn:hover { background: var(--line); border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 18%, var(--surface-2)); }
.btn.small { font-size: 12px; padding: 5px 10px; }
.btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.disabled, .btn[disabled] {
  opacity: .45; cursor: not-allowed; pointer-events: none;
}

/* ---- ring (SVG donut) ------------------------------------------------ */
.ring { display: inline-flex; line-height: 0; }
.ring-track { stroke: var(--line); }
.ring-fill { stroke: var(--accent); transition: stroke-dashoffset .4s ease; }
.ring-text { fill: var(--ink); font-family: var(--mono); font-weight: 600; }
.ring.ring-ok    .ring-fill { stroke: var(--ok); }
.ring.ring-accent .ring-fill { stroke: var(--accent); }
.ring.ring-low   .ring-fill { stroke: var(--warn); }
.ring.ring-low   .ring-text { fill: var(--ink-dim); }

/* ---- pct badge ------------------------------------------------------- */
.pct-badge {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-dim); background: var(--surface-2);
}
.pct-badge.ok  { color: var(--ok);  border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.pct-badge.mid { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.pct-badge.low { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

/* ---- gate chip (toggle) ---------------------------------------------- */
.gate-chip {
  --chip-color: var(--accent);
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
  padding: 4px 9px; border-radius: 999px; cursor: pointer; user-select: none;
  border: 1px solid var(--line); color: var(--ink-faint);
  background: var(--surface-2); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background .12s, color .12s, border-color .12s;
}
.gate-chip::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); flex: none;
}
.gate-chip:hover { border-color: var(--chip-color); color: var(--ink-dim); }
.gate-chip.on {
  color: var(--chip-color);
  border-color: color-mix(in srgb, var(--chip-color) 55%, transparent);
  background: color-mix(in srgb, var(--chip-color) 16%, var(--surface));
}
.gate-chip.on::before { background: var(--chip-color); box-shadow: 0 0 6px var(--chip-color); }
/* non-interactive (read-only role) gate chips */
.gate-chip:not([onclick]) { cursor: default; }

/* ---- select + inputs ------------------------------------------------- */
.ui-select, .ui-input {
  font-family: var(--font); font-size: 13px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 10px; width: 100%;
}
.ui-select { cursor: pointer; }
.ui-select:focus, .ui-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.ui-color { padding: 2px; height: 34px; cursor: pointer; }
.ui-check { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---- field (labelled wrapper) ---------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-dim);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .field:first-child { grid-column: 1 / -1; }

/* ---- modal ----------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 5, 10, .66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .14s ease;
}
.modal {
  width: 100%; max-width: 460px; max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  animation: pop-in .16s ease;
}
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-title { margin: 0; font-size: 16px; }
.modal-x {
  background: none; border: none; color: var(--ink-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; border-top: 1px solid var(--line);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- toast ----------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  z-index: 60; max-width: 80vw;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: var(--r-sm); padding: 11px 16px; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- tile grid (used by floorplan browser) --------------------------- */
.tile-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .nav-row { top: 49px; }
}
