/* AI booking widget: launcher, teaser, chat panel, SMS phone mockup.
 * Drop-in for any page: load this file + widget.js (see widget.js for config). */

:root {
  --brand: #1e3a8a;
  --brand-dark: color-mix(in srgb, var(--brand) 70%, #000);
  --on-brand: #ffffff;

  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --surface: #ffffff;
  --bubble-bot: #f1f3f7;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --success-bg: #ecfdf3;
  --success-text: #067647;
  --info-bg: color-mix(in srgb, var(--brand) 10%, #fff);
  --info-text: var(--brand);

  --shadow-lg: 0 1px 2px rgba(16, 24, 40, 0.06), 0 24px 56px -12px rgba(16, 24, 40, 0.28);
  --radius: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --bg-alt: #111722;
    --surface: #151a24;
    --bubble-bot: #222936;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #273042;
    --success-bg: #0f2a1d;
    --success-text: #6ce9a6;
    --info-bg: color-mix(in srgb, var(--brand) 22%, #151a24);
    --info-text: #e2e8f0;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-alt: #111722;
  --surface: #151a24;
  --bubble-bot: #222936;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #273042;
  --success-bg: #0f2a1d;
  --success-text: #6ce9a6;
  --info-bg: color-mix(in srgb, var(--brand) 22%, #151a24);
  --info-text: #e2e8f0;
}

/* Scoped base so the widget looks the same on any host page. */
.launcher, .teaser, .chat, .phone, .sms-card {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.launcher, .teaser, .chat, .phone, .launcher *, .teaser *, .chat *, .phone * { box-sizing: border-box; }
.chat button, .launcher, .teaser button { font: inherit; }
.chat [hidden], .teaser[hidden] { display: none !important; }

/* ================= Chat widget ================= */
.launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--brand) 70%, #000), 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.18s;
}
.launcher:hover { transform: scale(1.06); }
.launcher svg { grid-area: 1 / 1; transition: transform 0.25s, opacity 0.2s; }
.launcher__x { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.is-open .launcher__chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.is-open .launcher__x { opacity: 1; transform: none; }
.launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 var(--brand);
  animation: pulse 2.4s infinite;
}
.is-open .launcher::after, .launcher.pulsed::after { animation: none; }

.teaser {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 49;
  width: 280px;
  padding: 16px 18px 16px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.teaser p { margin: 0; font-size: 14.5px; line-height: 1.45; font-weight: 500; }
.teaser__avatar {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand) center / cover no-repeat;
  color: var(--on-brand);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.teaser__close {
  position: absolute;
  top: -8px; right: -8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
}

.chat {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 50;
  width: 380px;
  height: min(620px, calc(100vh - 124px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.1), visibility 0s 0.26s;
}
.is-open .chat {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.1), visibility 0s;
}

.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 18px 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: var(--on-brand);
}
.chat__avatar {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95) center / cover no-repeat;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px;
  color: var(--brand);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.chat__title { flex: 1; min-width: 0; }
.chat__title h2 { margin: 0; font-size: 16.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__title p { margin: 2px 0 0; font-size: 12.5px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.chat__close {
  flex: none;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  display: grid; place-items: center;
  cursor: pointer;
}
.chat__close:hover { background: rgba(255, 255, 255, 0.14); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3); }

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop 0.22s ease-out;
}
.msg--bot { align-self: flex-start; background: var(--bubble-bot); color: var(--text); border-bottom-left-radius: 6px; }
.msg--user { align-self: flex-end; background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 6px; }

.notice {
  align-self: center;
  margin: 6px 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  text-align: center;
  background: var(--success-bg);
  color: var(--success-text);
  animation: pop 0.3s ease-out;
}
.notice--info { background: var(--info-bg); color: var(--info-text); }
.notice--warn { background: var(--bubble-bot); color: var(--muted); }

/* Inline SMS preview card (small screens, where the phone mockup doesn't fit) */
.sms-card {
  align-self: stretch;
  margin: 4px 6px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--border));
  background: var(--info-bg);
  animation: pop 0.3s ease-out;
}
.sms-card__label { margin: 0 0 8px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--info-text); }
.sms-card__bubble { padding: 10px 12px; border-radius: 14px; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.45; }

.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bubble-bot);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

.chat__composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat__composer input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bubble-bot);
  border: 1px solid transparent;
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chat__composer input:focus { border-color: var(--brand); background: var(--surface); }
.chat__composer button {
  flex: none;
  width: 46px; height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
.chat__composer button:hover { transform: scale(1.05); }
.chat__composer button:disabled { opacity: 0.5; cursor: default; transform: none; }
.chat__footer { text-align: center; font-size: 11px; color: var(--muted); padding: 0 0 10px; background: var(--surface); }

/* ================= Phone mockup ================= */
/* Dims the page while the SMS preview is up, so the phone + chat read as one moment. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 47;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
body.has-phone::before { opacity: 1; }

.phone {
  position: fixed;
  z-index: 48;
  right: 428px;
  bottom: 100px;
  width: 270px;
  opacity: 0;
  transform: translateX(30px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.phone.is-visible { opacity: 1; transform: none; }
.phone__label,
.phone__to {
  margin: 0 0 10px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.phone__label {
  display: inline-block;
  width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.15);
}
.phone__to { margin: 10px 0 0; font-weight: 500; color: var(--muted); }
.phone__device {
  position: relative;
  height: 500px;
  padding: 14px 14px 20px;
  border-radius: 42px;
  background: #fff;
  color: #0f172a;
  border: 10px solid #0f172a;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px #334155;
  overflow: hidden;
}
.phone__notch {
  position: absolute;
  top: 8px; left: 50%;
  width: 86px; height: 22px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #0f172a;
}
.phone__status { display: flex; justify-content: space-between; padding: 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.phone__status span:last-child { font-size: 9px; letter-spacing: 1px; }
.phone__contact {
  margin: 22px -14px 0;
  padding: 0 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  border-bottom: 1px solid #e5e7eb;
}
.phone__avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--brand) center / cover no-repeat;
  color: var(--on-brand);
  display: grid; place-items: center;
  font-weight: 700;
}
.phone__thread { padding-top: 14px; }
.phone__stamp { margin: 0 0 10px; text-align: center; font-size: 10.5px; color: #64748b; }
.phone__bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: #e9e9eb;
  color: #0f172a;
  font-size: 13.5px;
  line-height: 1.42;
  opacity: 0;
  transform: translateY(8px);
}
.phone.is-visible .phone__bubble { animation: bubbleIn 0.4s 0.45s ease-out forwards; }

/* ================= Animations ================= */
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes bubbleIn { to { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 55%, transparent); }
  70% { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ================= Small screens ================= */
@media (max-width: 480px) {
  .chat {
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    z-index: 60;
  }
  .is-open .launcher { display: none; }
  .teaser { right: 16px; left: 16px; width: auto; bottom: 96px; }
  .launcher { right: 16px; bottom: 16px; }
}
