/* Longshore Smart Business — website assistant widget.
   Themeable via CSS custom properties; override --ls-* on :root (or on
   .ls-assistant directly) in the embedding page per client. Defaults below
   match Longshore's own live palette (styles.css: sand/foam/pine/dune/tide). */

.ls-assistant {
  --ls-primary: #22301F;   /* pine */
  --ls-accent: #B08A3E;    /* dune */
  --ls-bg: #F8F5EC;        /* foam */
  --ls-surface: #ffffff;
  --ls-text: #22301F;
  --ls-border: #22301F22;
  --ls-radius: 14px;
  --ls-font: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-family: var(--ls-font);
  position: fixed;
  right: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vw, 28px);
  z-index: 2147483000;
}

/* Defensive reset: this widget is embedded on host pages with their own
   CSS (e.g. a generic `section{padding:...}` rule on the host site leaking
   into our own <section class="ls-assistant-panel">, once found silently
   squeezing the message area down to ~28px tall on the live site). Every
   spacing value the widget actually wants is set explicitly below, so
   zeroing everything here first is safe. */
.ls-assistant *,
.ls-assistant *::before,
.ls-assistant *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.ls-assistant-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  border: none;
  background: var(--ls-primary);
  color: #fff;
  font-family: var(--ls-font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
}
.ls-assistant-toggle:hover { transform: translateY(-1px); }
.ls-assistant-toggle:focus-visible,
.ls-assistant-close:focus-visible,
.ls-assistant-chip:focus-visible,
.ls-assistant-input:focus-visible,
.ls-assistant-send:focus-visible {
  outline: 3px solid var(--ls-accent);
  outline-offset: 2px;
}

.ls-assistant-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(360px, calc(100vw - 24px));
  max-height: min(520px, 70vh);
  background: var(--ls-surface);
  border-radius: var(--ls-radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ls-border);
}
/* The [hidden] attribute drives open/closed state — without this override,
   the class's own `display:flex` above wins and the panel never hides. */
.ls-assistant-panel[hidden] { display: none; }

.ls-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--ls-primary);
  color: #fff;
  font-weight: 600;
}
.ls-assistant-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.ls-assistant-close:hover { background: rgba(255, 255, 255, 0.15); }

.ls-assistant-disclosure {
  margin: 0;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--ls-text);
  opacity: 0.7;
  background: var(--ls-bg);
  border-bottom: 1px solid var(--ls-border);
}

.ls-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ls-surface);
}

.ls-assistant-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.ls-assistant-msg-user {
  align-self: flex-end;
  background: var(--ls-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ls-assistant-msg-bot {
  align-self: flex-start;
  background: var(--ls-bg);
  color: var(--ls-text);
  border-bottom-left-radius: 4px;
}
.ls-assistant-thinking { opacity: 0.6; }

.ls-assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}
.ls-assistant-chip {
  border: 1px solid var(--ls-border);
  background: var(--ls-surface);
  color: var(--ls-text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--ls-font);
}
.ls-assistant-chip:hover { border-color: var(--ls-accent); }

.ls-assistant-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--ls-border);
  background: var(--ls-surface);
}
.ls-assistant-input {
  flex: 1;
  border: 1px solid var(--ls-border);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--ls-font);
  color: var(--ls-text);
}
.ls-assistant-send {
  border: none;
  background: var(--ls-accent);
  color: #fff;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--ls-font);
}
.ls-assistant-mic {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ls-border);
  background: var(--ls-surface);
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ls-assistant-mic[hidden] { display: none; }
.ls-assistant-mic.is-listening {
  background: var(--ls-accent);
  border-color: var(--ls-accent);
  animation: ls-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes ls-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(0, 0, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .ls-assistant-mic.is-listening { animation: none; }
}
.ls-assistant-hp {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .ls-assistant-toggle { transition: none; }
}

@media (max-width: 480px) {
  .ls-assistant { right: 10px; bottom: 10px; }
  .ls-assistant-panel { width: calc(100vw - 20px); }
}
