/* Speed Up Academy - AI receptionist chat widget
   Self-contained styles. Reads the host page's own --teal/--navy custom
   properties where available so the widget matches each page's palette,
   with safe fallbacks for pages that don't define them. */

#su-chat-root {
  --su-teal: var(--teal, #00C9B1);
  --su-teal-dark: var(--teal-dark, #00A89A);
  --su-navy: var(--navy, #0B1A2E);
  --su-navy-mid: var(--navy-mid, #112240);
  --su-white: var(--white, #ffffff);
  position: fixed;
  z-index: 999; /* above page sticky bars (e.g. camps.html mobile booking bar, z-index 300) */
  /* The floating WhatsApp button was removed on 2026-11-20, so the chat
     button now takes its place in the bottom corner. WhatsApp is still
     reachable from each page's own links and from inside the chat. */
  bottom: 24px;
  right: 24px;
  font-family: 'DM Sans', sans-serif;
}

html[dir="rtl"] #su-chat-root {
  right: auto;
  left: 24px;
  font-family: 'Cairo', sans-serif;
}

#su-chat-toggle {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--su-teal), var(--su-teal-dark));
  color: var(--su-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 180, 160, 0.38);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#su-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 180, 160, 0.48);
}

#su-chat-toggle:focus-visible {
  outline: 2px solid var(--su-white);
  outline-offset: 3px;
}

#su-chat-toggle svg {
  width: 26px;
  height: 26px;
}

#su-chat-toggle .su-icon-close {
  display: none;
}

#su-chat-root.su-open #su-chat-toggle .su-icon-chat {
  display: none;
}

#su-chat-root.su-open #su-chat-toggle .su-icon-close {
  display: block;
}

/* Small "ask us anything" nudge, shown briefly the first time a visitor
   sees the widget so the button is easy to notice without being loud. */
#su-chat-nudge {
  position: absolute;
  bottom: 8px;
  right: 68px;
  max-width: 180px;
  background: var(--su-white);
  color: var(--su-navy);
  font-size: 13px;
  line-height: 1.35;
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  animation: su-fade-in 0.3s ease;
}

html[dir="rtl"] #su-chat-nudge {
  right: auto;
  left: 68px;
}

#su-chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: min(70vh, 520px);
  background: var(--su-white);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: su-fade-in 0.18s ease;
}

html[dir="rtl"] #su-chat-panel {
  right: auto;
  left: 0;
}

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

@keyframes su-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.su-chat-header {
  background: linear-gradient(135deg, var(--su-navy), var(--su-navy-mid));
  color: var(--su-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.su-chat-header-text {
  flex: 1;
  min-width: 0;
}

.su-chat-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.su-chat-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}

.su-chat-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--su-white);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.su-chat-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.su-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f4f7fb;
}

.su-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.su-msg-assistant {
  align-self: flex-start;
  background: var(--su-white);
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

html[dir="rtl"] .su-msg-assistant {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}

.su-msg-user {
  align-self: flex-end;
  background: var(--su-teal);
  color: var(--su-navy);
  border-bottom-right-radius: 4px;
}

html[dir="rtl"] .su-msg-user {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 4px;
}

.su-msg-system {
  align-self: center;
  background: #fff7e6;
  color: #92650c;
  border: 1px solid #f3dca0;
  font-size: 12.5px;
  text-align: center;
}

.su-msg-error {
  align-self: flex-start;
  background: #fdecec;
  color: #a12a2a;
  border: 1px solid #f3c6c6;
}

.su-retry-btn {
  margin-top: 6px;
  display: inline-block;
  background: none;
  border: 1px solid #a12a2a;
  color: #a12a2a;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.su-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 11px 14px;
  background: var(--su-white);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
}

.su-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: su-typing-bounce 1.2s infinite ease-in-out;
}

.su-typing span:nth-child(2) { animation-delay: 0.15s; }
.su-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes su-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* WhatsApp handoff card inside the conversation */
.su-msg-handoff {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.su-handoff-btn {
  align-self: flex-start;
  display: inline-block;
  background: #25D366;
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  padding: 8px 12px;
  border-radius: 10px;
  white-space: normal;
}

.su-handoff-btn:hover {
  background: #1ebe5b;
}

.su-handoff-btn:focus-visible,
.su-chat-handoff-link:focus-visible {
  outline: 2px solid var(--su-navy);
  outline-offset: 2px;
}

.su-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e2e8f0;
  background: var(--su-white);
  flex-shrink: 0;
}

#su-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  max-height: 90px;
  color: #0f172a;
}

#su-chat-input:focus {
  outline: none;
  border-color: var(--su-teal);
}

.su-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--su-teal);
  color: var(--su-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* Quiet, always-available WhatsApp route under the input */
.su-chat-handoff-bar {
  flex-shrink: 0;
  padding: 0 12px 10px;
  background: var(--su-white);
  font-size: 11.5px;
  line-height: 1.4;
  color: #64748b;
  text-align: center;
}

.su-chat-handoff-link {
  color: #128C7E;
  font-weight: 600;
  text-decoration: underline;
}

.su-chat-send:disabled {
  opacity: 0.5;
  cursor: default;
}

.su-chat-send svg {
  width: 17px;
  height: 17px;
}

html[dir="rtl"] .su-chat-send svg {
  transform: scaleX(-1);
}

@media (max-width: 480px) {
  #su-chat-root {
    bottom: 16px;
    right: 16px;
  }

  html[dir="rtl"] #su-chat-root {
    left: 16px;
  }

  #su-chat-toggle {
    width: 52px;
    height: 52px;
  }

  #su-chat-panel {
    bottom: 64px;
    right: -8px;
    width: calc(100vw - 20px);
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
  }

  html[dir="rtl"] #su-chat-panel {
    left: -8px;
  }
}

/* camps.html has a fixed mobile booking bar (#mbar, shown below 760px).
   Keep the chat button clear of it there, as before. */
@media (max-width: 759px) {
  body:has(#mbar) #su-chat-root {
    bottom: 88px;
  }
}

@media (max-width: 480px) {
  body:has(#mbar) #su-chat-panel {
    height: calc(100vh - 212px);
    max-height: calc(100vh - 212px);
  }
}
