/* ── MakeMyRates AI Copilot: Aish ✦ ─────────────────────────────────────────
   Styled to seamlessly match the MakeMyRates Forest Green & Warm Canvas Theme
   ========================================================================== */
:root {
  /* Aligned with styles.css Design Tokens */
  --aish-green:        #176B4D; /* Primary forest green */
  --aish-green-hover:  #11523a; /* Darker green on hover */
  --aish-green-light:  #E7F2EC; /* Soft sage/mint tint */
  --aish-green-subtle: #F2F8F5; /* Very subtle light tint */
  --aish-green-border: #C2DED0; /* Subtle green border */
  --aish-bg:           #ffffff; /* Crisp white surface */
  --aish-canvas:       #F7F8F5; /* Warm off-white canvas */
  --aish-text-dark:    #1F2925; /* Deep charcoal headings & primary text */
  --aish-text-body:    #3D4A44; /* Readable charcoal body */
  --aish-text-muted:   #66736D; /* Muted slate for secondary labels */
  --aish-border-light: #DCE4DF; /* Crisp light border */
  --aish-border-med:   #C8D2CB; /* Input borders */
  --aish-shadow:       0 14px 34px -4px rgba(23, 107, 77, 0.22), 0 6px 14px -3px rgba(15, 23, 42, 0.08);
  --aish-radius:       18px;
}

.ca-leaf {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.15em;
  margin-left: 0.2em;
  background-image: url("../images/maple-leaf.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

/* ── 1. Floating Launcher Pill ───────────────────────────────────────────── */
.mmr-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 48px;
  padding: 0 16px 0 8px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--aish-green) 0%, var(--aish-green-hover) 100%);
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 8px 24px rgba(23, 107, 77, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9999;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.mmr-chat-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(23, 107, 77, 0.45);
  background: var(--aish-green-hover);
}

/* Highly visible assistant icon badge */
.mmr-launcher-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--aish-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mmr-launcher-icon-badge svg {
  width: 18px;
  height: 18px;
  fill: var(--aish-green);
}

.mmr-launcher-label {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.mmr-launcher-beacon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #4ade80;
  border: 1.5px solid var(--aish-green);
  animation: aishPulseDot 2s infinite;
}

@keyframes aishPulseDot {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.75); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* ── 2. Compact Teaser Pill ("The Nudge") ────────────────────────────────── */
.mmr-aish-teaser {
  position: fixed;
  bottom: 80px;
  right: 24px;
  height: 40px;
  padding: 0 12px 0 10px;
  background: #ffffff;
  border: 1.5px solid var(--aish-green-border);
  border-radius: 9999px;
  box-shadow: 0 8px 24px -4px rgba(23, 107, 77, 0.2);
  z-index: 9998;
  display: none;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  animation: aishFadeSlideUp 0.25s ease-out;
  white-space: nowrap;
}

.mmr-aish-teaser.visible {
  display: flex;
}

