/* LeadBurrow chat widget styles */
/*
 * --leadburrow-accent and --leadburrow-accent-text are the brand color knobs the WP plugin
 * overrides via inline style. Defaults match the original solid-black look.
 *
 * Selectors are scoped to #leadburrow-chat-widget so hostile WP themes that target
 * raw tag selectors (button, input, h2, etc.) can't bleed into the widget.
 * Each top-level container also resets inherited properties with `all: revert`
 * so a theme's universal `* { font-family: ... !important }` won't follow
 * through. WordPress's own theme.css uses `!important` on buttons surprisingly
 * often, so we further pin button styles with the parent #-id specificity.
 */
:root {
  --leadburrow-accent: #111;
  --leadburrow-accent-text: #fff;
}

#leadburrow-chat-widget,
#leadburrow-chat-widget * {
  box-sizing: border-box;
}

#leadburrow-chat-widget .leadburrow-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: #111;
}

#leadburrow-chat-widget .leadburrow-bubble {
  all: revert;
  display: inline-block;
  background: var(--leadburrow-accent);
  color: var(--leadburrow-accent-text);
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  text-transform: none;
  letter-spacing: normal;
}
#leadburrow-chat-widget .leadburrow-bubble:hover { filter: brightness(0.9); }
/* Mouse click on the bubble leaked the browser's default focus ring
   (Firefox 2px blue) as a "stray triangle" peeking from the rounded
   corner. Strip it on :focus, restore a clean halo on :focus-visible
   so keyboard users still get a focus indicator. */
#leadburrow-chat-widget .leadburrow-bubble:focus { outline: none; }
#leadburrow-chat-widget .leadburrow-bubble:focus-visible {
  outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18), 0 0 0 3px rgba(255, 255, 255, 0.7);
}

#leadburrow-chat-widget .leadburrow-panel {
  display: none;
  flex-direction: column;
  width: 360px;
  height: 520px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid #e5e7eb;
}
#leadburrow-chat-widget .leadburrow-panel.leadburrow-panel-open { display: flex; }

#leadburrow-chat-widget .leadburrow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--leadburrow-accent);
  color: var(--leadburrow-accent-text);
  padding: 12px 16px;
}
#leadburrow-chat-widget .leadburrow-title { font-weight: 600; font-size: 14px; }
#leadburrow-chat-widget .leadburrow-header-actions { display: flex; align-items: center; gap: 4px; }
#leadburrow-chat-widget .leadburrow-close,
#leadburrow-chat-widget .leadburrow-download {
  all: revert;
  background: transparent;
  color: var(--leadburrow-accent-text);
  border: none;
  font-family: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
#leadburrow-chat-widget .leadburrow-close { font-size: 22px; }
#leadburrow-chat-widget .leadburrow-download:disabled { opacity: 0.4; cursor: not-allowed; }

#leadburrow-chat-widget .leadburrow-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
}
#leadburrow-chat-widget .leadburrow-msg {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
#leadburrow-chat-widget .leadburrow-msg-user {
  background: var(--leadburrow-accent);
  color: var(--leadburrow-accent-text);
  margin-left: auto;
}
#leadburrow-chat-widget .leadburrow-msg-assistant {
  background: #fff;
  color: #111;
  border: 1px solid #e5e7eb;
}
#leadburrow-chat-widget .leadburrow-msg-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

#leadburrow-chat-widget .leadburrow-consent {
  margin: 12px 16px 4px;
  padding: 8px 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #4b5563;
}
#leadburrow-chat-widget .leadburrow-consent a { color: #2563eb; text-decoration: underline; }

#leadburrow-chat-widget .leadburrow-typing {
  align-self: flex-start;
  background: #f3f4f6;
  color: #111;
  padding: 12px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  max-width: 60px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin: 4px 12px;
}
#leadburrow-chat-widget .leadburrow-typing-dot {
  width: 7px;
  height: 7px;
  background: #6b7280;
  border-radius: 50%;
  animation: leadburrow-typing-bounce 1.2s infinite ease-in-out;
}
#leadburrow-chat-widget .leadburrow-typing-dot:nth-child(2) { animation-delay: 0.15s; }
#leadburrow-chat-widget .leadburrow-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes leadburrow-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-4px); opacity: 1; }
}

#leadburrow-chat-widget .leadburrow-input-row {
  display: flex;
  padding: 8px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
#leadburrow-chat-widget .leadburrow-input {
  all: revert;
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: #111;
}
#leadburrow-chat-widget .leadburrow-input:focus { border-color: var(--leadburrow-accent); }
#leadburrow-chat-widget .leadburrow-input:disabled { background: #f3f4f6; color: #9ca3af; }

#leadburrow-chat-widget .leadburrow-send {
  all: revert;
  margin-left: 6px;
  padding: 10px 16px;
  background: var(--leadburrow-accent);
  color: var(--leadburrow-accent-text);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
}
#leadburrow-chat-widget .leadburrow-send:hover { filter: brightness(0.9); }
#leadburrow-chat-widget .leadburrow-send:disabled { background: #9ca3af; cursor: not-allowed; filter: none; }

#leadburrow-chat-widget .leadburrow-start-over {
  all: revert;
  display: block;
  margin: 0 12px 12px;
  padding: 8px 12px;
  background: transparent;
  color: #2563eb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  text-transform: none;
  letter-spacing: normal;
}
#leadburrow-chat-widget .leadburrow-start-over:hover { background: #f3f4f6; }

/* Mobile: fill the viewport so the panel header (with the X close button)
 * is always reachable. `dvh` tracks the *current* visible viewport, unlike
 * `vh` which is pinned to the largest viewport on iOS Safari and pushes
 * the header off-screen whenever the URL bar is visible. `vh` stays as a
 * fallback for the rare browser without dvh support. */
@media (max-width: 480px) {
  #leadburrow-chat-widget .leadburrow-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }
  /* When the panel is open, stretch the container top-to-bottom so the
   * panel can fill the visible viewport. Closed state keeps the bubble
   * anchored bottom-right. */
  #leadburrow-chat-widget .leadburrow-container:has(.leadburrow-panel-open) {
    top: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  #leadburrow-chat-widget .leadburrow-panel {
    width: auto;
    height: 90vh;
    height: 100%;
    max-height: 100%;
    border-radius: 12px;
    margin-bottom: 0;
  }
  /* Anchor the bubble to the right edge regardless of position knob,
   * since we widened the container above. */
  #leadburrow-chat-widget .leadburrow-bubble {
    float: right;
  }
  /* On mobile the panel fills most of the viewport, so the bubble peeking
   * out below it looks broken. Hide it once the panel is open; the X in
   * the header is the close affordance. */
  #leadburrow-chat-widget .leadburrow-container:has(.leadburrow-panel-open) .leadburrow-bubble {
    display: none;
  }
}
