/**
 * public/css/components/nursery-settings.css
 * Canopy v2 component - Settings, Nursery sensors (#592): connect form,
 * connection status, LimitRow and the Show on Home checklist.
 * Approved mockup: docs/design/mockups/nursery-settings-mockup.html.
 * Consumes ONLY --v2-* tokens. Row, field and button chrome comes from
 * settings-drawer.css and onboarding-wizard.css.
 */

.nur-settings {
  font-family: var(--v2-font-body);
  color: var(--v2-text-primary);
}

.nur-settings,
.nur-settings *,
.nur-settings *::before,
.nur-settings *::after { box-sizing: border-box; }

.nur-settings .ic {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.nur-settings .section-label { margin-top: var(--v2-space-md); }
.nur-settings .section-label:first-child { margin-top: var(--v2-space-sm); }

.nur-settings .help,
.nur-settings .ns-note {
  font-size: 13px;
  line-height: 1.5;
  color: var(--v2-text-secondary);
  margin: 0 4px var(--v2-space-sm);
}

.nur-settings .field-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--v2-text-secondary);
}

.nur-settings .row-sub {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  font-weight: 400;
  color: var(--v2-text-secondary);
}

.nur-settings .ns-flash:empty { display: none; }
.nur-settings .ns-flash {
  margin: 0 4px var(--v2-space-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--v2-pop-sage);
}

/* ---- status banners (inline, not toasts). The shared .nur-banner is defined
 * in nursery-card.css; these scoped rules make the Settings view render the
 * same with or without it. ---- */
.nur-settings .ns-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--v2-radius-md);
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: var(--v2-space-sm);
}
.nur-settings .ns-banner .ic { margin-top: 1px; }
.nur-settings .ns-banner.bad {
  background: var(--v2-pop-coral-bg);
  color: var(--v2-pop-coral-text);
  border: 1px solid var(--v2-pop-coral);
}
.nur-settings .ns-banner.quiet {
  background: var(--v2-bg-secondary);
  color: var(--v2-text-primary);
  border: 1px solid var(--v2-border-strong);
}
.nur-settings .ns-banner.info {
  background: var(--v2-pop-slate-bg);
  color: var(--v2-pop-slate-text);
  border: 1px solid var(--v2-pop-slate);
}

.nur-settings .ns-retry { margin-top: var(--v2-space-sm); }

/* ---- connect form: 48px key fields, 16px+ so iOS Safari does not zoom ---- */
.nur-settings .text-input.ns-key {
  height: 48px;
  font-family: var(--v2-font-body);
  font-size: max(16px, 1rem);
  font-weight: 500;
}
.nur-settings .text-input.mac {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.nur-settings .text-input[aria-invalid="true"] { border-color: var(--v2-pop-coral); }
.nur-settings .text-input:focus-visible {
  outline: 2px solid var(--v2-accent-botanical);
  outline-offset: 2px;
}

/* ---- connection status line ---- */
.nur-settings .conn-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  min-height: 48px;
  border-bottom: 1px solid var(--v2-border-soft);
}
.nur-settings .conn-line:last-child { border-bottom: none; }
.nur-settings .conn-text { flex: 1; min-width: 0; }
.nur-settings .conn-title { font-size: 15px; font-weight: 600; }
.nur-settings .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--v2-pop-sage);
  flex: none;
}
.nur-settings .dot.bad { background: var(--v2-pop-coral); }

.nur-settings .section-row .ic.chevron {
  width: 16px;
  height: 16px;
  color: var(--v2-text-muted);
}

