/* MedXOptima AI Chat Assistant: all rules scoped to #medx-chat so the WordPress theme is untouched. */
#medx-chat {
  --mx-teal: #0e5f54;
  --mx-teal-deep: #0a4a41;
  --mx-ink: #142b27;
  --mx-muted: #55706a;
  --mx-mist: #eef4f2;
  --mx-line: #d4e2de;
  --mx-paper: #ffffff;
  --mx-alert: #a3332b;
  --mx-radius: 14px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--mx-ink);
  -webkit-font-smoothing: antialiased;
}
#medx-chat *, #medx-chat *::before, #medx-chat *::after { box-sizing: border-box; }
#medx-chat button, #medx-chat input, #medx-chat textarea, #medx-chat select {
  font: inherit; color: inherit; margin: 0; letter-spacing: normal; text-transform: none;
}
#medx-chat [hidden] { display: none !important; }
#medx-chat :focus-visible { outline: 2px solid var(--mx-teal); outline-offset: 2px; }

/* Launcher */
#medx-chat .mx-launcher {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px 12px 14px;
  border: 0; border-radius: 999px;
  background: var(--mx-teal); color: #fff;
  font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 20px rgba(14, 95, 84, 0.35);
  transition: background-color .15s ease, transform .15s ease;
}
#medx-chat .mx-launcher:hover { background: var(--mx-teal-deep); }
#medx-chat .mx-launcher:active { transform: scale(.97); }
#medx-chat .mx-launcher svg { width: 22px; height: 22px; flex: none; }
#medx-chat.mx-open .mx-launcher { display: none; }

/* Panel */
#medx-chat .mx-panel {
  position: absolute; right: 0; bottom: 0;
  width: 380px; height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--mx-paper);
  border: 1px solid var(--mx-line);
  border-radius: var(--mx-radius);
  box-shadow: 0 18px 50px rgba(20, 43, 39, 0.22);
  overflow: hidden;
  transform-origin: bottom right;
  animation: mx-open .18s ease-out;
}
@keyframes mx-open { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

#medx-chat .mx-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--mx-teal); color: #fff;
}
#medx-chat .mx-avatar {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; background: rgba(255,255,255,.14);
}
#medx-chat .mx-avatar svg { width: 20px; height: 20px; }
#medx-chat .mx-title { flex: 1; min-width: 0; }
#medx-chat .mx-title strong { display: block; font-size: 16px; font-weight: 650; line-height: 1.25; }
#medx-chat .mx-title span { display: block; font-size: 13px; opacity: .85; }
#medx-chat .mx-icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: #fff; cursor: pointer;
}
#medx-chat .mx-icon-btn:hover { background: rgba(255,255,255,.14); }
#medx-chat .mx-icon-btn svg { width: 20px; height: 20px; }

#medx-chat .mx-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--mx-mist); }

/* Forms (pre-chat and expert) */
#medx-chat .mx-form { flex: 1; overflow-y: auto; padding: 20px 18px; background: var(--mx-paper); }
#medx-chat .mx-form h2 { margin: 0 0 4px; font-size: 18px; font-weight: 650; line-height: 1.3; color: var(--mx-ink); }
#medx-chat .mx-form p.mx-lede { margin: 0 0 16px; color: var(--mx-muted); font-size: 14px; }
#medx-chat .mx-field { margin-bottom: 12px; }
#medx-chat .mx-field label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
#medx-chat .mx-field label small { font-weight: 400; color: var(--mx-muted); }
#medx-chat .mx-field input,
#medx-chat .mx-field select,
#medx-chat .mx-field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--mx-line); border-radius: 8px;
  background: #fff; font-size: 15px;
}
#medx-chat .mx-field textarea { min-height: 76px; resize: vertical; }
#medx-chat .mx-field input:focus,
#medx-chat .mx-field select:focus,
#medx-chat .mx-field textarea:focus { border-color: var(--mx-teal); outline: none; box-shadow: 0 0 0 3px rgba(14,95,84,.15); }
#medx-chat .mx-check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 13px; color: var(--mx-muted); }
#medx-chat .mx-check input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--mx-teal); }
#medx-chat .mx-check a { color: var(--mx-teal); }
#medx-chat .mx-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
#medx-chat .mx-error { margin: 8px 0 0; color: var(--mx-alert); font-size: 13px; }
#medx-chat .mx-note {
  margin: 14px 0 0; padding: 10px 12px;
  border-left: 3px solid var(--mx-teal);
  background: var(--mx-mist); font-size: 12.5px; color: var(--mx-muted);
}
#medx-chat .mx-primary {
  width: 100%; padding: 12px 16px;
  border: 0; border-radius: 8px;
  background: var(--mx-teal); color: #fff; font-weight: 600; cursor: pointer;
}
#medx-chat .mx-primary:hover { background: var(--mx-teal-deep); }
#medx-chat .mx-primary[disabled] { opacity: .6; cursor: progress; }
#medx-chat .mx-secondary {
  width: 100%; margin-top: 8px; padding: 10px 16px;
  border: 1px solid var(--mx-line); border-radius: 8px;
  background: #fff; color: var(--mx-ink); cursor: pointer;
}

