#mediserv-chatbot {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

#mediserv-chatbot * { box-sizing: border-box; }

#mediserv-chat-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px 18px 12px 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  background: linear-gradient(135deg, var(--ms-secondary), var(--ms-primary));
  box-shadow: 0 18px 45px rgba(0, 103, 177, 0.32);
  cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease;
}

#mediserv-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 55px rgba(0, 103, 177, 0.42);
}

#mediserv-chat-toggle img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  padding: 6px;
  border-radius: 50%;
  background: #fff;
}

#mediserv-chat-window {
  display: none;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 110px);
  overflow: hidden;
  border-radius: 28px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .10);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
}

#mediserv-chat-window.ms-open { display: block; }

.ms-chat-header {
  min-height: 92px;
  padding: 18px;
  background: linear-gradient(135deg, var(--ms-secondary), var(--ms-primary) 72%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ms-chat-brand { display: flex; align-items: center; gap: 13px; }

.ms-chat-logo-wrap {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.65), 0 10px 25px rgba(0,0,0,.12);
}

.ms-chat-logo-wrap img, .ms-avatar {
  object-fit: contain;
}

.ms-chat-logo-wrap img { width: 42px; height: 42px; }

.ms-chat-header h3 {
  margin: 0;
  color: #fff;
  font-size: 19px;
  line-height: 1.15;
  font-weight: 850;
}

.ms-chat-header p { margin: 6px 0 0; font-size: 13px; opacity: .92; }
.ms-status-dot { display: inline-block; width: 9px; height: 9px; background: #19e28a; border-radius: 99px; margin-right: 6px; }

#mediserv-chat-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.ms-chat-body {
  height: calc(100% - 168px);
  padding: 18px 17px;
  overflow-y: auto;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.ms-message-row { display: flex; gap: 10px; margin-bottom: 14px; }
.ms-user-row { justify-content: flex-end; }
.ms-avatar { width: 34px; height: 34px; padding: 4px; border-radius: 50%; background: #fff; box-shadow: 0 7px 18px rgba(15,23,42,.10); flex: 0 0 auto; }

.ms-message {
  max-width: 84%;
  padding: 13px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.48;
}

.ms-message p { margin: 0 0 6px; }
.ms-message small { display: block; color: #64748b; font-size: 12px; line-height: 1.4; }
.ms-bot-message { background: #fff; color: #172033; border: 1px solid rgba(15,23,42,.08); border-bottom-left-radius: 7px; box-shadow: 0 8px 20px rgba(15,23,42,.06); }
.ms-user-message { background: #eaf4ff; color: #0f172a; border-bottom-right-radius: 7px; }

.ms-quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 14px 0 18px 44px; }
.ms-quick-actions button {
  padding: 10px 12px;
  border: 1px solid rgba(0,103,177,.22);
  border-radius: 999px;
  background: #fff;
  color: var(--ms-primary);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
.ms-quick-actions button:hover { background: #f0f7ff; border-color: var(--ms-primary); transform: translateY(-1px); }

.ms-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.ms-typing span { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; display: block; animation: msBlink 1.2s infinite ease-in-out; }
.ms-typing span:nth-child(2) { animation-delay: .16s; }
.ms-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes msBlink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ms-chat-input-area {
  height: 66px;
  padding: 11px 13px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border-top: 1px solid rgba(15,23,42,.08);
}
#mediserv-chat-input {
  flex: 1;
  height: 44px;
  border: 1px solid rgba(15,23,42,.14);
  border-radius: 999px;
  padding: 0 15px;
  outline: none;
  font-size: 14px;
  background: #fff;
}
#mediserv-chat-input:focus { border-color: var(--ms-primary); box-shadow: 0 0 0 4px rgba(0,103,177,.10); }
#mediserv-chat-send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--ms-primary);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.ms-secure-note { height: 28px; text-align: center; color: #64748b; font-size: 12px; background: #fff; }

.ms-lead-card {
  margin: 10px 0 15px 44px;
  padding: 14px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(15,23,42,.06);
}
.ms-lead-card label { display: block; margin-bottom: 8px; font-size: 12px; color: #475569; font-weight: 750; }
.ms-lead-card input, .ms-lead-card textarea {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.13);
  font: inherit;
}
.ms-lead-card button { width: 100%; padding: 11px 14px; border: 0; border-radius: 999px; background: var(--ms-primary); color: #fff; font-weight: 800; cursor: pointer; }

@media (max-width: 520px) {
  #mediserv-chat-toggle span { display: none; }
  .ms-message { max-width: 88%; }
}

/* Rev 1.1 — reduced typography size + stronger WordPress theme isolation */
#mediserv-chatbot,
#mediserv-chatbot * {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}

#mediserv-chat-window {
  font-size: 14px !important;
}

.ms-chat-header {
  min-height: 82px !important;
  padding: 14px 16px !important;
}

.ms-chat-logo-wrap {
  width: 48px !important;
  height: 48px !important;
  border-radius: 16px !important;
}

.ms-chat-logo-wrap img {
  width: 36px !important;
  height: 36px !important;
}

.ms-chat-header h3 {
  font-size: 17px !important;
  line-height: 1.15 !important;
  font-weight: 800 !important;
}

.ms-chat-header p {
  font-size: 12px !important;
  line-height: 1.2 !important;
}

.ms-message {
  font-size: 13.5px !important;
  line-height: 1.42 !important;
  padding: 11px 13px !important;
}

.ms-message p,
.ms-message div,
.ms-message span {
  font-size: inherit !important;
  line-height: inherit !important;
}

.ms-message small {
  font-size: 11.5px !important;
  line-height: 1.35 !important;
}

.ms-quick-actions button {
  font-size: 12.5px !important;
  line-height: 1.2 !important;
  padding: 9px 10px !important;
  font-weight: 750 !important;
}

#mediserv-chat-input {
  font-size: 13.5px !important;
}

.ms-secure-note {
  font-size: 11.5px !important;
}

@media (max-width: 520px) {
  #mediserv-chatbot {
    right: 0 !important;
    bottom: 0 !important;
  }

  #mediserv-chat-window {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 82vh !important;
    max-height: 82vh !important;
    border-radius: 22px 22px 0 0 !important;
  }

  .ms-chat-header {
    min-height: 76px !important;
    padding: 13px 14px !important;
  }

  .ms-chat-brand {
    gap: 10px !important;
  }

  .ms-chat-logo-wrap {
    width: 46px !important;
    height: 46px !important;
    border-radius: 15px !important;
  }

  .ms-chat-logo-wrap img {
    width: 34px !important;
    height: 34px !important;
  }

  .ms-chat-header h3 {
    font-size: 16px !important;
    line-height: 1.12 !important;
  }

  .ms-chat-header p {
    font-size: 11.5px !important;
    margin-top: 4px !important;
  }

  #mediserv-chat-close {
    width: 34px !important;
    height: 34px !important;
    font-size: 22px !important;
  }

  .ms-chat-body {
    padding: 14px 12px !important;
    height: calc(100% - 160px) !important;
  }

  .ms-avatar {
    width: 30px !important;
    height: 30px !important;
    padding: 4px !important;
  }

  .ms-message-row {
    gap: 8px !important;
    margin-bottom: 11px !important;
  }

  .ms-message {
    max-width: 82% !important;
    font-size: 13px !important;
    line-height: 1.38 !important;
    padding: 10px 12px !important;
    border-radius: 16px !important;
  }

  .ms-quick-actions {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin: 12px 0 14px 38px !important;
  }

  .ms-quick-actions button {
    font-size: 12px !important;
    padding: 8px 9px !important;
    min-height: 40px !important;
  }

  .ms-chat-input-area {
    height: 62px !important;
    padding: 9px 11px !important;
  }

  #mediserv-chat-input,
  #mediserv-chat-send {
    height: 42px !important;
  }

  #mediserv-chat-send {
    width: 42px !important;
  }
}


