/* Smart Flow Services — AI chat widget styles.
 * Matches the site's dark HUD aesthetic (styles.css variables, mono accents).
 * The widget anchors to the inline-start edge so it mirrors itself in RTL.
 */

.chat-widget {
  position: fixed;
  /* 28px aligns with the footer bar's horizontal padding; bottom 16px nests
     the FABs inside the taller .hud-bottom bar (88px). */
  inset-inline-start: 1.75rem;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  /* Side by side on desktop: WhatsApp sits to the RIGHT of the AI chat
     bubble (row-reverse because the WA button is first in the DOM). */
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 0.75rem;
  font-family: var(--font-body, "Heebo", system-ui, sans-serif);
  direction: ltr; /* chat text itself stays LTR even in an RTL page */
}

.chat-widget[dir="rtl"],
html[dir="rtl"] .chat-widget {
  direction: ltr; /* keep messages readable; container flips via inset-inline */
}

/* --- floating bubble ------------------------------------------------------ */

.chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--accent, #4dd0e1);
  background: var(--surface, #1b1d23);
  color: var(--accent, #4dd0e1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.chat-bubble:hover {
  transform: translateY(-2px);
  background: var(--accent-dim, rgba(77, 208, 225, 0.14));
}

.chat-bubble-hidden {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

/* --- floating WhatsApp button -------------------------------------------- */

.chat-wa {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #25d366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.chat-wa:hover {
  transform: translateY(-2px);
  background: #1ebe5b;
}

/* --- panel ---------------------------------------------------------------- */

.chat-panel {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 0.9rem);
  width: min(360px, calc(100vw - 2.5rem));
  height: min(480px, calc(100vh - 6.5rem));
  display: flex;
  flex-direction: column;
  background: var(--surface, #1b1d23);
  border: 1px solid var(--border, #3a3d45);
  border-radius: 14px;
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.chat-panel[hidden] {
  display: none;
}

/* --- header --------------------------------------------------------------- */

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg, #101318);
  border-bottom: 1px solid var(--border, #3a3d45);
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-dim, rgba(77, 208, 225, 0.14));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.chat-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.chat-title {
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--fg, #eef0f4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #9ba0ab);
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 6px #3ddc84;
}

.chat-status-dot.chat-status-off {
  background: var(--muted, #9ba0ab);
  box-shadow: none;
}

.chat-close {
  background: transparent;
  border: none;
  color: var(--muted, #9ba0ab);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.chat-close:hover {
  color: var(--fg, #eef0f4);
  background: var(--accent-dim, rgba(77, 208, 225, 0.14));
}

/* --- messages ------------------------------------------------------------- */

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.85rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent, #4dd0e1) transparent;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: var(--accent, #4dd0e1);
  border-radius: 3px;
}

.chat-msg {
  max-width: 86%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg p {
  margin: 0;
}

.chat-bot {
  align-self: flex-start;
  background: var(--bg, #101318);
  border: 1px solid var(--border, #3a3d45);
  border-start-start-radius: 4px;
  color: var(--fg, #eef0f4);
}

.chat-hint {
  border-style: dashed;
  color: var(--muted, #9ba0ab);
  font-size: 0.78rem;
}

.chat-user {
  align-self: flex-end;
  background: var(--accent-dim, rgba(77, 208, 225, 0.16));
  border: 1px solid var(--accent, #4dd0e1);
  border-end-end-radius: 4px;
  color: var(--fg, #eef0f4);
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  padding-block: 0.6rem;
}

.chat-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted, #9ba0ab);
  animation: chat-blink 1.2s infinite ease-in-out;
}

.chat-typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chat-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* --- input ---------------------------------------------------------------- */

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem 0.85rem;
  border-top: 1px solid var(--border, #3a3d45);
}

.chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg, #101318);
  border: 1px solid var(--border, #3a3d45);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--fg, #eef0f4);
  font-family: var(--font-body, "Heebo", system-ui, sans-serif);
  font-size: 0.85rem;
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent, #4dd0e1);
}

.chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-send {
  background: var(--accent-dim, rgba(77, 208, 225, 0.16));
  border: 1px solid var(--accent, #4dd0e1);
  color: var(--accent, #4dd0e1);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-send:hover {
  background: var(--accent, #4dd0e1);
  color: #06222b;
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget,
  .chat-bubble,
  .chat-wa,
  .chat-panel,
  .chat-typing .dot {
    transition: none;
    animation: none;
  }
}
