/* ChatBot widget — scoped under #lw-root to avoid clashing with host site styles */
#lw-root, #lw-root * { box-sizing: border-box; }

#lw-root {
  --lw-color: #0e7c86;
  --lw-color-dark: #0a5b62;
  --lw-color-shadow: rgba(14, 124, 134, 0.35);
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Docks the widget in the bottom-left corner instead of the default bottom-right. Set via the
   widget script's applyPosition(), driven by data-position or the bot's saved widget position. */
#lw-root.lw-position-left {
  right: auto;
  left: 20px;
}
#lw-root.lw-position-left #lw-window {
  right: auto;
  left: 0;
}

#lw-bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--lw-color);
  box-shadow: 0 6px 20px var(--lw-color-shadow);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.2s ease;
  /* Hidden until #lw-root gets .lw-ready (added once the real brand color is known) — avoids a
     visible flash of the default teal before the saved color loads in from the server. */
  opacity: 0;
  pointer-events: none;
}
#lw-root.lw-ready #lw-bubble {
  opacity: 1;
  pointer-events: auto;
}
#lw-bubble:hover { transform: scale(1.06); }
#lw-bubble svg { width: 26px; height: 26px; }

#lw-window {
  display: none;
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 40px);
  height: 460px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(14, 43, 51, 0.25);
  overflow: hidden;
  flex-direction: column;
}
#lw-window.open { display: flex; }

#lw-header {
  background: var(--lw-color);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#lw-header-title { font-size: 15px; font-weight: 700; }
#lw-header-sub { font-size: 11.5px; opacity: 0.85; margin-top: 1px; }
#lw-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
#lw-minimize,
#lw-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 5px;
  opacity: 0.85;
  border-radius: 6px;
  transition: opacity 0.15s, background 0.15s;
}
#lw-minimize:hover,
#lw-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }
#lw-minimize svg { width: 17px; height: 17px; }
#lw-close svg { width: 17px; height: 17px; }

/* Pinned Forms buttons — standing in the header so a visitor can start a structured form
   without typing. Hidden (display:none, set from JS) when a bot has no pinned forms. */
#lw-pinned-forms {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  background: var(--lw-color);
}
.lw-pinned-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.lw-pinned-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* Inline Form card — every field of a Form shown at once in a single chat bubble, filled out
   and submitted in one screen (no back-and-forth questions). */
