/* ═══════════════════════════════════════════════════════════════════════════
   NEXT DOOR — premium UI system for the lead popup + AI concierge.

   One shared visual language so both surfaces look identical:
     · near-black panel (#0d0f12) with fine gold line-art
     · gold accent (#c9a227) used sparingly, as a luxury cue
     · white body with icon-prefixed fields
     · black CTA with a hairline gold border
     · trust row, then a quiet reassurance line

   All selectors are namespaced (.ndx-) so nothing can collide with the ported
   Realar theme CSS.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --ndx-ink: #0d0f12;
  --ndx-ink-2: #16191f;
  --ndx-gold: #c9a227;
  --ndx-gold-soft: #e3c766;
  --ndx-line: #e7e9ee;
  --ndx-text: #1d2430;
  --ndx-muted: #6b7684;
  --ndx-radius: 22px;
  --ndx-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

/* ── Shared overlay ─────────────────────────────────────────────────────── */
.ndx-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(8, 10, 13, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ndx-fade 0.28s ease-out;
  overflow-y: auto;
}
@keyframes ndx-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Shared panel ───────────────────────────────────────────────────────── */
.ndx-panel {
  width: 100%;
  max-width: 470px;
  background: #fff;
  border-radius: var(--ndx-radius);
  box-shadow: var(--ndx-shadow);
  overflow: hidden;
  animation: ndx-rise 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: inherit;
  color: var(--ndx-text);
  margin: auto;
}
@keyframes ndx-rise {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ── Dark header with line-art ──────────────────────────────────────────── */
.ndx-head {
  position: relative;
  background: linear-gradient(135deg, #0d0f12 0%, #16191f 55%, #0d0f12 100%);
  color: #fff;
  padding: 30px 30px 28px;
  overflow: hidden;
}

/* The line-art sits behind the copy, bleeding off the right edge. */
.ndx-art {
  position: absolute;
  right: -18px;
  top: 0;
  height: 100%;
  width: 62%;
  pointer-events: none;
  opacity: 0.5;
}
.ndx-art svg { width: 100%; height: 100%; }

.ndx-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}
.ndx-brand__mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.ndx-brand__txt { line-height: 1.15; }
.ndx-brand__txt strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2.6px;
}
.ndx-brand__txt span {
  font-size: 8.5px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.ndx-title {
  position: relative;
  z-index: 1;
  margin: 0 0 18px;
  font-size: 29px;
  line-height: 1.16;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: #fff;
  max-width: 15ch;
}

/* Short gold rule under the headline. */
.ndx-rule {
  position: relative;
  z-index: 1;
  width: 78px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ndx-gold), rgba(201, 162, 39, 0));
  margin-bottom: 16px;
}

.ndx-sub {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.74);
  max-width: 26ch;
}

/* ── Close button ───────────────────────────────────────────────────────── */
.ndx-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.ndx-close:hover { background: rgba(255, 255, 255, 0.18); transform: rotate(90deg); }
.ndx-close:focus-visible { outline: 2px solid var(--ndx-gold); outline-offset: 2px; }

/* ── Body / form ────────────────────────────────────────────────────────── */
.ndx-body { padding: 26px 30px 22px; background: #fff; }

.ndx-field { position: relative; margin-bottom: 12px; }
.ndx-field__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa4b2;
  pointer-events: none;
  display: flex;
}
.ndx-field input,
.ndx-field textarea {
  width: 100%;
  border: 1px solid var(--ndx-line);
  border-radius: 13px;
  background: #fcfcfd;
  padding: 15px 16px 15px 50px;
  font-size: 14.5px;
  color: var(--ndx-text);
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.ndx-field input::placeholder,
.ndx-field textarea::placeholder { color: #9aa4b2; }
.ndx-field input:focus,
.ndx-field textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--ndx-gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.14);
}

/* ── Primary CTA ────────────────────────────────────────────────────────── */
.ndx-cta {
  width: 100%;
  margin-top: 6px;
  padding: 17px 22px;
  border-radius: 13px;
  border: 1px solid var(--ndx-gold);
  background: var(--ndx-ink);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: background 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}
.ndx-cta__arrow { color: var(--ndx-gold); transition: transform 0.22s ease; display: flex; }
.ndx-cta:hover:not(:disabled) {
  background: #000;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
}
.ndx-cta:hover:not(:disabled) .ndx-cta__arrow { transform: translateX(5px); }
.ndx-cta:disabled { opacity: 0.6; cursor: not-allowed; }
.ndx-cta:focus-visible { outline: 2px solid var(--ndx-gold); outline-offset: 3px; }