@keyframes aishFadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mmr-teaser-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--aish-green-light);
  color: var(--aish-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mmr-teaser-badge svg {
  width: 13px;
  height: 13px;
  fill: var(--aish-green);
}

.mmr-teaser-text {
  font-size: 0.82rem;
  color: var(--aish-text-body);
}

.mmr-teaser-text strong {
  color: var(--aish-green);
  font-weight: 700;
}

.mmr-teaser-close {
  background: none;
  border: none;
  color: var(--aish-text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.15s;
}

.mmr-teaser-close:hover {
  color: var(--aish-text-dark);
}

/* ── 3. Chat Window (Modal) ─────────────────────────────────────────────── */
.mmr-chat-modal {
  position: fixed;
  bottom: 82px;
  right: 24px;
  width: 385px;
  max-width: calc(100vw - 28px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background-color: var(--aish-bg);
  border-radius: var(--aish-radius);
  box-shadow: var(--aish-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  border: 1px solid var(--aish-border-light);
  animation: aishModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mmr-chat-modal.active {
  display: flex;
}

@keyframes aishModalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.mmr-chat-header {
  background: linear-gradient(135deg, var(--aish-green) 0%, var(--aish-green-hover) 100%);
  color: #ffffff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

.mmr-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mmr-header-avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--aish-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mmr-header-avatar-badge svg {
  width: 19px;
  height: 19px;
  fill: var(--aish-green);
}

.mmr-header-info {
  display: flex;
  flex-direction: column;
}

.mmr-header-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mmr-header-name strong {
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
}

.mmr-verified-pill {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}

.mmr-chat-status {
  font-size: 0.70rem;
  color: var(--aish-green-light);
  display: flex;
  align-items: center;
  gap: 5px;
}

.mmr-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #4ade80;
}

.mmr-chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mmr-chat-icon-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.mmr-chat-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* ── 4. Chat Messages Stream ─────────────────────────────────────────────── */
.mmr-chat-messages {
  flex: 1;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--aish-canvas);
  scroll-behavior: smooth;
}

.mmr-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.mmr-chat-messages::-webkit-scrollbar-thumb {
  background-color: var(--aish-border-med);
  border-radius: 4px;
}

/* ── Minimal Clean Welcome State ─────────────────────────────────────────── */
.mmr-clean-hero {
  text-align: center;
  padding: 12px 4px 8px;
  animation: aishFadeSlideUp 0.3s ease-out;
}

.mmr-clean-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--aish-green);
  background: var(--aish-green-light);
  border: 1px solid var(--aish-green-border);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
}

.mmr-clean-hero-badge svg {
  width: 13px;
  height: 13px;
  fill: var(--aish-green);
}

.mmr-clean-hero h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--aish-text-dark);
  letter-spacing: -0.01em;
}

.mmr-clean-hero p {
  margin: 4px 0 14px 0;
  font-size: 0.82rem;
  color: var(--aish-text-muted);
}

/* Visual Action Cards Grid (2x2) */
.mmr-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
}

.mmr-action-card {
  background: #ffffff;
  border: 1px solid var(--aish-border-light);
  border-radius: 12px;
  padding: 10px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.18s ease;
}

.mmr-action-card:hover {
  border-color: var(--aish-green);
  background: var(--aish-green-subtle);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(23, 107, 77, 0.10);
}

.mmr-action-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mmr-action-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.mmr-action-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--aish-text-dark);
}

.mmr-action-sub {
  font-size: 0.70rem;
  color: var(--aish-green);
  font-weight: 700;
}

/* ── Message Rows ────────────────────────────────────────────────────────── */
.mmr-msg {
  display: flex;
  gap: 8px;
  max-width: 90%;
  animation: aishBubbleIn 0.2s ease-out;
}

@keyframes aishBubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mmr-msg.assistant {
  align-self: flex-start;
}

.mmr-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Assistant Avatar in message stream: High-contrast & visible */
.mmr-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--aish-green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 2px 5px rgba(23, 107, 77, 0.25);
}

.mmr-msg-avatar svg {
  width: 15px;
  height: 15px;
  fill: #ffffff;
}

.mmr-msg-content {
  display: flex;
  flex-direction: column;
}

.mmr-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.52;
  word-break: break-word;
}

.mmr-msg.assistant .mmr-msg-bubble {
  background-color: #ffffff;
  color: var(--aish-text-dark);
  border: 1px solid var(--aish-border-light);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.mmr-msg.assistant .mmr-msg-bubble strong {
  color: var(--aish-text-dark);
}

.mmr-msg.user .mmr-msg-bubble {
  background-color: var(--aish-green);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.mmr-msg-time {
  font-size: 0.66rem;
  color: var(--aish-text-muted);
  margin-top: 3px;
  padding: 0 2px;
}

.mmr-msg.user .mmr-msg-time {
  align-self: flex-end;
}

/* Lead Captured Confirmation Ticket */
.mmr-lead-card {
  background: var(--aish-green-light);
  border: 1px solid var(--aish-green-border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--aish-green);
  animation: aishBubbleIn 0.2s ease-out;
}

.mmr-lead-card-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--aish-green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.80rem;
  font-weight: 800;
  flex-shrink: 0;
}

.mmr-lead-card-text {
  font-size: 0.78rem;
  line-height: 1.35;
}

.mmr-lead-card-text strong {
  display: block;
  font-size: 0.82rem;
  color: var(--aish-green);
}

/* Typing Indicator */
.mmr-typing-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  background-color: #ffffff;
  border: 1px solid var(--aish-border-light);
  padding: 7px 12px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  margin-left: 36px;
}

