.health-chatbot {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5000;
  font-family: "Tajawal", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --chatbot-vh: 100dvh;
  --chatbot-offset-top: 0px;
}

.health-chatbot,
.health-chatbot * {
  box-sizing: border-box;
}

.health-chatbot__launcher {
  position: relative;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #141006;
  background:
    linear-gradient(135deg, #fff4ba, #ffcc00 52%, #c99400),
    #ffcc00;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

.health-chatbot__launcher i {
  font-size: 25px;
}

.health-chatbot__pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 204, 0, 0.55);
  animation: health-chatbot-pulse 1.8s ease-out infinite;
}

.health-chatbot__panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(390px, calc(100vw - 32px));
  height: min(570px, calc(100vh - 122px));
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  border: 1px solid rgba(255, 204, 0, 0.28);
  border-radius: 22px;
  color: #f8fafc;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0)),
    #101112;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.health-chatbot.is-open .health-chatbot__panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.health-chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(255, 204, 0, 0.18), rgba(255, 255, 255, 0.03));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.health-chatbot__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.health-chatbot__mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #15110a;
  background: linear-gradient(135deg, #fff4b5, #ffcc00);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.health-chatbot__brand strong,
.health-chatbot__brand small {
  display: block;
  white-space: nowrap;
}

.health-chatbot__brand strong {
  font-size: 15px;
  line-height: 1.4;
}

.health-chatbot__brand small {
  color: #cbd5e1;
  font-size: 10.5px;
  line-height: 1.45;
  white-space: normal;
}

.health-chatbot__close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.health-chatbot__messages {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 204, 0, 0.5) rgba(255, 255, 255, 0.06);
}

.health-chatbot__message {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.health-chatbot__message--bot {
  align-self: flex-end;
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 6px;
}

.health-chatbot__message--user {
  align-self: flex-start;
  color: #16120a;
  background: linear-gradient(135deg, #ffe58a, #ffcc00);
  border-bottom-right-radius: 6px;
}

.health-chatbot__message--system {
  align-self: center;
  max-width: 96%;
  color: #fef3c7;
  background: rgba(255, 204, 0, 0.1);
  border: 1px solid rgba(255, 204, 0, 0.18);
  text-align: center;
}

.health-chatbot__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.health-chatbot__actions button,
.health-chatbot__chip {
  border: 1px solid rgba(255, 204, 0, 0.22);
  border-radius: 999px;
  padding: 8px 11px;
  color: #ffeeb0;
  background: rgba(255, 204, 0, 0.08);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.health-chatbot__actions button {
  flex: 1 1 calc(33.333% - 8px);
  min-width: 96px;
  text-align: center;
}

.health-chatbot__message--questions {
  max-width: 96%;
}

.health-chatbot__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 8px 6px 0 0;
  text-align: right;
  vertical-align: top;
}

.health-chatbot__chip--more {
  color: #141006;
  background: linear-gradient(135deg, #fff2a6, #ffcc00);
  border-color: rgba(255, 204, 0, 0.5);
  font-weight: 700;
}

.health-chatbot__form {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.24);
}

.health-chatbot__form input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 11px 12px;
  outline: none;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
  font-size: 16px;
  line-height: 1.35;
}

.health-chatbot__form input:focus {
  border-color: rgba(255, 204, 0, 0.62);
  box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.12);
}

.health-chatbot__form button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  color: #141006;
  background: linear-gradient(135deg, #fff2a6, #ffcc00);
  cursor: pointer;
}

.health-chatbot__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.health-chatbot__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffcc00;
  animation: health-chatbot-dot 1s ease-in-out infinite;
}

.health-chatbot__typing span:nth-child(2) {
  animation-delay: 0.12s;
}

.health-chatbot__typing span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes health-chatbot-pulse {
  from {
    opacity: 0.8;
    transform: scale(0.9);
  }
  to {
    opacity: 0;
    transform: scale(1.25);
  }
}

@keyframes health-chatbot-dot {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@media (max-width: 640px) {
  .health-chatbot {
    right: 14px;
    bottom: 78px;
  }

  .health-chatbot__panel {
    right: -2px;
    bottom: 74px;
    width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 158px));
    max-width: calc(100vw - 24px);
    border-radius: 18px;
  }

  .health-chatbot.is-open.is-writing {
    top: var(--chatbot-offset-top, 0px);
    left: 0;
    right: 0;
    bottom: auto;
    width: 100vw;
    height: var(--chatbot-vh, 100dvh);
    overflow: hidden;
  }

  .health-chatbot.is-open.is-writing .health-chatbot__launcher {
    display: none;
  }

  .health-chatbot.is-open.is-writing .health-chatbot__panel {
    position: fixed;
    top: var(--chatbot-offset-top, 0px);
    left: 0;
    right: 0;
    bottom: auto;
    width: 100vw;
    height: var(--chatbot-vh, 100dvh);
    max-width: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    transform: none;
  }

  .health-chatbot.is-open.is-writing .health-chatbot__messages {
    padding-bottom: 18px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .health-chatbot.is-open.is-writing .health-chatbot__actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
  }

  .health-chatbot.is-open.is-writing .health-chatbot__actions button {
    min-width: 0;
    width: 100%;
    padding: 8px 6px;
    font-size: 11.5px;
    line-height: 1.35;
    white-space: normal;
  }

  .health-chatbot.is-open.is-writing .health-chatbot__form {
    grid-template-columns: 1fr 46px;
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }
}