/* Rev 1.3 — desktop glow launcher + mobile centered launcher */
#mediserv-chat-toggle {
  position: relative;
  overflow: visible;
}

#mediserv-chat-toggle::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(218,31,54,.45), rgba(0,103,177,.45));
  filter: blur(14px);
  opacity: 0;
  z-index: -1;
  transition: opacity .25s ease, transform .25s ease;
}

#mediserv-chat-toggle::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,.24), rgba(255,255,255,.06));
  z-index: -1;
  pointer-events: none;
}

#mediserv-chat-toggle img {
  box-shadow: 0 0 0 0 rgba(255,255,255,.30), 0 0 0 0 rgba(0,103,177,.18);
  transition: box-shadow .25s ease, transform .25s ease;
}

@media (min-width: 521px) {
  #mediserv-chat-toggle {
    box-shadow: 0 18px 45px rgba(0, 103, 177, 0.32), 0 0 0 1px rgba(255,255,255,.10) inset;
    animation: msLauncherGlow 2.8s ease-in-out infinite;
  }

  #mediserv-chat-toggle::before {
    opacity: .88;
    animation: msLauncherAura 2.8s ease-in-out infinite;
  }

  #mediserv-chat-toggle:hover::before {
    opacity: 1;
    transform: scale(1.02);
  }

  #mediserv-chat-toggle:hover img {
    box-shadow: 0 0 0 6px rgba(255,255,255,.16), 0 0 26px rgba(255,255,255,.40), 0 0 36px rgba(0,103,177,.30);
    transform: scale(1.04);
  }
}