.mmr-typing-indicator.active {
  display: flex;
}

.mmr-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--aish-green);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.mmr-typing-dot:nth-child(1) { animation-delay: 0s; }
.mmr-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.mmr-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* ── 5. Input Form Area ─────────────────────────────────────────────────── */
.mmr-chat-footer {
  padding: 10px 12px;
  background-color: #ffffff;
  border-top: 1px solid var(--aish-border-light);
}

.mmr-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mmr-chat-input {
  flex: 1;
  border: 1.5px solid var(--aish-border-med);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 0.86rem;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
  background-color: var(--aish-canvas);
}

.mmr-chat-input:focus {
  background-color: #ffffff;
  border-color: var(--aish-green);
  box-shadow: 0 0 0 2px rgba(23, 107, 77, 0.15);
}

.mmr-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--aish-green);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.mmr-chat-send-btn:hover {
  background: var(--aish-green-hover);
  transform: scale(1.05);
}

.mmr-chat-send-btn:disabled {
  background: var(--aish-border-med);
  cursor: not-allowed;
  transform: none;
}

.mmr-chat-disclaimer {
  font-size: 0.64rem;
  color: var(--aish-text-muted);
  text-align: center;
  margin-top: 6px;
}

/* ── 6. Mobile Viewports ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .mmr-chat-modal {
    right: 12px;
    bottom: 74px;
    width: calc(100vw - 24px);
    height: 500px;
  }

  .mmr-action-grid {
    grid-template-columns: 1fr;
  }
}

/* ── 7. Compact launcher that opens to "Ask Aish" at question moments ───── */
.mmr-chat-launcher {
  min-width: 48px;
  padding: 0 6px;
  gap: 0;
}

.mmr-chat-launcher .mmr-launcher-label {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 0;
  opacity: 0;
  margin: 0;
  transition: max-width 0.35s ease, opacity 0.25s ease, margin 0.35s ease;
}

.mmr-chat-launcher.mmr-peek .mmr-launcher-label {
  max-width: 90px;
  opacity: 1;
  margin: 0 8px;
}

@media (hover: hover) {
  .mmr-chat-launcher:hover .mmr-launcher-label {
    max-width: 90px;
    opacity: 1;
    margin: 0 8px;
  }
}

.mmr-chat-launcher .mmr-launcher-beacon {
  position: absolute;
  top: 3px;
  right: 3px;
}

/* Hide launcher and greeting while the mobile menu is open */
body:has(.drawer.open) .mmr-chat-launcher,
body:has(.drawer.open) .mmr-aish-teaser {
  display: none;
}

@media (max-width: 480px) {
  .mmr-chat-launcher {
    right: 14px;
    bottom: 14px;
  }

  .mmr-aish-teaser {
    right: 14px;
    bottom: 72px;
  }

  /* Sit above the sticky Call / Get a Quote bar where a page has one */
  body:has(.sticky-bar) .mmr-chat-launcher {
    bottom: 78px;
  }

  body:has(.sticky-bar) .mmr-aish-teaser {
    bottom: 136px;
  }
}

/* Quote page on phones: launcher waits until the visitor scrolls past the product buttons */
body.mmr-quote-top .mmr-chat-launcher,
body.mmr-quote-top .mmr-aish-teaser {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}
