/* Floating WhatsApp + chatbot FABs — closed by default, glowing circles */
.hi-fab {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.85rem;
  font-family: inherit;
}

.hi-fab__stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.hi-fab__btn {
  width: 3.55rem;
  height: 3.55rem;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.hi-fab__btn:hover,
.hi-fab__btn:focus-visible {
  transform: translateY(-2px) scale(1.04);
  outline: none;
}

.hi-fab__btn--whatsapp {
  background: #25d366;
  box-shadow: 0 8px 22px rgba(37, 211, 102, 0.45);
  animation: hi-fab-glow-wa 2.4s ease-in-out infinite;
}

.hi-fab__btn--agent {
  background: var(--brand-accent, #c4a35a);
  color: #1a1408;
  box-shadow: 0 8px 22px rgba(196, 163, 90, 0.45);
  animation: hi-fab-glow-agent 2.6s ease-in-out infinite;
}

.hi-fab.is-open .hi-fab__btn--agent {
  background: var(--brand-primary, #0f3d5e);
  color: #fff;
  animation: none;
}

@keyframes hi-fab-glow-wa {
  0%, 100% {
    box-shadow: 0 8px 22px rgba(37, 211, 102, 0.45), 0 0 0 0 rgba(37, 211, 102, 0.35);
  }
  50% {
    box-shadow: 0 8px 22px rgba(37, 211, 102, 0.45), 0 0 0 12px rgba(37, 211, 102, 0);
  }
}

@keyframes hi-fab-glow-agent {
  0%, 100% {
    box-shadow: 0 8px 22px rgba(196, 163, 90, 0.45), 0 0 0 0 rgba(196, 163, 90, 0.35);
  }
  50% {
    box-shadow: 0 8px 22px rgba(196, 163, 90, 0.45), 0 0 0 12px rgba(196, 163, 90, 0);
  }
}

/* Critical: force closed state — plain display:flex would override [hidden] */
.hi-fab__panel {
  --hi-chat-ink: #152033;
  --hi-chat-muted: #5b6575;
  --hi-chat-surface: #ffffff;
  --hi-chat-bubble: #f3f5f8;
  position: absolute;
  right: 0;
  bottom: calc(3.55rem + 0.85rem + 3.55rem + 0.85rem);
  width: min(23rem, calc(100vw - 1.5rem));
  height: min(34rem, calc(100vh - 7.5rem));
  flex-direction: column;
  background: var(--hi-chat-surface);
  color: var(--hi-chat-ink);
  border: 1px solid rgba(20, 32, 51, 0.12);
  border-radius: 1rem;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  display: none;
}

.hi-fab__panel[hidden],
.hi-fab__panel[aria-hidden="true"] {
  display: none !important;
}

.hi-fab.is-open .hi-fab__panel,
.hi-fab.is-open .hi-fab__panel:not([hidden]) {
  display: flex !important;
}

[data-theme="dark"] .hi-fab__panel {
  --hi-chat-ink: #eef2f8;
  --hi-chat-muted: #aeb8c8;
  --hi-chat-surface: #121826;
  --hi-chat-bubble: #1c2433;
  border-color: rgba(232, 238, 247, 0.12);
}

.hi-fab__head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(135deg, #1a4d6e, #0f3d5e);
  color: #fff;
}

.hi-fab__name {
  margin: 0;
  font-weight: 700;
  font-size: 0.98rem;
  color: #fff;
}

.hi-fab__status {
  margin: 0.12rem 0 0;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.88);
}

.hi-fab__close {
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.4rem;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

/* Compact suggestion strip under header — horizontal scroll, low height */
.hi-fab__suggestions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  border-bottom: 1px solid rgba(20, 32, 51, 0.08);
  background: #f7f8fa;
  -webkit-overflow-scrolling: touch;
}

.hi-fab__suggestions[hidden] {
  display: none !important;
}

[data-theme="dark"] .hi-fab__suggestions {
  background: #171e2b;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.hi-fab__chip {
  flex: 0 0 auto;
  max-width: 11.5rem;
  border: 1px solid rgba(20, 32, 51, 0.14);
  background: #fff;
  color: #152033;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

[data-theme="dark"] .hi-fab__chip {
  background: #1f2937;
  color: #eef2f8;
  border-color: rgba(255, 255, 255, 0.14);
}

.hi-fab__chip:hover,
.hi-fab__chip:focus-visible {
  border-color: #0f3d5e;
  outline: none;
}

.hi-fab__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #eef1f5;
}

[data-theme="dark"] .hi-fab__messages {
  background: #0e1420;
}

.hi-fab__msg {
  max-width: 94%;
}

.hi-fab__msg--user {
  align-self: flex-end;
}

.hi-fab__msg--assistant {
  align-self: flex-start;
}

.hi-fab__bubble {
  padding: 0.65rem 0.8rem;
  border-radius: 0.8rem;
  font-size: 0.9rem;
  line-height: 1.45;
  background: #ffffff;
  color: #152033 !important;
  border: 1px solid rgba(20, 32, 51, 0.1);
}

.hi-fab__bubble,
.hi-fab__bubble * {
  color: #152033 !important;
}

.hi-fab__bubble a {
  color: #0b4f7a !important;
  text-decoration: underline;
}

[data-theme="dark"] .hi-fab__bubble {
  background: #1c2433;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .hi-fab__bubble,
[data-theme="dark"] .hi-fab__bubble * {
  color: #eef2f8 !important;
}

[data-theme="dark"] .hi-fab__bubble a {
  color: #8ec8f0 !important;
}

.hi-fab__msg--user .hi-fab__bubble {
  background: #0f3d5e !important;
  border-color: transparent;
}

.hi-fab__msg--user .hi-fab__bubble,
.hi-fab__msg--user .hi-fab__bubble * {
  color: #ffffff !important;
}

.hi-fab__bubble p {
  margin: 0 0 0.45rem;
}

.hi-fab__bubble p:last-child {
  margin-bottom: 0;
}

.hi-fab__bubble strong {
  font-weight: 700;
}

.hi-fab__msg--pending .hi-fab__bubble {
  opacity: 0.85;
  font-style: italic;
  color: #5b6575 !important;
}

.hi-fab__sources {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.hi-fab__sources a,
.hi-fab__sources li {
  font-size: 0.7rem;
  color: #0b4f7a !important;
  text-decoration: none;
  background: rgba(11, 79, 122, 0.1);
  padding: 0.18rem 0.4rem;
  border-radius: 999px;
}

.hi-fab__form {
  flex: 0 0 auto;
  display: flex;
  gap: 0.45rem;
  padding: 0.65rem 0.7rem;
  border-top: 1px solid rgba(20, 32, 51, 0.1);
  background: #fff;
}

[data-theme="dark"] .hi-fab__form {
  background: #121826;
  border-top-color: rgba(255, 255, 255, 0.08);
}

.hi-fab__input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(20, 32, 51, 0.16);
  border-radius: 0.6rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: #fff;
  color: #152033;
}

.hi-fab__input::placeholder {
  color: #7a8494;
}

.hi-fab__send {
  border: 0;
  border-radius: 0.6rem;
  padding: 0 0.9rem;
  background: var(--brand-accent, #c4a35a);
  color: #1a1408;
  font-weight: 700;
  cursor: pointer;
}

body.has-mobile-cta .hi-fab {
  bottom: 4.5rem;
}

@media (max-width: 640px) {
  .hi-fab {
    right: 0.8rem;
    bottom: 0.85rem;
  }

  body.has-mobile-cta .hi-fab {
    bottom: 4.7rem;
  }

  .hi-fab__panel {
    width: min(100vw - 1rem, 23rem);
    height: min(72vh, 34rem);
    bottom: calc(3.55rem + 0.85rem + 3.55rem + 0.7rem);
  }
}