@keyframes msLauncherGlow {
  0%, 100% {
    box-shadow: 0 18px 45px rgba(0,103,177,.30), 0 0 0 0 rgba(0,103,177,.12);
  }
  50% {
    box-shadow: 0 22px 54px rgba(0,103,177,.40), 0 0 0 8px rgba(0,103,177,.08);
  }
}

@keyframes msLauncherAura {
  0%, 100% { transform: scale(0.98); filter: blur(14px); }
  50% { transform: scale(1.03); filter: blur(16px); }
}

@media (max-width: 520px) {
  #mediserv-chatbot {
    right: 12px !important;
    top: 72% !important;
    bottom: auto !important;
    transform: translateY(-50%);
  }

  #mediserv-chat-window {
    position: fixed;
    right: 12px;
    top: 54%;
    bottom: auto;
    transform: translateY(-50%);
    width: min(calc(100vw - 24px), 420px);
    height: min(78vh, 680px);
    max-height: calc(100vh - 24px);
  }

  #mediserv-chat-toggle {
    min-height: 56px;
    padding: 10px;
    box-shadow: 0 16px 38px rgba(0,103,177,.22);
  }

  #mediserv-chat-toggle::before,
  #mediserv-chat-toggle::after {
    display: none;
  }

  #mediserv-chat-window.ms-open + #mediserv-chat-toggle {
    transform: none;
  }
}


