/* NTMG Lending chat widget — self-contained styles.
 *
 * Everything is scoped under .ntmg-widget-* so nothing leaks into the host
 * page. There are deliberately no global resets (no *, html, or body rules)
 * that could affect ntmglending.com once this is embedded in Phase B.
 *
 * Brand discipline: Cormorant Garamond is for the header title ONLY. All body
 * text, message content, and any numbers use DM Sans (numbers get bold +
 * tabular-nums). Animations are gentle — fade and slide only, never bounce.
 */

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap");

:root {
  --ntmg-navy: #0c1e35;
  --ntmg-deep-navy: #162d47;
  --ntmg-gold: #c9a84c;
  --ntmg-warm-white: #f5f2ec;
  --ntmg-slate: #8a9ab0;
  --ntmg-white: #ffffff;

  --ntmg-font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --ntmg-font-display: "Cormorant Garamond", Georgia, serif;
  --ntmg-shadow-soft: 0 4px 16px rgba(12, 30, 53, 0.18);
  --ntmg-shadow-strong: 0 8px 28px rgba(12, 30, 53, 0.26);
}

/* ── Floating bubble ─────────────────────────────────────────────────── */

.ntmg-widget-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ntmg-navy);
  border: 1px solid var(--ntmg-gold);
  box-shadow: var(--ntmg-shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 9998;
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}

.ntmg-widget-bubble:hover {
  transform: scale(1.03);
  box-shadow: var(--ntmg-shadow-strong);
}

.ntmg-widget-bubble:focus-visible {
  outline: 2px solid var(--ntmg-gold);
  outline-offset: 3px;
}

.ntmg-widget-bubble svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* Hide the bubble while the panel is open so they don't overlap. */
.ntmg-widget-bubble.ntmg-widget-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Chat panel ──────────────────────────────────────────────────────── */

.ntmg-widget-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 600px;
  max-height: 90vh;
  background: var(--ntmg-warm-white);
  border: 1px solid rgba(12, 30, 53, 0.08);
  border-radius: 14px;
  box-shadow: var(--ntmg-shadow-strong);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: var(--ntmg-font-body);
}

.ntmg-widget-panel.ntmg-widget-open {
  display: flex;
  animation: ntmg-widget-slide-up 200ms ease-out;
}

@keyframes ntmg-widget-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Panel header ────────────────────────────────────────────────────── */

