/* SW Booking Agent – Chat Widget
   Lightweight, mobile-first, no dependencies.
   Brand color set via --swba-brand CSS variable. */

:root {
  --swba-brand: #1a73e8;
  --swba-bg: #ffffff;
  --swba-text: #1a1a1a;
  --swba-light: #f1f3f5;
  --swba-muted: #6b7280;
  --swba-radius: 12px;
  --swba-shadow: 0 4px 24px rgba(0,0,0,.12);
}

/* ── Toggle button ────────────────────────────────────────────────── */
#swba-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--swba-brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--swba-shadow);
  transition: transform .2s ease, background .2s ease;
}
#swba-toggle:hover {
  transform: scale(1.08);
}
#swba-toggle.swba-open {
  transform: scale(0);
  pointer-events: none;
}

/* ── Chat window ──────────────────────────────────────────────────── */
#swba-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100000;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 40px);
  background: var(--swba-bg);
  border-radius: var(--swba-radius);
  box-shadow: var(--swba-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--swba-text);
  transition: opacity .2s ease, transform .2s ease;
}
#swba-window.swba-hidden {
  opacity: 0;
  transform: translateY(16px) scale(.96);
  pointer-events: none;
}

/* ── Header ───────────────────────────────────────────────────────── */
#swba-header {
  background: var(--swba-brand);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#swba-header-name {
  font-weight: 600;
  font-size: 15px;
}
#swba-header-status {
  font-size: 12px;
  opacity: .85;
}
#swba-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: .8;
  transition: opacity .15s;
}
#swba-close:hover {
  opacity: 1;
}

/* ── Messages area ────────────────────────────────────────────────── */
#swba-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 8px;
  scroll-behavior: smooth;
}
.swba-msg {
  display: flex;
  margin-bottom: 10px;
  animation: swbaFade .25s ease;
}
.swba-msg.swba-bot {
  justify-content: flex-start;
}
.swba-msg.swba-user {
  justify-content: flex-end;
}
.swba-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.swba-bot .swba-bubble {
  background: var(--swba-light);
  color: var(--swba-text);
  border-bottom-left-radius: 4px;
}
.swba-user .swba-bubble {
  background: var(--swba-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.swba-bubble a {
  color: inherit;
  text-decoration: underline;
  font-weight: 500;
}
.swba-user .swba-bubble a {
  color: #fff;
}

/* ── Quick replies ────────────────────────────────────────────────── */
#swba-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
}
.swba-qr {
  background: var(--swba-bg);
  color: var(--swba-brand);
  border: 1.5px solid var(--swba-brand);
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.swba-qr:hover {
  background: var(--swba-brand);
  color: #fff;
}

/* ── Input bar ────────────────────────────────────────────────────── */
#swba-input-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid #e5e7eb;
  padding: 8px 10px;
  gap: 8px;
  flex-shrink: 0;
}
#swba-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
#swba-input:focus {
  border-color: var(--swba-brand);
}
#swba-send {
  background: var(--swba-brand);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
#swba-send:hover {
  opacity: .85;
}

/* ── Typing indicator ─────────────────────────────────────────────── */
.swba-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}
.swba-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--swba-muted);
  animation: swbaBounce .6s infinite alternate;
}
.swba-typing-dots span:nth-child(2) { animation-delay: .15s; }
.swba-typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes swbaBounce {
  to { opacity: .3; transform: translateY(-4px); }
}
@keyframes swbaFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile tweaks ────────────────────────────────────────────────── */
@media (max-width: 420px) {
  #swba-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    bottom: 8px;
    right: 8px;
    border-radius: 10px;
  }
  #swba-toggle {
    bottom: 12px;
    right: 12px;
  }
}