/* Rev 1.6 — mobile safe-area layout so the full widget stays clearly visible */
@media (max-width: 520px) {
  #mediserv-chatbot {
    right: 12px !important;
    left: auto !important;
    top: auto !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 96px) !important;
    transform: none !important;
  }

  #mediserv-chat-toggle {
    min-height: 56px;
    padding: 10px;
    box-shadow: 0 16px 38px rgba(0,103,177,.22);
  }

  #mediserv-chat-toggle::before,
  #mediserv-chat-toggle::after {
    display: none;
  }

  #mediserv-chat-window {
    position: fixed;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    top: calc(env(safe-area-inset-top, 0px) + 70px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    height: auto;
    max-height: none;
    transform: none;
    border-radius: 24px;
  }

  .ms-chat-header {
    min-height: 78px !important;
    padding: 12px 14px !important;
  }

  .ms-chat-header h3 {
    font-size: 15px !important;
  }

  .ms-chat-header p {
    font-size: 11px !important;
  }

  .ms-chat-logo-wrap {
    width: 42px !important;
    height: 42px !important;
    border-radius: 14px !important;
  }

  .ms-chat-logo-wrap img {
    width: 31px !important;
    height: 31px !important;
  }

  #mediserv-chat-close {
    width: 34px;
    height: 34px;
    font-size: 22px;
  }

  .ms-chat-body {
    height: calc(100% - 154px);
    padding: 14px 12px;
  }

  .ms-message {
    max-width: 92%;
    font-size: 12.5px !important;
    line-height: 1.36 !important;
    padding: 10px 11px !important;
  }

  .ms-avatar {
    width: 28px;
    height: 28px;
    padding: 3px;
  }

  .ms-quick-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0 14px 0;
  }

  .ms-quick-actions button {
    padding: 9px 8px;
    font-size: 12px;
    line-height: 1.15;
  }

  .ms-chat-input-area {
    height: 58px;
    padding: 8px 10px;
  }

  #mediserv-chat-input {
    height: 40px;
    font-size: 13px;
  }

  #mediserv-chat-send {
    width: 40px;
    height: 40px;
  }

  .ms-secure-note {
    height: 22px;
    font-size: 11px;
  }

  .ms-lead-card {
    margin: 10px 0 14px 0;
  }
}


/* Rev 1.7 — tighter spacing between welcome message and quick answer buttons on mobile */
@media (max-width: 520px) {
  .ms-message-row.ms-bot-row {
    margin-bottom: 6px !important;
  }

  .ms-message p {
    margin-bottom: 4px !important;
  }

  .ms-message small {
    margin-top: 0 !important;
  }

  .ms-quick-actions {
    margin: 4px 0 10px 38px !important;
    gap: 6px !important;
  }

  .ms-quick-actions button {
    min-height: 36px !important;
    padding: 7px 8px !important;
  }
}


/* Rev 1.8 — move the mobile window higher and make the open widget more compact */
@media (max-width: 520px) {
  #mediserv-chat-window.ms-open {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
    top: calc(env(safe-area-inset-top, 0px) + 110px) !important;
    bottom: auto !important;
    height: min(60vh, 560px) !important;
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 130px) !important;
    transform: none !important;
    border-radius: 22px !important;
  }

  .ms-chat-body {
    height: calc(100% - 142px) !important;
    padding: 12px 12px 10px !important;
  }

  .ms-message-row {
    margin-bottom: 8px !important;
  }

  .ms-quick-actions {
    margin: 4px 0 8px 38px !important;
  }

  .ms-chat-input-area {
    height: 56px !important;
    padding: 8px 10px !important;
  }

  .ms-secure-note {
    height: 20px !important;
  }
}


/* Rev 1.9 — make the bottom security/lock message clearly visible on mobile */
@media (max-width: 520px) {
  #mediserv-chat-window.ms-open {
    top: calc(env(safe-area-inset-top, 0px) + 100px) !important;
    height: min(59vh, 550px) !important;
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 118px) !important;
  }

  .ms-chat-body {
    height: calc(100% - 148px) !important;
    padding: 12px 12px 8px !important;
  }

  .ms-chat-input-area {
    height: 54px !important;
    padding: 7px 10px !important;
    border-top: 1px solid rgba(15,23,42,.08) !important;
    border-bottom: 1px solid rgba(15,23,42,.06) !important;
    background: #ffffff !important;
  }

  .ms-secure-note {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 10px 6px !important;
    font-size: 11px !important;
    line-height: 1.1 !important;
    color: #64748b !important;
    background: #ffffff !important;
    border-radius: 0 0 22px 22px !important;
    position: relative !important;
    z-index: 3 !important;
    overflow: visible !important;
  }
}