/* ── Trust row ──────────────────────────────────────────────────────────── */
.ndx-trust {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
  padding-top: 4px;
}
.ndx-trust__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ndx-text);
  flex: 1 1 0;
  justify-content: center;
  position: relative;
}
.ndx-trust__item:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 22px;
  background: var(--ndx-line);
}
.ndx-trust__item svg { color: var(--ndx-ink); flex: 0 0 auto; }

.ndx-note {
  margin: 18px 0 0;
  padding-top: 15px;
  border-top: 1px solid var(--ndx-line);
  text-align: center;
  font-size: 12.5px;
  color: var(--ndx-muted);
}

.ndx-err {
  margin: 0 0 12px;
  padding: 10px 13px;
  border-radius: 10px;
  background: #fdf2f2;
  border: 1px solid #f5c6c6;
  color: #b3261e;
  font-size: 13px;
}

/* ── Success state ──────────────────────────────────────────────────────── */
.ndx-success { padding: 46px 34px 40px; text-align: center; }
.ndx-success__tick {
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: var(--ndx-ink);
  border: 1px solid var(--ndx-gold);
  color: var(--ndx-gold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ndx-success h3 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--ndx-ink);
  letter-spacing: -0.3px;
}
.ndx-success p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ndx-muted); }

/* ── Screen-reader-only helper ──────────────────────────────────────────── */
.ndx-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AI CONCIERGE — same design language, chat layout
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Launcher ───────────────────────────────────────────────────────────── */
.ndx-launch {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99998;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-radius: 50%;
  background: linear-gradient(145deg, #16191f 0%, #0d0f12 100%);
  color: var(--ndx-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease;
}
.ndx-launch:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 16px 38px rgba(0, 0, 0, 0.42); }
.ndx-launch:focus-visible { outline: 2px solid var(--ndx-gold); outline-offset: 4px; }

/* Soft gold halo to draw the eye without being loud. */
.ndx-launch::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 39, 0.3);
  animation: ndx-halo 2.8s ease-in-out infinite;
}
@keyframes ndx-halo {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 0; }
}

.ndx-launch__dot {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ndx-gold);
  border: 2px solid #0d0f12;
}

