/* ========================================================
   BION MED CONCIERGE CHAT WIDGET
   Design System Tokens matched to styles.css
   Includes Lead Capture, Timezone Detection & Dual Conversion (Call + Email)
   ======================================================== */

.bm-concierge-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 70;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: Inter, Avenir Next, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Floating Launcher Button */
.bm-concierge-launcher {
  width: 58px;
  height: 58px;
  pointer-events: auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy, #1b2b4b), #0d1a33);
  border: 1.5px solid var(--sky, #4daff7);
  box-shadow: 0 10px 25px -4px rgba(27, 43, 75, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  position: relative;
  outline: none;
}
.bm-concierge-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 30px -4px rgba(77, 175, 247, 0.45);
}
.bm-concierge-launcher svg {
  width: 26px;
  height: 26px;
  fill: var(--sky, #4daff7);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.bm-concierge-launcher.is-open svg.icon-chat { display: none; }
.bm-concierge-launcher.is-open svg.icon-close { display: block; fill: #ffffff; }
.bm-concierge-launcher svg.icon-close { display: none; }

.bm-concierge-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: var(--green, #3dbe7a);
  border: 2px solid var(--navy, #1b2b4b);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(61, 190, 122, 0.3);
}

/* Chat Window */
.bm-concierge-window {
  width: 440px;
  height: 640px;
  max-height: calc(100vh - 100px);
  max-width: calc(100vw - 32px);
  background: var(--paper, #f7faff);
  border: 1px solid var(--line, rgba(27, 43, 75, 0.14));
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(27, 43, 75, 0.22);
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: all 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
.bm-concierge-window.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.bm-concierge-header {
  background: linear-gradient(135deg, var(--navy, #1b2b4b) 0%, #122038 100%);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.bm-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bm-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(77, 175, 247, 0.18);
  border: 1.5px solid var(--sky, #4daff7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--sky, #4daff7);
  letter-spacing: 0.5px;
}
.bm-header-title h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.2px;
}
.bm-header-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.bm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green, #3dbe7a);
  box-shadow: 0 0 6px var(--green, #3dbe7a);
}
.bm-header-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.bm-header-close:hover {
  color: #ffffff;
}

/* Messages Scroll Area */
.bm-concierge-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7faff;
}

.bm-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: bmFadeIn 0.22s ease-out;
}
.bm-msg.bot {
  align-self: flex-start;
}
.bm-msg.user {
  align-self: flex-end;
}
.bm-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.48;
  position: relative;
  word-wrap: break-word;
}
.bm-msg.bot .bm-bubble {
  background: #ffffff;
  color: var(--ink, #1f2d42);
  border: 1px solid var(--line, rgba(27, 43, 75, 0.12));
  border-bottom-left-radius: 4px;
  box-shadow: 0 3px 10px rgba(27, 43, 75, 0.04);
}
.bm-msg.user .bm-bubble {
  background: var(--navy, #1b2b4b);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.bm-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--line, rgba(27, 43, 75, 0.12));
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  margin-left: 16px;
  margin-bottom: 8px;
  gap: 5px;
  align-items: center;
  width: fit-content;
}
.bm-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sky, #4daff7);
  animation: bmBounce 1.2s infinite ease-in-out;
}
.bm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.bm-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Interactive Lead Form Inside Chat */
.bm-lead-form {
  margin-top: 6px;
  padding: 13px 15px;
  background: #ffffff;
  border: 1.5px solid rgba(77, 175, 247, 0.35);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 6px 16px rgba(27, 43, 75, 0.05);
}
.bm-lead-form-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy, #1b2b4b);
  display: flex;
  align-items: center;
  gap: 6px;
}
.bm-lead-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  font-size: 12.5px;
  border: 1px solid var(--line, rgba(27, 43, 75, 0.18));
  border-radius: 7px;
  background: #fbfdff;
  color: var(--ink, #1f2d42);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.bm-lead-input:focus {
  border-color: var(--sky, #4daff7);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(77, 175, 247, 0.18);
}
.bm-lead-submit {
  padding: 8px 12px;
  background: var(--navy, #1b2b4b);
  color: #ffffff;
  border: none;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.bm-lead-submit:hover {
  background: #253961;
}

/* Dual Conversion Action Card (Calendly + Direct Email) */
.bm-action-card {
  margin-top: 8px;
  padding: 13px 15px;
  background: #ffffff;
  border: 1.5px solid rgba(77, 175, 247, 0.35);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(27, 43, 75, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bm-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}
.bm-card-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy, #1b2b4b);
}
.bm-tz-tag {
  font-size: 11px;
  color: var(--navy, #1b2b4b);
  background: rgba(77, 175, 247, 0.14);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  border: 1px solid rgba(77, 175, 247, 0.28);
}
.bm-card-desc {
  font-size: 12px;
  color: var(--muted, #5b6778);
  line-height: 1.42;
}
.bm-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.bm-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: center;
  box-sizing: border-box;
}
.bm-cta-btn.primary {
  background: var(--navy, #1b2b4b);
  color: #ffffff;
  border: 1px solid transparent;
}
.bm-cta-btn.primary:hover {
  background: #253961;
  transform: translateY(-1px);
}
.bm-cta-btn.secondary {
  background: rgba(77, 175, 247, 0.09);
  color: var(--navy, #1b2b4b);
  border: 1px solid rgba(77, 175, 247, 0.35);
}
.bm-cta-btn.secondary:hover {
  background: rgba(77, 175, 247, 0.18);
  border-color: var(--sky, #4daff7);
  transform: translateY(-1px);
}

/* Quick Chips Area */
.bm-chips-area {
  padding: 8px 14px 10px;
  background: #f7faff;
  border-top: 1px solid var(--line, rgba(27, 43, 75, 0.08));
}
.bm-chips-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #5b6778);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.bm-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 104px;
  overflow-y: auto;
}
.bm-chip {
  background: #ffffff;
  color: var(--navy, #1b2b4b);
  border: 1px solid var(--line, rgba(27, 43, 75, 0.18));
  padding: 6px 11px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
  transition: all 0.15s ease;
  font-family: inherit;
}
.bm-chip:hover {
  background: var(--sky, #4daff7);
  color: #ffffff;
  border-color: var(--sky, #4daff7);
  transform: translateY(-1px);
}

/* Footer / Input Area */
.bm-concierge-footer {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid var(--line, rgba(27, 43, 75, 0.12));
  display: flex;
  gap: 8px;
  align-items: center;
}
.bm-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 13.5px;
  border: 1px solid var(--line, rgba(27, 43, 75, 0.18));
  border-radius: 20px;
  outline: none;
  background: #f7faff;
  color: var(--ink, #1f2d42);
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.bm-input:focus {
  border-color: var(--sky, #4daff7);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(77, 175, 247, 0.15);
}
.bm-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--navy, #1b2b4b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  outline: none;
  flex-shrink: 0;
}
.bm-send-btn:hover {
  background: var(--sky, #4daff7);
}
.bm-send-btn:disabled {
  cursor: wait;
  opacity: 0.55;
}
.bm-privacy-note {
  margin: 0;
  padding: 2px 14px 10px;
  background: #ffffff;
  color: var(--ink, #1f2d42);
  font-size: 11px;
  line-height: 1.4;
}
.bm-privacy-note a { color: var(--navy, #1b2b4b); text-decoration: underline; }
.bm-lead-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0 14px 10px;
  background: #ffffff;
  color: var(--ink, #1f2d42);
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}
.bm-lead-consent input { flex: none; margin: 2px 0 0; }
.bm-send-btn svg {
  width: 17px;
  height: 17px;
  fill: #ffffff;
}

@keyframes bmFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bmBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .bm-concierge-container {
    bottom: 12px;
    right: 12px;
  }
  .bm-concierge-window {
    width: calc(100vw - 24px);
    height: min(620px, calc(100dvh - 104px));
    border-radius: 14px;
    margin-bottom: 10px;
  }
}
