/* ============================================
   Orpheus Chatbot Widget
   Desktop: floating panel above the launcher.
   < 600px: full-screen sheet (same markup).
   ============================================ */

.chatbot-widget-container {
  --cb-brand: #0052CC;
  --cb-brand-dark: #003D99;
  --cb-brand-soft: #EBF2FF;
  --cb-text: #1E293B;
  --cb-muted: #64748B;
  --cb-border: #E2E8F0;
  --cb-surface: #FFFFFF;
  --cb-canvas: #F5F7FB;
  --cb-wa: #128C4B;
  --cb-radius: 20px;
  --cb-shadow: 0 24px 60px -12px rgba(0, 40, 100, 0.28), 0 4px 16px rgba(0, 40, 100, 0.08);
  --cb-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--cb-text);
  -webkit-font-smoothing: antialiased;
}

/* Neutralise the site's global p/li/span/a/h2 sizing inside the widget (:where keeps this easy to override) */
.chatbot-widget-container :where(p, li, span, a, h2, ul, ol, strong) {
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  padding: 0;
}

.chatbot-widget-container :where(button) {
  font-family: inherit;
}

.chatbot-widget-container svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.chatbot-widget-container svg.chatbot-icon-fill {
  fill: currentColor;
  stroke: none;
}

.chatbot-widget-container :focus-visible {
  outline: 3px solid rgba(0, 82, 204, 0.45);
  outline-offset: 2px;
}

/* =====================
   LAUNCHER
   ===================== */
.chatbot-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #0062E6 0%, var(--cb-brand) 45%, var(--cb-brand-dark) 100%);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 82, 204, 0.35);
  transition: transform 0.2s var(--cb-ease), box-shadow 0.2s var(--cb-ease);
}

.chatbot-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 28px rgba(0, 82, 204, 0.42);
}

.chatbot-launcher:active {
  transform: scale(0.96);
}

/* Attention ring — plays a few times, then stops */
.chatbot-launcher::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 82, 204, 0.35);
  animation: chatbotRing 2.4s ease-out 1.5s 3;
  opacity: 0;
  pointer-events: none;
}

@keyframes chatbotRing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.chatbot-launcher-logo,
.chatbot-launcher-close {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  transition: transform 0.25s var(--cb-ease), opacity 0.2s ease;
}

.chatbot-launcher-logo .chatbot-logo-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  object-fit: cover;
  display: block;
}

.chatbot-launcher-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.chatbot-launcher-close svg {
  width: 26px;
  height: 26px;
}

.chatbot-widget-container.is-open .chatbot-launcher-logo {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.chatbot-widget-container.is-open .chatbot-launcher-close {
  opacity: 1;
  transform: none;
}

.chatbot-widget-container.is-open .chatbot-launcher::before {
  animation: none;
}

/* Greeting nudge */
.chatbot-greeting {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: max-content;
  max-width: calc(100vw - 48px);
  padding: 10px 14px;
  border: 1px solid var(--cb-border);
  border-radius: 14px 14px 4px 14px;
  background: var(--cb-surface);
  color: var(--cb-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 40, 100, 0.14);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s var(--cb-ease);
}

.chatbot-greeting.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.chatbot-greeting:hover {
  border-color: var(--cb-brand);
}

/* =====================
   PANEL
   ===================== */
.chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 380px;
  height: min(620px, calc(100vh - 124px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cb-surface);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.25s var(--cb-ease);
}

.chatbot-panel[hidden] {
  display: none;
}

.chatbot-widget-container.is-open .chatbot-panel {
  opacity: 1;
  transform: none;
}

/* === Header === */
.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: linear-gradient(135deg, var(--cb-brand) 0%, var(--cb-brand-dark) 100%);
  color: #fff;
  flex-shrink: 0;
}

.chatbot-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.chatbot-avatar .chatbot-logo-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  object-fit: cover;
  display: block;
  background: #fff;
}

.chatbot-online {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid var(--cb-brand);
}

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

.chatbot-header .chatbot-title {
  margin: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.chatbot-header .chatbot-subtitle {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12.5px;
  line-height: 1.4;
}

.chatbot-icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chatbot-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.chatbot-icon-btn:focus-visible {
  outline-color: rgba(255, 255, 255, 0.8);
}

/* === Messages === */
.chatbot-messages {
  position: relative; /* offsetTop of rows is measured against this box */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 8px;
  background: var(--cb-canvas);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

.chatbot-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: chatbotRowIn 0.25s var(--cb-ease);
}

.chatbot-row-user {
  justify-content: flex-end;
}

@keyframes chatbotRowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.chatbot-row-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.chatbot-row-avatar .chatbot-logo-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--cb-border);
  object-fit: cover;
  display: block;
  background: #fff;
}