/* ── Chat window ────────────────────────────────────────────────────────── */
.ndx-chat {
  position: fixed;
  right: 22px;
  bottom: 98px;
  z-index: 99999;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 605px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--ndx-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ndx-rise 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.ndx-chat__head {
  position: relative;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #0d0f12 0%, #16191f 60%, #0d0f12 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}
.ndx-chat__art {
  position: absolute; right: -10px; top: 0; height: 100%; width: 46%;
  opacity: 0.33; pointer-events: none;
}
.ndx-chat__art svg { width: 100%; height: 100%; }

.ndx-chat__avatar {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(201, 162, 39, 0.6);
  background: rgba(201, 162, 39, 0.1);
  color: var(--ndx-gold);
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.ndx-chat__id { position: relative; z-index: 1; line-height: 1.3; min-width: 0; }
.ndx-chat__id strong { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: 0.2px; }
.ndx-chat__id span {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: rgba(255, 255, 255, 0.62);
}
.ndx-chat__live {
  width: 6px; height: 6px; border-radius: 50%;
  background: #2ecc71; flex: 0 0 auto;
}
.ndx-chat__actions { margin-left: auto; display: flex; gap: 6px; position: relative; z-index: 2; }
.ndx-chat__btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s ease;
}
.ndx-chat__btn:hover { background: rgba(255, 255, 255, 0.2); }
.ndx-chat__btn:focus-visible { outline: 2px solid var(--ndx-gold); outline-offset: 2px; }

/* ── Messages ───────────────────────────────────────────────────────────── */
.ndx-chat__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}
.ndx-chat__body::-webkit-scrollbar { width: 6px; }
.ndx-chat__body::-webkit-scrollbar-thumb { background: #d3d8e0; border-radius: 3px; }

.ndx-msg {
  max-width: 86%;
  padding: 12px 15px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.58;
  background: #fff;
  border: 1px solid #e9ecf1;
  border-bottom-left-radius: 5px;
  align-self: flex-start;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.ndx-msg a { color: var(--ndx-ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--ndx-gold); }
.ndx-msg strong { font-weight: 700; color: var(--ndx-ink); }
.ndx-msg--me {
  align-self: flex-end;
  background: var(--ndx-ink);
  color: #fff;
  border-color: var(--ndx-ink);
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 5px;
}
.ndx-msg--me strong { color: var(--ndx-gold-soft); }

/* Typing indicator */
.ndx-typing { display: flex; gap: 5px; align-items: center; padding: 14px 16px; }
.ndx-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ndx-gold);
  animation: ndx-bounce 1.15s infinite ease-in-out;
}
.ndx-typing span:nth-child(2) { animation-delay: 0.16s; }
.ndx-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes ndx-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick-reply chips */
.ndx-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.ndx-chips button {
  background: #fff;
  border: 1px solid var(--ndx-line);
  color: var(--ndx-text);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.ndx-chips button:hover {
  border-color: var(--ndx-gold);
  background: var(--ndx-ink);
  color: #fff;
}
.ndx-chips button:focus-visible { outline: 2px solid var(--ndx-gold); outline-offset: 2px; }

/* ── Composer ───────────────────────────────────────────────────────────── */
.ndx-chat__input {
  flex: 0 0 auto;
  display: flex;
  gap: 9px;
  align-items: flex-end;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--ndx-line);
}
.ndx-chat__input textarea {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 96px;
  min-height: 46px;
  resize: none;
  border: 1px solid var(--ndx-line);
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 14px;
  line-height: 1.4;
  font-family: inherit;
  color: var(--ndx-text);
  background: #fcfcfd;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ndx-chat__input textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--ndx-gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.13);
}
.ndx-chat__send {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border: 1px solid var(--ndx-gold);
  border-radius: 14px;
  background: var(--ndx-ink);
  color: var(--ndx-gold);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.ndx-chat__send:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
.ndx-chat__send:disabled { opacity: 0.42; cursor: not-allowed; }
.ndx-chat__send:focus-visible { outline: 2px solid var(--ndx-gold); outline-offset: 2px; }

.ndx-chat__foot {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px 11px;
  font-size: 10px;
  line-height: 1.5;
  color: #97a1ad;
  text-align: center;
  background: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE — full-screen sheets, thumb-friendly targets
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .ndx-overlay { padding: 0; align-items: flex-end; }

  .ndx-panel {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 96vh;
    overflow-y: auto;
    animation: ndx-sheet 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }
  @keyframes ndx-sheet {
    from { transform: translateY(100%); }
    to { transform: none; }
  }

  .ndx-head { padding: 24px 22px 22px; }
  .ndx-title { font-size: 25px; max-width: 13ch; }
  .ndx-sub { font-size: 13.5px; max-width: 100%; }
  .ndx-art { width: 52%; opacity: 0.38; right: -24px; }
  .ndx-body { padding: 20px 22px 20px; }
  .ndx-field input { padding: 15px 14px 15px 48px; font-size: 15px; }
  .ndx-cta { padding: 17px 18px; font-size: 15.5px; }

  /* Stack the trust row so labels never truncate. */
  .ndx-trust { flex-direction: column; align-items: stretch; gap: 11px; margin-top: 18px; }
  .ndx-trust__item { justify-content: flex-start; font-size: 13.5px; }
  .ndx-trust__item:not(:last-child)::after { display: none; }

  /* Chat becomes a full-screen sheet. */
  .ndx-chat {
    right: 0; left: 0; bottom: 0; top: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: 100%;
    border-radius: 0;
    animation: ndx-sheet 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .ndx-chat__head { padding: 15px 16px; padding-top: max(15px, env(safe-area-inset-top)); }
  .ndx-chat__body { padding: 16px; }
  .ndx-msg { max-width: 90%; font-size: 14.5px; }
  .ndx-chat__input { padding: 11px; padding-bottom: max(11px, env(safe-area-inset-bottom)); }
  .ndx-chat__foot { display: none; } /* reclaim vertical space on small screens */

  .ndx-launch { right: 16px; bottom: 16px; width: 58px; height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .ndx-overlay, .ndx-panel, .ndx-chat { animation: none; }
  .ndx-launch::before { animation: none; }
  .ndx-typing span { animation: none; }
  .ndx-launch, .ndx-cta, .ndx-close, .ndx-chat__send { transition: none; }
  .ndx-cta:hover:not(:disabled), .ndx-launch:hover { transform: none; }
}