/* Expert sheet slides over the chat */
#medx-chat .mx-sheet { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--mx-paper); z-index: 2; }

/* Conversation */
#medx-chat .mx-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
#medx-chat .mx-msg { max-width: 86%; padding: 10px 13px; border-radius: 12px; font-size: 14.5px; overflow-wrap: anywhere; }
#medx-chat .mx-msg p { margin: 0 0 8px; }
#medx-chat .mx-msg p:last-child, #medx-chat .mx-msg ul:last-child { margin-bottom: 0; }
#medx-chat .mx-msg ul { margin: 0 0 8px; padding-left: 18px; }
#medx-chat .mx-msg li { margin: 2px 0; }
#medx-chat .mx-bot { align-self: flex-start; background: #fff; border: 1px solid var(--mx-line); border-bottom-left-radius: 4px; }
#medx-chat .mx-user { align-self: flex-end; background: var(--mx-teal); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
#medx-chat .mx-err { align-self: center; max-width: 92%; background: #fbeceb; color: var(--mx-alert); font-size: 13px; text-align: center; }
#medx-chat .mx-cta {
  display: inline-block; margin-top: 10px; padding: 8px 14px;
  border: 1px solid var(--mx-teal); border-radius: 999px;
  background: #fff; color: var(--mx-teal); font-weight: 600; font-size: 13.5px; cursor: pointer;
}
#medx-chat .mx-cta:hover { background: var(--mx-teal); color: #fff; }

#medx-chat .mx-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 6px; }
#medx-chat .mx-chip {
  padding: 7px 12px; border: 1px solid var(--mx-line); border-radius: 999px;
  background: #fff; font-size: 13px; cursor: pointer;
}
#medx-chat .mx-chip:hover { border-color: var(--mx-teal); color: var(--mx-teal); }

#medx-chat .mx-typing { align-self: flex-start; display: flex; gap: 4px; padding: 13px 14px; background: #fff; border: 1px solid var(--mx-line); border-radius: 12px; }
#medx-chat .mx-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--mx-muted); animation: mx-dot 1.2s infinite ease-in-out; }
#medx-chat .mx-typing i:nth-child(2) { animation-delay: .15s; }
#medx-chat .mx-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mx-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

#medx-chat .mx-compose { border-top: 1px solid var(--mx-line); background: #fff; padding: 10px 12px 8px; }
#medx-chat .mx-compose-row { display: flex; gap: 8px; align-items: flex-end; }
#medx-chat .mx-compose textarea {
  flex: 1; min-height: 42px; max-height: 120px; padding: 10px 12px;
  border: 1px solid var(--mx-line); border-radius: 10px; resize: none; font-size: 15px; background: #fff;
}
#medx-chat .mx-compose textarea:focus { border-color: var(--mx-teal); outline: none; }
#medx-chat .mx-send {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: var(--mx-teal); color: #fff; cursor: pointer;
}
#medx-chat .mx-send[disabled] { opacity: .5; cursor: not-allowed; }
#medx-chat .mx-send svg { width: 18px; height: 18px; }
#medx-chat .mx-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--mx-muted); }
#medx-chat .mx-link { border: 0; background: none; padding: 0; color: var(--mx-teal); font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; }

/* Phones: full screen */
@media (max-width: 520px) {
  #medx-chat { right: 14px; bottom: 14px; }
  #medx-chat.mx-open { inset: 0; right: 0; bottom: 0; }
  #medx-chat .mx-panel {
    position: fixed; inset: 0; width: 100%; height: 100%;
    border: 0; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #medx-chat .mx-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  #medx-chat .mx-field input, #medx-chat .mx-compose textarea { font-size: 16px; } /* stops iOS zoom */
}

@media (prefers-reduced-motion: reduce) {
  #medx-chat .mx-panel, #medx-chat .mx-typing i { animation: none; }
  #medx-chat .mx-launcher { transition: none; }
}