.lw-form-card {
  align-self: stretch;
  background: #ffffff;
  border: 1px solid #dfe9ea;
  border-radius: 14px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lw-form-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #1c2b33;
}
.lw-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lw-form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #5c6b6d;
}
.lw-form-input {
  border: 1.5px solid #dfe9ea;
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  color: #1c2b33;
  outline: none;
  background: #fff;
}
.lw-form-input:focus { border-color: var(--lw-color); }
.lw-form-location-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lw-form-location-btn {
  align-self: flex-start;
  background: #eef8f8;
  border: 1.5px solid var(--lw-color);
  color: var(--lw-color);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.lw-form-location-btn:disabled { opacity: 0.6; cursor: default; }
.lw-form-error {
  font-size: 11px;
  color: #d9534f;
}
.lw-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.lw-form-submit {
  flex: 1;
  background: var(--lw-color);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.lw-form-submit:hover { background: var(--lw-color-dark); }
.lw-form-submit:disabled { opacity: 0.6; cursor: default; }
.lw-form-cancel {
  background: none;
  border: 1.5px solid #dfe9ea;
  color: #7c8f93;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#lw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f4f8f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lw-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.lw-msg.user {
  align-self: flex-end;
  background: var(--lw-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lw-msg.bot {
  align-self: flex-start;
  background: #ffffff;
  color: #1c2b33;
  border: 1px solid #dfe9ea;
  border-bottom-left-radius: 4px;
}
.lw-msg.typing {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #dfe9ea;
  color: #7c8f93;
  font-style: italic;
}
.lw-msg a {
  color: inherit;
  text-decoration: underline;
  word-break: break-word;
}
.lw-msg.bot a {
  color: var(--lw-color);
}
/* Human agent reply (dashboard takeover) — same shape as a bot bubble, distinct accent so a
   visitor can tell a real person answered, with a small sender label above the text. */
.lw-msg.agent {
  align-self: flex-start;
  background: #fff8ec;
  color: #1c2b33;
  border: 1px solid #f0dcb0;
  border-bottom-left-radius: 4px;
}
.lw-msg-sender {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #a8791f;
  margin-bottom: 3px;
}
/* System notices (escalated/returned/closed) — centered, muted, no bubble shape. Also used for
   the existing "Triggered: X" keyword-match note. */
.lw-msg.system {
  align-self: center;
  background: transparent;
  border: none;
  color: #7c8f93;
  font-size: 12px;
  font-style: italic;
  text-align: center;
  max-width: 90%;
  padding: 2px 8px;
}

/* --- CSAT rating prompt (shown once, at the end of a conversation) --- */
.lw-csat {
  align-self: center;
  background: #ffffff;
  border: 1px solid #dfe9ea;
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 90%;
  text-align: center;
}
.lw-csat-label {
  font-size: 12.5px;
  color: #1c2b33;
  margin-bottom: 8px;
}
.lw-csat-stars {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.lw-csat-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #d8dfe0;
  padding: 2px;
}
.lw-csat-star:hover,
.lw-csat-star.lw-csat-star-active {
  color: #f2a93b;
}
.lw-csat-skip {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: #9aa7aa;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
}
.lw-csat-thanks {
  font-size: 12.5px;
  color: #4c7a5a;
}

.lw-end-confirm-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 26, 30, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
  border-radius: 14px;
}
.lw-end-confirm {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 260px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(14, 43, 51, 0.3);
}
.lw-end-confirm-label {
  font-size: 13.5px;
  font-weight: 600;
  color: #1c2b33;
  margin-bottom: 14px;
}
.lw-end-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.lw-end-confirm-yes {
  background: var(--lw-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}
.lw-end-confirm-no {
  background: none;
  border: 1px solid #dfe9ea;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: #5b6b70;
  cursor: pointer;
  flex: 1;
}

.lw-quick-replies {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.lw-quick-reply {
  background: var(--lw-color);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 82%;
  text-align: right;
  transition: background 0.15s;
}
.lw-quick-reply:hover { background: var(--lw-color-dark); }
.lw-quick-reply-back {
  background: transparent;
  color: var(--lw-color);
  border: 1.5px solid #cfe0e3;
  font-weight: 600;
}
.lw-quick-reply-back:hover { background: #e4f2f1; }

.lw-whatsapp-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 20px;
  margin-top: 2px;
}
.lw-whatsapp-btn:hover { background: #1fb958; }
.lw-call-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--lw-color);
  color: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 20px;
  margin-top: 2px;
}
.lw-call-btn:hover { background: var(--lw-color-dark); }
.lw-contact-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lw-summary-link {
  color: var(--lw-color);
  font-weight: 600;
  text-decoration: underline;
}
.lw-summary-link:hover { color: var(--lw-color-dark); }
.lw-summary-address {
  font-size: 12.5px;
  color: #5c6b6d;
  margin-top: 2px;
}

/* --- Booking confirmation card --- */
.lw-confirm-card {
  align-self: flex-start;
  max-width: 88%;
  background: #f3fbf6;
  border: 1px solid #cdeedb;
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 12px 14px;
}
.lw-confirm-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e8a52;
  margin-bottom: 8px;
}
.lw-confirm-receipt {
  background: #ffffff;
  border: 1px solid #dcf1e5;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  color: #5c6b6d;
  display: flex;
  flex-direction: column;
  gap: 3px;
  word-break: break-word;
  overflow-wrap: break-word;
}
.lw-confirm-receipt div {
  word-break: break-word;
  overflow-wrap: break-word;
}
.lw-confirm-receipt strong {
  color: #1c2b33;
  font-weight: 600;
  word-break: break-all;
  overflow-wrap: break-word;
}
.lw-confirm-note {
  font-size: 12px;
  color: #4c5e61;
  margin-top: 9px;
  line-height: 1.4;
}
.lw-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.lw-confirm-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  padding: 9px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.lw-confirm-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.lw-confirm-btn-wa {
  background: #25d366;
  color: #fff;
}
.lw-confirm-btn-wa:hover { background: #1fb958; }
.lw-confirm-btn-email {
  background: #eef1f2;
  color: #37474a;
  border: 1px solid #dfe4e5;
}
.lw-confirm-btn-email:hover { background: #e2e7e8; }

/* --- Suggested topic chips (shown alongside the greeting) --- */
.lw-suggested-topics {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  align-self: flex-start;
  max-width: 88%;
}
.lw-suggested-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #7c8f93;
  margin-bottom: 2px;
}
.lw-suggested-topic {
  background: #ffffff;
  border: 1.5px solid var(--lw-color);
  color: var(--lw-color);
  border-radius: 16px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.lw-suggested-topic:hover { background: #eef8f8; }

#lw-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e5edee;
  background: #fff;
}
#lw-input {
  flex: 1;
  border: 1.5px solid #dfe9ea;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
}
#lw-input:focus { border-color: var(--lw-color); }
#lw-send {
  border: none;
  background: var(--lw-color);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#lw-send:disabled { opacity: 0.5; cursor: default; }
#lw-send svg { width: 16px; height: 16px; }

@media (max-width: 420px) {
  #lw-window { width: calc(100vw - 32px); right: -4px; }
  #lw-root.lw-position-left #lw-window { left: -4px; right: auto; }
}
