/*
 * AI Chatbot widget styles. No framework, no external fonts, no Elementor/jQuery dependency.
 * Customize by overriding the CSS variables below (e.g. in Customizer > Additional CSS).
 */
/* Palette taken from theholidave.com: teal #0A5B66, orange #FB5B32, green #25D366, warm grey #F2F2F0 / #E2E2DE, Inter. */
:root {
  --ai-chat-primary: #0a5b66;        /* header, launcher, user bubble */
  --ai-chat-primary-text: #ffffff;
  --ai-chat-accent: #fb5b32;         /* send button, focus ring, accents */
  --ai-chat-accent-text: #1a1a1a;    /* white on this orange fails contrast, so dark text */
  --ai-chat-online: #25d366;         /* status dot */
  --ai-chat-background: #ffffff;
  --ai-chat-user: #0a5b66;
  --ai-chat-user-text: #ffffff;
  --ai-chat-bot: #f2f2f0;
  --ai-chat-border: #e2e2de;
  --ai-chat-input-border: #8a918f;
  --ai-chat-text: #1a1a1a;
  --ai-chat-muted: #57605f;
  --ai-chat-link: #0a5b66;
  --ai-chat-focus: #0a5b66;
  --ai-chat-error-bg: #fef2f2;
  --ai-chat-error-text: #991b1b;
  --ai-chat-shadow: 10, 91, 102;     /* RGB of primary, used for shadows */
  --ai-chat-radius: 12px;
  --ai-chat-z: 99999;
  --ai-chat-font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ai-chatbot-root,
.ai-chatbot-root *,
.ai-chatbot-root *::before,
.ai-chatbot-root *::after {
  box-sizing: border-box;
}

.ai-chatbot-root {
  font-family: var(--ai-chat-font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ai-chat-text);
}

.ai-chatbot-root [hidden] {
  display: none !important;
}

/* Visually hidden, still read by screen readers */
.ai-chatbot-root .ai-chat-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Buttons: neutralize theme styles */
.ai-chatbot-root button,
.ai-chatbot-root textarea {
  margin: 0;
  font-family: inherit;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Focus */
.ai-chatbot-root button:focus-visible,
.ai-chatbot-root textarea:focus-visible,
.ai-chatbot-root .ai-chat-messages:focus-visible,
.ai-chatbot-root .ai-chat-link:focus-visible {
  outline: 3px solid var(--ai-chat-focus);
  outline-offset: 2px;
}

.ai-chatbot-root .ai-chat-header button:focus-visible {
  outline-color: #ffffff;
}

/* Launcher sits on arbitrary page colors: orange ring keeps it visible */
.ai-chatbot-root .ai-chat-launcher:focus-visible {
  outline-color: var(--ai-chat-accent);
}

/* Launcher */
.ai-chatbot-root .ai-chat-launcher {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: var(--ai-chat-z);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ai-chat-primary);
  color: var(--ai-chat-primary-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(var(--ai-chat-shadow), 0.34), 0 2px 6px rgba(var(--ai-chat-shadow), 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ai-chatbot-root .ai-chat-launcher:hover {
  background: var(--ai-chat-primary);
  color: var(--ai-chat-primary-text);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(var(--ai-chat-shadow), 0.38), 0 3px 8px rgba(var(--ai-chat-shadow), 0.22);
}

/* Window */
.ai-chatbot-root .ai-chat-window {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: var(--ai-chat-z);
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 600px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  background: var(--ai-chat-background);
  color: var(--ai-chat-text);
  border: 1px solid var(--ai-chat-border);
  border-radius: var(--ai-chat-radius);
  box-shadow: 0 24px 60px rgba(var(--ai-chat-shadow), 0.28), 0 4px 12px rgba(var(--ai-chat-shadow), 0.12);
  animation: ai-chat-pop 0.18s ease-out;
}

.ai-chatbot-root .ai-chat-window.is-minimized {
  height: auto;
}

.ai-chatbot-root .ai-chat-window.is-minimized .ai-chat-messages,
.ai-chatbot-root .ai-chat-window.is-minimized .ai-chat-form {
  display: none;
}

/* Header */
.ai-chatbot-root .ai-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: var(--ai-chat-primary);
  color: var(--ai-chat-primary-text);
}

.ai-chatbot-root .ai-chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.ai-chatbot-root .ai-chat-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-chatbot-root .ai-chat-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chatbot-root .ai-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.9);
}

.ai-chatbot-root .ai-chat-status::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ai-chat-online);
}