/* Rev 2.0 — extra bottom spacing after the security text on mobile */
@media (max-width: 520px) {
  #mediserv-chat-window.ms-open {
    top: calc(env(safe-area-inset-top, 0px) + 96px) !important;
    height: min(56vh, 520px) !important;
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 126px) !important;
  }

  .ms-chat-body {
    height: calc(100% - 152px) !important;
  }

  .ms-chat-input-area {
    height: 52px !important;
    padding: 7px 10px 6px !important;
  }

  .ms-secure-note {
    height: 40px !important;
    min-height: 40px !important;
    padding: 4px 10px 14px !important;
    margin-bottom: 6px !important;
    border-radius: 0 0 22px 22px !important;
  }
}


/* Rev 2.1 — separate the medical warning text inside the welcome message */
.ms-bot-message small {
  display: block !important;
  margin-top: 10px !important;
  padding-top: 10px !important;
  border-top: 1px solid rgba(15,23,42,.10) !important;
  font-size: 11px !important;
  line-height: 1.35 !important;
  color: #111111 !important;
  font-weight: 600 !important;
}

@media (max-width: 520px) {
  .ms-bot-message small {
    margin-top: 8px !important;
    padding-top: 8px !important;
    font-size: 10.5px !important;
    line-height: 1.32 !important;
    color: #111111 !important;
  }
}


/* Rev 2.2 — add breathing room after the 6 quick action buttons */
@media (max-width: 520px) {
  .ms-quick-actions {
    margin-bottom: 22px !important;
  }

  .ms-chat-body::after {
    content: "";
    display: block;
    height: 8px;
  }
}

@media (min-width: 521px) {
  .ms-quick-actions {
    margin-bottom: 26px !important;
  }
}


/* Rev 2.3 — more bottom breathing room below the 6 quick actions while keeping the top text visible */
@media (max-width: 520px) {
  #mediserv-chat-window.ms-open {
    top: calc(env(safe-area-inset-top, 0px) + 92px) !important;
    height: min(62vh, 585px) !important;
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 112px) !important;
  }

  .ms-chat-body {
    height: calc(100% - 160px) !important;
    padding: 14px 12px 8px !important;
  }

  .ms-message-row.ms-bot-row {
    margin-bottom: 8px !important;
  }

  .ms-bot-message {
    padding-bottom: 12px !important;
  }

  .ms-quick-actions {
    margin: 10px 0 28px 38px !important;
    gap: 8px !important;
  }

  .ms-quick-actions button {
    min-height: 38px !important;
    padding: 8px 8px !important;
  }

  .ms-chat-input-area {
    margin-top: 0 !important;
  }

  .ms-secure-note {
    margin-top: 0 !important;
  }
}


/* Rev 3.7 — reverted launcher behavior; only compact welcome text changes retained */
.ms-bot-message p {
  margin-bottom: 0 !important;
}

.ms-bot-message small {
  margin-top: 12px !important;
  padding-top: 10px !important;
  border-top: 1px solid rgba(15,23,42,.09) !important;
  font-size: 10.5px !important;
  line-height: 1.34 !important;
  color: #687386 !important;
  font-weight: 500 !important;
}

@media (max-width: 520px) {
  .ms-bot-message {
    padding: 10px 12px !important;
  }

  .ms-bot-message p {
    font-size: 12.75px !important;
    line-height: 1.34 !important;
  }

  .ms-bot-message small {
    margin-top: 9px !important;
    padding-top: 8px !important;
    font-size: 10px !important;
    line-height: 1.28 !important;
    color: #6b7280 !important;
    font-weight: 500 !important;
  }

  .ms-quick-actions {
    grid-template-columns: 1fr 1fr !important;
    margin: 10px 0 22px 38px !important;
    gap: 7px !important;
  }

  .ms-quick-actions button {
    min-height: 36px !important;
    padding: 7px 8px !important;
    font-size: 11.75px !important;
  }

  .ms-quick-actions button:nth-child(n+5) {
    display: none !important;
  }
}