.chatbot-bubble {
  max-width: 82%;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.chatbot-row-bot .chatbot-bubble {
  background: var(--cb-surface);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chatbot-row-user .chatbot-bubble {
  background: var(--cb-brand);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  font-weight: 500;
}

.chatbot-bubble p + p,
.chatbot-bubble p + .chatbot-list,
.chatbot-bubble .chatbot-list + p,
.chatbot-bubble .chatbot-list + .chatbot-list {
  margin-top: 10px;
}

.chatbot-bubble strong {
  font-weight: 600;
  color: inherit;
}

.chatbot-bubble .chatbot-list {
  padding-left: 20px;
}

.chatbot-bubble .chatbot-list li + li {
  margin-top: 4px;
}

.chatbot-bubble .chatbot-list-check {
  list-style: none;
  padding-left: 0;
}

.chatbot-bubble .chatbot-list-check li {
  position: relative;
  padding-left: 24px;
}

.chatbot-bubble .chatbot-list-check li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cb-brand-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230052CC' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 10px no-repeat;
}

/* Links in bot replies render as small action buttons (Register / Login / WhatsApp) */
.chatbot-bubble a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--cb-brand);
  color: #fff !important;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none !important;
  transition: background 0.15s ease;
}

.chatbot-bubble a::after {
  content: '\2197';
  font-size: 12px;
}

.chatbot-bubble a:hover {
  background: var(--cb-brand-dark);
}

/* Typing indicator */
.chatbot-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.chatbot-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94A3B8;
  animation: chatbotTyping 1.2s infinite ease-in-out;
}

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

@keyframes chatbotTyping {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* === Quick replies (only the latest set is shown) === */
.chatbot-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 2px 0 6px 36px; /* line up with the bubble, past the avatar */
}

.chatbot-reply {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  background: var(--cb-surface);
  color: var(--cb-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  animation: chatbotReplyIn 0.3s var(--cb-ease) both;
  animation-delay: calc(var(--i, 0) * 50ms + 80ms);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@keyframes chatbotReplyIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.chatbot-reply-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--cb-brand-soft);
  color: var(--cb-brand);
}

.chatbot-reply-icon svg {
  width: 18px;
  height: 18px;
}

.chatbot-reply-label {
  flex: 1;
  min-width: 0;
}

.chatbot-reply-arrow {
  color: #94A3B8;
  display: grid;
  transition: transform 0.15s ease, color 0.15s ease;
}

.chatbot-reply-arrow svg {
  width: 18px;
  height: 18px;
}

.chatbot-reply:hover {
  border-color: var(--cb-brand);
  background: #FAFCFF;
  box-shadow: 0 4px 12px rgba(0, 82, 204, 0.1);
}

.chatbot-reply:hover .chatbot-reply-arrow {
  color: var(--cb-brand);
  transform: translateX(2px);
}

.chatbot-reply:active {
  transform: scale(0.98);
}

.chatbot-reply:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === Footer === */
.chatbot-footer {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface);
}

.chatbot-footer-actions {
  display: flex;
  gap: 8px;
}

.chatbot-footer-btn {
  flex: 1 1 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  background: var(--cb-surface);
  color: var(--cb-text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none !important;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chatbot-footer-btn[hidden] {
  display: none;
}

.chatbot-footer-btn svg {
  width: 18px;
  height: 18px;
}

.chatbot-footer-btn:hover {
  border-color: var(--cb-brand);
  color: var(--cb-brand);
}

.chatbot-footer-btn-wa {
  color: var(--cb-wa);
}

.chatbot-footer-btn-wa:hover {
  border-color: var(--cb-wa);
  background: #F0FBF4;
  color: var(--cb-wa);
}

.chatbot-footer .chatbot-powered-by {
  margin-top: 8px;
  text-align: center;
  color: var(--cb-muted);
  font-size: 11px;
  line-height: 1.4;
}

.chatbot-footer .chatbot-powered-by strong {
  color: var(--cb-brand);
  font-weight: 600;
}

/* =====================
   MOBILE: full-screen sheet
   ===================== */
@media (max-width: 599px) {
  .chatbot-widget-container {
    right: 16px;
    bottom: 16px;
  }

  .chatbot-launcher {
    width: 56px;
    height: 56px;
  }

  .chatbot-launcher-logo .chatbot-logo-img {
    width: 38px;
    height: 38px;
  }

  .chatbot-greeting {
    bottom: 68px;
  }

  .chatbot-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    transform-origin: bottom center;
    transform: translateY(24px);
  }

  .chatbot-header {
    padding-top: max(16px, calc(env(safe-area-inset-top) + 10px));
  }

  /* Launcher sits under the sheet while it is open — the header close button takes over */
  .chatbot-widget-container.is-open .chatbot-launcher,
  .chatbot-widget-container.is-open .chatbot-greeting {
    visibility: hidden;
  }

  .chatbot-bubble {
    font-size: 15px;
  }

  .chatbot-reply {
    font-size: 15px;
    min-height: 52px;
  }

  .chatbot-footer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

body.chatbot-scroll-lock {
  overflow: hidden;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .chatbot-widget-container *,
  .chatbot-widget-container *::before,
  .chatbot-widget-container *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