.ai-chatbot-root .ai-chat-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

.ai-chatbot-root .ai-chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ai-chat-primary-text);
  cursor: pointer;
}

.ai-chatbot-root .ai-chat-icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--ai-chat-primary-text);
}

/* Messages */
.ai-chatbot-root .ai-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--ai-chat-background);
}

.ai-chatbot-root .ai-chat-msg {
  position: relative;
  display: flex;
  max-width: 100%;
}

.ai-chatbot-root .ai-chat-msg--user {
  justify-content: flex-end;
}

.ai-chatbot-root .ai-chat-msg--system,
.ai-chatbot-root .ai-chat-msg--error {
  justify-content: center;
}

.ai-chatbot-root .ai-chat-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-chatbot-root .ai-chat-msg--bot .ai-chat-bubble {
  background: var(--ai-chat-bot);
  color: var(--ai-chat-text);
  border-bottom-left-radius: 4px;
}

.ai-chatbot-root .ai-chat-msg--user .ai-chat-bubble {
  background: var(--ai-chat-user);
  color: var(--ai-chat-user-text);
  border-bottom-right-radius: 4px;
}

.ai-chatbot-root .ai-chat-msg--system .ai-chat-bubble {
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--ai-chat-border);
  border-radius: 999px;
  background: var(--ai-chat-background);
  color: var(--ai-chat-muted);
  font-size: 13px;
  text-align: center;
}

.ai-chatbot-root .ai-chat-msg--error .ai-chat-bubble {
  max-width: 100%;
  background: var(--ai-chat-error-bg);
  color: var(--ai-chat-error-text);
  border: 1px solid #fecaca;
  font-size: 14px;
}

.ai-chatbot-root .ai-chat-link {
  color: var(--ai-chat-link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Typing */
.ai-chatbot-root .ai-chat-typing .ai-chat-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ai-chat-muted);
  font-size: 14px;
}

.ai-chatbot-root .ai-chat-dots {
  display: inline-flex;
  gap: 4px;
}

.ai-chatbot-root .ai-chat-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-chat-muted);
  animation: ai-chat-bounce 1.2s infinite ease-in-out;
}

.ai-chatbot-root .ai-chat-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-chatbot-root .ai-chat-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Form */
.ai-chatbot-root .ai-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--ai-chat-border);
  background: var(--ai-chat-background);
}

.ai-chatbot-root .ai-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--ai-chat-input-border);
  border-radius: 8px;
  background: var(--ai-chat-background);
  color: var(--ai-chat-text);
  font-size: 16px; /* prevents iOS zoom on focus */
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
  box-shadow: none;
}

.ai-chatbot-root .ai-chat-input:focus {
  border-color: var(--ai-chat-primary);
}

.ai-chatbot-root .ai-chat-input::placeholder {
  color: var(--ai-chat-muted);
  opacity: 1;
}

.ai-chatbot-root .ai-chat-send {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--ai-chat-accent);
  color: var(--ai-chat-accent-text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.ai-chatbot-root .ai-chat-send:hover:not(:disabled) {
  background: var(--ai-chat-accent);
  color: var(--ai-chat-accent-text);
  filter: brightness(1.08);
}

.ai-chatbot-root .ai-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile: nearly full screen, safe spacing, no overflow */
@media (max-width: 480px) {
  .ai-chatbot-root .ai-chat-window {
    right: 8px;
    left: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .ai-chatbot-root .ai-chat-bubble {
    max-width: 90%;
  }

  .ai-chatbot-root .ai-chat-launcher {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes ai-chat-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes ai-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-chatbot-root .ai-chat-window,
  .ai-chatbot-root .ai-chat-launcher,
  .ai-chatbot-root .ai-chat-dots span {
    animation: none !important;
    transition: none !important;
  }
}