/* ---- LimitRow: low / high number pair ---- */
.nur-settings .lim {
  padding: 16px;
  border-bottom: 1px solid var(--v2-border-soft);
}
.nur-settings .lim:last-child { border-bottom: none; }
.nur-settings .lim-name { font-size: 15px; font-weight: 600; }
.nur-settings .lim-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--v2-space-sm);
  margin-top: var(--v2-space-sm);
}
.nur-settings .lim-pair label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nur-settings .lim-pair label span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--v2-text-support);
}
.nur-settings .lim-unit {
  margin-top: 6px;
  font-size: 12px;
  color: var(--v2-text-secondary);
}
.nur-settings .text-input.num {
  height: 48px;
  text-align: center;
  font-family: var(--v2-font-display);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nur-settings .ns-error {
  margin: 0 4px var(--v2-space-sm);
  font-size: 13px;
  line-height: 1.4;
  color: var(--v2-pop-coral-text);
}
.nur-settings .ns-error:empty { display: none; }

/* save-bar status chip (outside .nur-settings: the bar is a drawer sibling) */
.save-bar .ns-save-status {
  margin-top: var(--v2-space-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--v2-text-secondary);
}
.save-bar .ns-save-status:empty { display: none; }

/* ---- Show on Home checklist ---- */
.nur-settings .chk {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--v2-border-soft);
  font: inherit;
  color: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  cursor: pointer;
}
.nur-settings .chk:last-child { border-bottom: none; }
.nur-settings .chk:focus-visible {
  outline: 2px solid var(--v2-accent-botanical);
  outline-offset: -2px;
  border-radius: var(--v2-radius-xs);
}
.nur-settings .chk-box {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1.5px solid var(--v2-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--v2-text-on-accent);
}
.nur-settings .chk-box .ic {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
  opacity: 0;
}
.nur-settings .chk.on .chk-box {
  background: var(--v2-accent-botanical);
  border-color: var(--v2-accent-botanical);
}
.nur-settings .chk.on .chk-box .ic { opacity: 1; }
.nur-settings .chk-t { flex: 1; font-size: 15px; font-weight: 500; }
.nur-settings .chk-end {
  font-size: 12px;
  color: var(--v2-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ---- load-failed retry button (.secondary-cta is not loaded in index.html) ---- */
.nur-settings .ns-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--v2-space-lg);
  background: var(--v2-bg-card);
  color: var(--v2-accent-botanical);
  border: 1px solid var(--v2-accent-botanical);
  border-radius: var(--v2-radius-sm);
  font-family: var(--v2-font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.nur-settings .ns-retry:focus-visible {
  outline: 2px solid var(--v2-accent-botanical);
  outline-offset: 2px;
}

/* ---- sensors list and panel (REQ-0003, #610) ---- */
/* A row that is not a button: members' list, the Counts switch row. */
.nur-settings .section-row.ns-static { cursor: default; }
.nur-settings .ns-banner-host:empty { display: none; }
/* "Not now" under the Counts switch: full width, 44px+ */
.nur-settings .ns-retry.ns-wide {
  display: flex;
  width: 100%;
  margin-top: var(--v2-space-md);
}
.nur-settings .ns-retry:disabled { opacity: 0.5; cursor: default; }
/* Inline name error sits under the hint inside the field row */
.nur-settings .field-row .ns-error { margin: var(--v2-space-xs) 0 0; }
.nur-settings .text-input.ns-key[aria-invalid="true"] { border-color: var(--v2-pop-coral); }

/* ---- Grow-light hours (REQ-0004, #620): inline time fields ---- */
.nur-settings .ns-time {
  min-height: var(--v2-space-touch);
  min-width: 118px;
  padding: 0 12px;
  border: 1px solid var(--v2-border-strong);
  border-radius: var(--v2-radius-md);
  background: var(--v2-bg-secondary);
  color: var(--v2-text-primary);
  font: 600 16px var(--v2-font-body);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.nur-settings .ns-time:disabled { opacity: 0.6; }
.nur-settings .ns-gl-hint { display: block; padding: 8px 4px 0; }

/* ---- Suggest limits (#593, mockup nursery-soil-calibrate-suggest-677 S1-S3) ---- */
/* One Claude suggestion under a limit: the reason in one line. */
.nur-settings .ns-why { font-size: 12px; color: var(--v2-text-secondary); padding: 0 var(--v2-space-md) var(--v2-space-sm); margin-top: -4px; }
.nur-settings .ns-suggest-actions { display: flex; gap: var(--v2-space-sm); padding: var(--v2-space-sm) var(--v2-space-md) var(--v2-space-md); }
.nur-settings .ns-suggest-actions .ns-retry { flex: 1; margin-top: 0; gap: var(--v2-space-xs); }
.nur-settings .ns-suggest > .ns-banner,
.nur-settings .ns-suggest > .ns-note { margin: var(--v2-space-sm) var(--v2-space-md); }
/* The reason belongs to the limit above it: the row divider moves below the reason. */
.nur-settings .lim:has(+ .ns-why) { border-bottom: none; }
.nur-settings .ns-why:not(:last-child) { border-bottom: 1px solid var(--v2-border-soft); }

/* ---- Calibrate moisture settings (#677, mockup nursery-soil-calibrate-suggest-677 C0-C5) ---- */
/* Three-segment progress bar: segments up to the current step are filled. */
.nur-settings .ns-progress { display: flex; gap: var(--v2-space-xs); padding: var(--v2-space-sm) var(--v2-space-md) 0; }
.nur-settings .ns-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--v2-border-soft); }
.nur-settings .ns-progress i.on { background: var(--v2-accent-terracotta-dark); }
/* Step header: "Step 2 of 3 · Just watered". */
.nur-settings .ns-step { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--v2-text-secondary); padding: var(--v2-space-xs) var(--v2-space-md); }
/* The live reading the step is about: big number, small caption. */
.nur-settings .ns-reading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--v2-space-sm); padding: var(--v2-space-md); }
.nur-settings .ns-reading-val { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--v2-text-primary); }
.nur-settings .ns-reading-cap { font-size: 13px; color: var(--v2-text-secondary); text-align: right; }
/* The two numbers to type into the Ecowitt app. */
.nur-settings .ns-copy { display: grid; grid-template-columns: 1fr 1fr; gap: var(--v2-space-sm); padding: var(--v2-space-md); }
.nur-settings .ns-copy div { border: 1px solid var(--v2-border-soft); border-radius: var(--v2-radius-md); padding: var(--v2-space-sm) var(--v2-space-md); display: flex; flex-direction: column; gap: 2px; }
.nur-settings .ns-copy span { font-size: 12px; font-weight: 600; color: var(--v2-text-secondary); }
.nur-settings .ns-copy b { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--v2-text-primary); }
.nur-settings .ns-howto { margin: 0; padding: 0 var(--v2-space-md) var(--v2-space-md) calc(var(--v2-space-md) + 18px); display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--v2-text-primary); }
/* Numbered steps on the intro: each is a bold action plus a "when". */
.nur-settings .ns-howto li span { display: block; font-size: 13px; color: var(--v2-text-secondary); margin-top: 2px; }
/* Plain-language headline and its one-line reason. */
.nur-settings .ns-lead { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.25; color: var(--v2-text-primary); padding: var(--v2-space-md) var(--v2-space-md) 0; }
.nur-settings .ns-why-line { margin: 0; font-size: 15px; color: var(--v2-text-secondary); padding: var(--v2-space-xs) var(--v2-space-md) 0; }
/* One-line payoff under a screen. */
.nur-settings .ns-after { margin: 0; font-size: 14px; color: var(--v2-text-primary); padding: var(--v2-space-sm) var(--v2-space-md) 0; }
/* Help lines and notes that line up with the step text. */
.nur-settings .help.ns-pad { margin: 0; padding: 0 var(--v2-space-md); }
.nur-settings .help.ns-pad-top { padding-top: var(--v2-space-sm); }
.nur-settings .ns-inset { margin: var(--v2-space-md) var(--v2-space-md) 0; }
.nur-settings .ns-banner.ns-inset,
.nur-settings .ns-inset-sm { margin: var(--v2-space-sm) var(--v2-space-md); }
.nur-settings .ns-calibration:empty { display: none; }
.nur-settings .ns-calibration > .ns-banner { margin: var(--v2-space-sm) 0; }
/* A step button that cannot be used yet (no reading, or Ecowitt would refuse the numbers) looks off. */
.drawer[data-settings-view="nursery_calibration"] .save-bar .primary-cta:disabled {
  background: var(--v2-bg-secondary);
  color: var(--v2-text-tertiary);
  cursor: not-allowed;
}

/* ---- Suggest limits working state (#711, mockup nursery-settings-suggest-busy-711 C2) ---- */
.nur-settings .ns-content[hidden] { display: none; }
.nur-settings .ns-spin { flex: none; width: 32px; height: 32px; color: var(--v2-accent-botanical); animation: ns-spin 0.9s linear infinite; }
.nur-settings .ns-spin-static { display: none; flex: none; width: 32px; height: 32px; color: var(--v2-accent-botanical); }
@keyframes ns-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .nur-settings .ns-spin { display: none; }
  .nur-settings .ns-spin-static { display: block; }
}
.nur-settings .ns-busy { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--v2-space-sm); min-height: 420px; padding: var(--v2-space-xl) var(--v2-space-lg); }
.nur-settings .ns-busy-t { font-size: 20px; font-weight: 700; line-height: 1.25; }
.nur-settings .ns-busy-s { font-size: 14px; color: var(--v2-text-secondary); max-width: 28ch; }
