/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
/* SMART DISCOVERY — the window (components/discovery/ui.js). The editor's dialog look (ed-dlg) with its own compact cards; colours mean
   what they mean everywhere in INIQDASH: green = new / healthy, blue = information, violet = renamed, warm = relocated, red = removed /
   destructive, amber = attention. */
.sd {
  --sd-good: var(--success); --sd-info: var(--info); --sd-violet: #b49cff; --sd-warm: #ff9d4d; --sd-bad: var(--danger); --sd-warn: var(--warning); --sd-muted: var(--text-muted);
  --ed-chrome: var(--nav-bg, #16171c); --ed-chrome-2: var(--surface-tertiary, #242428); --ed-primary: var(--accent); --ed-on-primary: var(--accent-on);
  width: min(1000px, calc(100vw - 24px)); height: min(860px, calc(100vh - 32px)); display: none; flex-direction: column; overflow: hidden;
  background: var(--surface-secondary, #111113); color: var(--text-primary, #f1f1f3);
}
.sd[open] { display: flex; }
.sd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 14px 10px 20px; border-bottom: 1px solid var(--border-primary); }
.sd-head__t { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sd-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.sd-head__sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.sd-head__ic { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); }
.sd-body { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 14px 20px 18px; }
.sd-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border-primary); }
.sd-foot__gap { flex: 1 1 auto; }
.sd-body > *, .sd-list > * { flex-shrink: 0; }
.sd-ic { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; }
.sd-ic svg { width: 100%; height: 100%; fill: currentColor; }
.sd-muted { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.sd-btn--danger { background: var(--danger) !important; color: #fff !important; }

/* scanning */
.sd-scan { display: flex; align-items: center; gap: 28px; margin: auto; padding: 24px; }
.sd-scan__t { margin: 0 0 10px; font-size: 18px; font-weight: 700; }
.sd-radar { position: relative; width: 110px; height: 110px; flex: none; border-radius: 50%; background: radial-gradient(circle, var(--accent-soft) 0 30%, transparent 31%); }
.sd-radar span { position: absolute; inset: 0; border: 2px solid var(--accent-line); border-radius: 50%; animation: sd-ping 2.4s ease-out infinite; }
.sd-radar span:nth-child(2) { animation-delay: .8s; } .sd-radar span:nth-child(3) { animation-delay: 1.6s; }
@keyframes sd-ping { from { transform: scale(.3); opacity: 1; } to { transform: scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sd-radar span { animation: none; opacity: .5; } }
.sd-steps { margin: 0 0 8px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.sd-steps li::before { content: '○'; display: inline-block; width: 18px; color: var(--text-muted); }
.sd-steps li.is-on { color: var(--text-primary); } .sd-steps li.is-on::before { content: '◌'; color: var(--accent); }
.sd-steps li.is-done { color: var(--text-secondary); } .sd-steps li.is-done::before { content: '✓'; color: var(--success); }

/* overview */
.sd-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; font-weight: 600; }
.sd-dot { width: 9px; height: 9px; border-radius: 50%; } .sd-dot--ok { background: var(--success); box-shadow: 0 0 0 4px rgba(52, 209, 124, .16); }
.sd-hero { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: linear-gradient(135deg, rgba(52, 209, 124, .12), rgba(59, 167, 255, .06)); box-shadow: 0 0 0 1px rgba(52, 209, 124, .25) inset; }
.sd-hero__ic { width: 28px; height: 28px; color: var(--success); }
.sd-hero__t { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.sd-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.sd-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 0; border-radius: 14px; cursor: pointer; text-align: left; color: var(--text-primary);
  font: inherit; background: var(--ed-chrome-2); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.sd-tile:hover, .sd-tile.is-on { box-shadow: 0 0 0 1px var(--sd-c, var(--accent-line)) inset; background: var(--surface-interactive); }
.sd-tile__n { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--sd-c, var(--text-primary)); font-variant-numeric: tabular-nums; }
.sd-tile__l { font-size: 11.5px; color: var(--text-muted); line-height: 1.25; }
.sd-tone-good { --sd-c: var(--sd-good); } .sd-tone-info { --sd-c: var(--sd-info); } .sd-tone-violet { --sd-c: var(--sd-violet); } .sd-tone-warm { --sd-c: var(--sd-warm); }
.sd-tone-bad { --sd-c: var(--sd-bad); } .sd-tone-warn { --sd-c: var(--sd-warn); } .sd-tone-muted { --sd-c: var(--sd-muted); }
.sd-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sd-dash { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.sd-select, .sd-search { min-height: 36px; padding: 0 10px; border: 0; border-radius: 10px; font: 500 13px var(--font); color: var(--text-primary); background: var(--surface-secondary); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.sd-select { max-width: 100%; }
.sd-search { flex: 1 1 220px; min-width: 0; }
.sd-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.sd-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 32px; padding: 0 10px; border: 0; border-radius: 999px; cursor: pointer; font: 600 12px var(--font); color: var(--text-secondary);
  background: var(--ed-chrome-2); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.sd-chip b { font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--surface-secondary); color: var(--text-muted); font-size: 11px; }
.sd-chip.is-on { color: var(--accent-on); background: var(--accent); box-shadow: none; } .sd-chip.is-on b { background: rgba(0, 0, 0, .18); color: inherit; }
.sd-bulk { display: flex; align-items: center; gap: 8px; } .sd-bulk__n { margin-left: auto; }
.sd-list { display: flex; flex-direction: column; gap: 8px; }
.sd-moreitems { align-self: center; }

/* cards */
.sd-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 16px; background: var(--surface-primary); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.sd-card.is-sel { box-shadow: 0 0 0 1px var(--accent-line) inset, 0 0 0 3px var(--accent-soft); }
.sd-card.is-danger { box-shadow: 0 0 0 1px rgba(255, 77, 79, .6) inset, 0 0 0 3px rgba(255, 77, 79, .12); }
.sd-card--info { background: var(--surface-secondary); }
.sd-card__top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sd-card__id { flex: 1 1 auto; min-width: 0; }
.sd-card__t { margin: 0; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.sd-check { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.sd-bubble { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px; color: var(--sd-c); background: color-mix(in srgb, var(--sd-c) 16%, transparent); }
.sd-bubble .sd-ic { width: 20px; height: 20px; }
.sd-badge { flex: none; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--sd-c); background: color-mix(in srgb, var(--sd-c) 14%, transparent); white-space: nowrap; }
.sd-ignore { flex: none; min-height: 30px; font-size: 12px; color: var(--text-muted); background: transparent; }
.sd-card__rec { padding-left: 74px; }
.sd-rec { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; font-size: 13px; color: var(--accent); } .sd-rec b { color: var(--text-primary); }
.sd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 12px; align-items: end; padding-left: 74px; }
.sd-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-muted); min-width: 0; }
.sd-toggle { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; font-size: 12.5px !important; color: var(--text-secondary) !important; }
.sd-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.sd-extras { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-left: 74px; }
.sd-pop { align-self: center; }
.sd-details { padding-left: 74px; font-size: 12.5px; }
.sd-details summary { cursor: pointer; color: var(--text-muted); }
.sd-ents { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.sd-ents li { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.4fr) minmax(0, .7fr) auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 8px; background: var(--surface-secondary); }
.sd-ents li.is-tech { opacity: .6; }
.sd-ents code, .sd-rename code { font-size: 11.5px; color: var(--text-secondary); overflow-wrap: anywhere; }
.sd-ent__n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-role { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.sd-rename { margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.sd-changes { margin: 0; padding: 0 0 0 46px; list-style: none; display: grid; gap: 4px; font-size: 12.5px; }
.sd-changes li { display: flex; align-items: center; gap: 6px; }
.sd-radio { display: flex; flex-direction: column; gap: 4px; padding-left: 46px; font-size: 12.5px; }
.sd-radio label { display: flex; align-items: center; gap: 8px; cursor: pointer; } .sd-radio input { accent-color: var(--accent); }
.sd-radio label.is-danger { color: #ff8a8b; }
.sd-replace { display: flex; gap: 10px; margin-left: 46px; padding: 10px 12px; border-radius: 12px; background: rgba(59, 167, 255, .08); box-shadow: 0 0 0 1px rgba(59, 167, 255, .25) inset; }
.sd-note { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; color: var(--text-secondary); background: var(--surface-secondary); }
.sd-note--warn { color: #ffd77a; background: rgba(255, 194, 51, .08); }
.sd-note--bad { color: #ff9a9b; background: rgba(255, 77, 79, .1); }
.sd-safe { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; color: var(--success); }

/* empty / error / done */
.sd-empty, .sd-done { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: auto; padding: 28px 18px; max-width: 520px; text-align: center; }
.sd-empty__ic { width: 40px; height: 40px; color: var(--text-muted); } .sd-empty--bad .sd-empty__ic { color: var(--danger); }
.sd-empty__t { margin: 0; font-size: 16px; font-weight: 700; }
.sd-done__ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; color: #0c2a18; background: var(--success); box-shadow: 0 0 0 8px rgba(52, 209, 124, .16); }
.sd-done__ic .sd-ic { width: 30px; height: 30px; }
.sd-done__facts { margin: 4px 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 14px; font-weight: 600; }

/* preview, extras */
.sd-preview, .sd-extra { display: flex; flex-direction: column; gap: 10px; }
.sd-sec { padding: 12px 14px; border-radius: 14px; background: var(--surface-primary); box-shadow: 0 0 0 1px var(--border-primary) inset; }
.sd-sec.sd-tone-bad { box-shadow: 0 0 0 1px rgba(255, 77, 79, .5) inset; }
.sd-sec__t { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--sd-c, var(--text-primary)); }
.sd-sec ul { margin: 0; padding-left: 20px; display: grid; gap: 3px; font-size: 13px; }
.sd-ignored, .sd-hist { list-style: none !important; padding: 0 !important; }
.sd-ignored li, .sd-hist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.sd-hist li { justify-content: flex-start; }

/* the online demo's simulation buttons */
.sd-demo { padding: 10px 12px; border-radius: 14px; background: rgba(180, 156, 255, .08); box-shadow: 0 0 0 1px rgba(180, 156, 255, .3) inset; }
.sd-demo__t { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; font-size: 13px; }
.sd-demo__b { display: flex; flex-wrap: wrap; gap: 6px; }

/* toasts and the notification */
.sd-toast { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 13px;
  color: var(--text-primary); background: var(--surface-tertiary); box-shadow: 0 10px 30px -10px #000, 0 0 0 1px var(--border-primary) inset; z-index: 5; }
.sd-toast--bad { background: #3a1517; color: #ffb3b4; }
.sd-notice { position: fixed; right: 16px; bottom: 16px; z-index: 2147483000; width: min(400px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 18px;
  font-family: var(--font); color: var(--text-primary); background: var(--surface-tertiary, #242428); box-shadow: 0 20px 50px -14px #000, 0 0 0 1px var(--border-primary) inset; }
.sd-notice__top { display: flex; gap: 10px; align-items: flex-start; }
.sd-notice__b { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }

/* tablet / phone */
@media (max-width: 760px) {
  .sd { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .sd-head { padding: 12px 10px 8px 14px; } .sd-head__sub { display: none; }
  .sd-body { padding: 12px 14px 16px; } .sd-foot { padding: 10px 14px 14px; }
  .sd-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sd-card__rec, .sd-grid, .sd-extras, .sd-details { padding-left: 0; }
  .sd-changes, .sd-radio { padding-left: 0; } .sd-replace { margin-left: 0; }
  .sd-card__top { flex-wrap: wrap; } .sd-badge { order: 5; }
  .sd-ents li { grid-template-columns: minmax(0, 1fr) auto; } .sd-ents code { grid-column: 1 / -1; }
  .sd-scan { flex-direction: column; gap: 16px; text-align: center; } .sd-steps { text-align: left; }
  .sd-foot .ed-btn { flex: 1 1 auto; } .sd-foot__gap { display: none; }
}
/* the online demo's timer control stays out of the way while the window is open (it is in the window's own place on a phone) */
body:has(dialog.sd[open]) .iq-demo { display: none; }

/* the recommendation: its text and buttons beside the PREVIEW of the proposed widget (its real renderer) */
.sd-card__rec { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 240px); gap: 14px; align-items: start; }
.sd-rec__btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sd-pv { position: relative; overflow: hidden; border-radius: 12px; background: var(--page-bg); box-shadow: inset 0 0 0 1px var(--border-subtle); min-height: 60px; }
.sd-pv__w { transform-origin: 0 0; pointer-events: none; }
.sd-ent__meta { flex-basis: 100%; font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 640px) { .sd-card__rec { grid-template-columns: 1fr; } }