.ntmg-widget-header {
  height: 64px;
  flex: 0 0 64px;
  background: var(--ntmg-navy);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.ntmg-widget-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.ntmg-widget-title {
  font-family: var(--ntmg-font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--ntmg-warm-white);
  margin: 0;
}

.ntmg-widget-tagline {
  font-family: var(--ntmg-font-body);
  font-weight: 500;
  font-size: 12px;
  color: var(--ntmg-slate);
  margin-top: 2px;
}

/* Persistent hand-off action row in the header (phone / calendar / mail). */
.ntmg-widget-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ntmg-widget-action {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: var(--ntmg-warm-white);
  transition: color 150ms ease-out, background 150ms ease-out;
}

.ntmg-widget-action svg {
  width: 18px;
  height: 18px;
  display: block;
}

.ntmg-widget-action:hover {
  color: var(--ntmg-gold);
  background: rgba(245, 242, 236, 0.08);
}

.ntmg-widget-action:focus-visible {
  outline: 2px solid var(--ntmg-gold);
  outline-offset: 2px;
}

.ntmg-widget-close {
  margin-left: 2px;
  background: none;
  border: none;
  color: var(--ntmg-warm-white);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 150ms ease-out;
}

.ntmg-widget-close:hover {
  color: var(--ntmg-gold);
}

.ntmg-widget-close:focus-visible {
  outline: 2px solid var(--ntmg-gold);
  outline-offset: 2px;
}

/* ── Message list ────────────────────────────────────────────────────── */

.ntmg-widget-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ntmg-widget-msg {
  font-family: var(--ntmg-font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  padding: 10px 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: ntmg-widget-fade-in 200ms ease-out;
}

@keyframes ntmg-widget-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ntmg-widget-msg-user {
  align-self: flex-end;
  background: var(--ntmg-navy);
  color: var(--ntmg-warm-white);
  border-radius: 12px 12px 4px 12px;
  max-width: 80%;
}

.ntmg-widget-msg-assistant {
  align-self: flex-start;
  background: var(--ntmg-white);
  color: var(--ntmg-navy);
  border-radius: 12px 12px 12px 4px;
  max-width: 85%;
  box-shadow: 0 1px 3px rgba(12, 30, 53, 0.06);
}

/* Markdown elements rendered inside assistant messages. */
.ntmg-widget-msg p {
  margin: 0 0 8px 0;
}

.ntmg-widget-msg p:last-child {
  margin-bottom: 0;
}

.ntmg-widget-msg ul {
  margin: 6px 0;
  padding-left: 20px;
}

.ntmg-widget-msg li {
  margin: 2px 0;
}

.ntmg-widget-msg a {
  color: var(--ntmg-navy);
  text-decoration: underline;
  text-decoration-color: var(--ntmg-gold);
}

.ntmg-widget-msg-user a {
  color: var(--ntmg-warm-white);
}

.ntmg-widget-msg strong {
  font-weight: 700;
}

/* Any numeric content gets DM Sans bold + tabular figures. Never Cormorant. */
.ntmg-widget-msg .ntmg-widget-num,
.ntmg-widget-num {
  font-family: var(--ntmg-font-body);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Lead-capture confirmation line shown beneath an assistant message. */
.ntmg-widget-lead-note {
  align-self: flex-start;
  max-width: 85%;
  font-family: var(--ntmg-font-body);
  font-size: 13px;
  font-style: italic;
  color: var(--ntmg-slate);
  margin-top: -6px;
  padding: 0 4px;
}

/* ── Auto-linked phone numbers and email addresses in assistant text ──── */

.ntmg-widget-msg a.ntmg-widget-tel,
.ntmg-widget-msg a.ntmg-widget-email {
  color: var(--ntmg-navy);
  text-decoration: underline;
  text-decoration-color: var(--ntmg-gold);
}

.ntmg-widget-msg a.ntmg-widget-tel:hover,
.ntmg-widget-msg a.ntmg-widget-email:hover {
  color: var(--ntmg-gold);
}

/* Phone numbers get tabular figures so the digits line up (typography rule). */
.ntmg-widget-msg a.ntmg-widget-tel {
  font-family: var(--ntmg-font-body);
  font-variant-numeric: tabular-nums;
}

/* ── Inline CTA card (rendered once, after lead_captured) ─────────────── */

.ntmg-widget-cta {
  align-self: flex-start;
  max-width: 85%;
  margin-top: 8px;
  padding: 16px;
  background: var(--ntmg-warm-white);
  border: 1px solid var(--ntmg-gold);
  border-radius: 12px;
  animation: ntmg-widget-fade-in 200ms ease-out;
}

.ntmg-widget-cta-heading {
  font-family: var(--ntmg-font-body);
  font-weight: 500;
  font-size: 14px;
  color: var(--ntmg-navy);
  margin: 0 0 12px 0;
}

.ntmg-widget-cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ntmg-widget-cta-btn {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--ntmg-font-body);
  font-weight: 500;
  font-size: 14px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out;
}

.ntmg-widget-cta-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  flex: 0 0 auto;
}

.ntmg-widget-cta-btn-primary {
  background: var(--ntmg-navy);
  color: var(--ntmg-warm-white);
  border: 1px solid var(--ntmg-navy);
}

.ntmg-widget-cta-btn-primary:hover {
  background: var(--ntmg-deep-navy);
  border-color: var(--ntmg-deep-navy);
}

.ntmg-widget-cta-btn-secondary {
  background: var(--ntmg-warm-white);
  color: var(--ntmg-navy);
  border: 1px solid var(--ntmg-navy);
}

.ntmg-widget-cta-btn-secondary:hover {
  background: var(--ntmg-white);
  color: var(--ntmg-gold);
}

.ntmg-widget-cta-btn:focus-visible {
  outline: 2px solid var(--ntmg-gold);
  outline-offset: 2px;
}

/* Phone number inside the Call button keeps tabular figures. */
.ntmg-widget-cta-btn .ntmg-widget-num {
  font-weight: 500;
}

/* On wider panels, lay the buttons out in a row instead of stacked. */
@media (min-width: 420px) {
  .ntmg-widget-cta-btn {
    flex: 1 1 auto;
  }
}

/* ── Typing indicator ────────────────────────────────────────────────── */

.ntmg-widget-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: var(--ntmg-white);
  border-radius: 12px 12px 12px 4px;
  box-shadow: 0 1px 3px rgba(12, 30, 53, 0.06);
}

.ntmg-widget-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ntmg-gold);
  opacity: 0.4;
  animation: ntmg-widget-typing-pulse 1.2s ease-in-out infinite;
}

.ntmg-widget-typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.ntmg-widget-typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes ntmg-widget-typing-pulse {
  0%,
  60%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ── Input row ───────────────────────────────────────────────────────── */

.ntmg-widget-input-row {
  flex: 0 0 64px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--ntmg-white);
  border-top: 1px solid rgba(12, 30, 53, 0.08);
}

.ntmg-widget-input {
  flex: 1 1 auto;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--ntmg-font-body);
  font-weight: 400;
  font-size: 15px;
  color: var(--ntmg-navy);
  padding: 8px 4px;
}

.ntmg-widget-input::placeholder {
  color: var(--ntmg-slate);
}

.ntmg-widget-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: var(--ntmg-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 150ms ease-out, background 150ms ease-out;
}

.ntmg-widget-send svg {
  width: 18px;
  height: 18px;
  display: block;
}

.ntmg-widget-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.ntmg-widget-send:not(:disabled):hover {
  background: var(--ntmg-deep-navy);
}

.ntmg-widget-send:focus-visible {
  outline: 2px solid var(--ntmg-gold);
  outline-offset: 2px;
}

/* ── Mobile: full-screen panel ───────────────────────────────────────── */

@media (max-width: 480px) {
  .ntmg-widget-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
  }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .ntmg-widget-bubble,
  .ntmg-widget-panel.ntmg-widget-open,
  .ntmg-widget-msg,
  .ntmg-widget-typing span {
    animation: none;
    transition: none;
  }
}
