/**
 * Medigap Pro - Chat Widget Styles
 * "Let's Chat!" floating lead-qualification bot
 *
 * Brand color is applied dynamically by JS (injectBrandColorStyle) so the
 * static rules here use neutral defaults as fallbacks only.
 */

/* ─── Root Container ──────────────────────────────────────────────────────── */

#mmmp-chat-root {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Floating Button ─────────────────────────────────────────────────────── */

#mmmp-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: none; /* shown by JS after appear-delay */
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border: none;
  border-radius: 50px;
  background: #1e40af;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
  white-space: nowrap;
}

#mmmp-chat-btn.mmmp-chat-visible {
  animation: mmmp-pulse 2.8s ease-in-out infinite;
}

#mmmp-chat-btn:hover,
#mmmp-chat-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.32);
  animation: none;
  outline: none;
}

@keyframes mmmp-pulse {
  0%,
  100% {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  }
  50% {
    box-shadow:
      0 4px 22px rgba(0, 0, 0, 0.35),
      0 0 0 8px rgba(255, 255, 255, 0.13);
  }
}

/* ─── Chat Window ─────────────────────────────────────────────────────────── */

#mmmp-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: 350px;
  max-width: calc(100vw - 32px);
  max-height: 540px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
  display: none; /* flex when open */
  flex-direction: column;
  overflow: hidden;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */

#mmmp-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  background: #1e40af;
  color: #fff;
  flex-shrink: 0;
}

#mmmp-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

#mmmp-chat-header-text {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

#mmmp-chat-bot-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

#mmmp-chat-header-text span {
  font-size: 11px;
  opacity: 0.8;
}

#mmmp-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.1s;
  flex-shrink: 0;
}

#mmmp-chat-close:hover,
#mmmp-chat-close:focus-visible {
  opacity: 1;
  outline: none;
}

/* ─── Messages ────────────────────────────────────────────────────────────── */

#mmmp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.mmmp-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.mmmp-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.mmmp-msg-user {
  align-self: flex-end;
  background: #1e40af; /* overridden by JS injectBrandColorStyle */
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ─── Typing Indicator ────────────────────────────────────────────────────── */

.mmmp-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 11px 15px;
  min-height: 0;
}

.mmmp-typing span {
  display: block;
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: mmmp-bounce 1.2s ease-in-out infinite;
}

.mmmp-typing span:nth-child(2) {
  animation-delay: 0.18s;
}
.mmmp-typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes mmmp-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ─── Input Area ──────────────────────────────────────────────────────────── */

#mmmp-chat-input-area {
  padding: 10px 12px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
  max-height: 230px;
  overflow-y: auto;
}

/* ─── Choice Buttons ──────────────────────────────────────────────────────── */

.mmmp-choice-btn {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 9px;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 13px;
  cursor: pointer;
  text-align: left;
  transition:
    background 0.1s,
    border-color 0.1s;
  line-height: 1.35;
}

.mmmp-choice-btn:hover,
.mmmp-choice-btn:focus-visible {
  background: #dbeafe;
  border-color: #93c5fd;
  outline: none;
}

/* ─── Free-Text Input ─────────────────────────────────────────────────────── */

.mmmp-text-input-wrap {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.mmmp-text-input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  color: #1e293b;
  transition: border-color 0.12s;
}

.mmmp-text-input:focus {
  border-color: #1e40af;
}

.mmmp-send-btn {
  padding: 9px 15px;
  background: #1e40af; /* overridden by injectBrandColorStyle */
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s;
}

.mmmp-send-btn:hover,
.mmmp-send-btn:focus-visible {
  filter: brightness(1.1);
  outline: none;
}

/* ─── Contact / Bail Form ─────────────────────────────────────────────────── */

.mmmp-contact-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mmmp-field {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14px;
  color: #1e293b;
  outline: none;
  transition: border-color 0.12s;
}

.mmmp-field:focus {
  border-color: #1e40af;
}

.mmmp-consent-label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 11px;
  color: #64748b;
  cursor: pointer;
  line-height: 1.45;
}

.mmmp-consent-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #1e40af;
}

.mmmp-submit-btn {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.12s;
}

.mmmp-submit-btn:hover,
.mmmp-submit-btn:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.mmmp-submit-btn:disabled {
  background: #86efac;
  cursor: not-allowed;
  filter: none;
}

/* ─── Error Text ──────────────────────────────────────────────────────────── */

.mmmp-field-error {
  color: #dc2626;
  font-size: 12px;
  margin: 0;
  padding: 0;
}

/* ─── Mobile ──────────────────────────────────────────────────────────────── */

/* Prevent iOS auto-zoom on input focus (requires font-size ≥ 16px on inputs) */
@media (max-width: 480px) {
  .mmmp-field,
  .mmmp-text-input {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  #mmmp-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    /* Stay above iOS home bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Use dvh so the window shrinks when the virtual keyboard opens */
    max-height: 86dvh;
    max-height: 86vh; /* fallback for browsers without dvh support */
  }

  #mmmp-chat-btn {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }
}
