/* Floating Chatbox styles aligned with site identity */
:root {
  --chat-radius: var(--radius-md, 10px);
}

/* Floating button */
.chat-fab {
  position: fixed;
  inset-inline-start: 18px; 
  /* right in RTL/auto */
  bottom: 18px; /* sit above contact widget */
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(var(--brand-primary-rgb), 0.45), 0 2px 6px rgba(0,0,0,0.18);
  cursor: pointer;
  z-index: 1041; /* above contact */
  transition: filter .2s ease, transform .2s ease;
}
.chat-fab:hover { filter: brightness(.95); transform: translateY(-2px); }
.chat-fab svg { display: block; }
.chat-fab .chat-badge {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: #ef4444; /* red-500 */
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

/* Chat window */
.chat-window {
  position: fixed;
  inset-inline-start: 18px;
  bottom: 88px;
  width: min(360px, 92vw);
  max-height: min(70vh, 560px);
  background: #fff;
  border: 1px solid var(--brand-border);
  border-radius: var(--chat-radius);
  box-shadow: var(--shadow-md, 0 8px 22px rgba(2,8,23,.12));
  display: none; /* toggled to flex */
  flex-direction: column;
  overflow: hidden;
  z-index: 1042;
}
@media (max-width: 575.98px) {
  .chat-fab { inset-inline-end: 14px; bottom: 80px; width: 50px; height: 50px; }
  .chat-window { inset-inline-end: 14px; bottom: 80px; width: min(92vw, 380px); }
}

.chat-header {
  background: linear-gradient(180deg, rgba(var(--brand-primary-rgb), .06), transparent), #fff;
  border-bottom: 1px solid var(--brand-border);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header .header-info h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--brand-ink);
}
.connection-status {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  color: #065f46;
  background: rgba(16,185,129,.08);
}
.connection-status.offline { color: #991b1b; background: rgba(239,68,68,.08); }

.header-controls { display: flex; align-items: center; gap: 6px; }
.control-btn {
  border: 1px solid var(--brand-border);
  background: #fff;
  color: var(--brand-ink);
  border-radius: 8px;
  font-size: 14px;
  width: 34px; height: 34px;
}
.close-chat {
  border: none;
  background: var(--brand-primary);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
}

.chat-messages {
  padding: 12px;
  overflow: auto;
  flex: 1 1 auto;
  background: #f8fafc;
}
.msg {
  background: #fff;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  max-width: 85%;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(2,8,23,.06));
}
.msg.me {
  margin-inline-start: auto;
  background: rgba(var(--brand-primary-rgb), .06);
  border-color: rgba(var(--brand-primary-rgb), .35);
}

.chat-input {
  border-top: 1px solid var(--brand-border);
  padding: 10px;
  display: flex;
  gap: 8px;
}
.chat-input input {
  flex: 1 1 auto;
  height: 42px;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  padding: 0 10px;
}
.chat-input button {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-muted);
  font-size: .875rem;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand-muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2 } 40% { opacity: 1 } }

/* Bot options + inputs */
.bot-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.bot-option-btn {
  border: 1px solid var(--brand-border);
  background: #fff;
  color: var(--brand-ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .85rem;
}
.visitor-data-input .input-container { display: flex; gap: 8px; }
.visitor-input { flex: 1 1 auto; height: 42px; border: 1px solid var(--brand-border); border-radius: 8px; padding: 0 10px; }
.submit-visitor-btn { background: var(--brand-primary); color: #fff; border: none; border-radius: 8px; padding: 0 12px; font-weight: 700; }
.input-hint { color: #64748b; display: block; margin-top: 6px; }
.input-error { color: #b91c1c; margin-top: 6px; font-size: .85rem; }
