/* =========================================================================
   FOUND HOUSE DIGITAL — CHAT WIDGET STYLES
   Reuses the site's :root custom properties defined in css/style.css.
   Sections: launcher, panel, header, messages, typing indicator, chips,
   input row, lead-capture card, mobile, reduced motion.
   ========================================================================= */

#fhd-chat-root {
  position: fixed;
  z-index: 999999;
  right: var(--space-md, 1.5rem);
  bottom: var(--space-md, 1.5rem);
  font-family: var(--font-body, system-ui, sans-serif);
}

/* ---------- Launcher ---------- */
.fhd-chat-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-surface, #141A19);
  border: 1px solid var(--color-border-strong, rgba(255,255,255,0.16));
  color: var(--color-accent-strong, #2DD4BF);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 34px -10px rgba(0,0,0,0.55);
  cursor: pointer;
  transition: transform var(--dur-fast, 0.2s) var(--ease-out, ease), border-color var(--dur-fast, 0.2s) var(--ease-out, ease);
}
.fhd-chat-launcher:hover {
  transform: scale(1.08);
  border-color: var(--color-accent, #14B8A6);
}
.fhd-chat-launcher svg { width: 26px; height: 26px; }
.fhd-chat-launcher .fhd-close-icon { display: none; }
#fhd-chat-root.is-open .fhd-chat-launcher .fhd-chat-icon { display: none; }
#fhd-chat-root.is-open .fhd-chat-launcher .fhd-close-icon { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .fhd-chat-launcher {
    animation: fhd-pulse 3.2s ease-in-out infinite;
  }
  .fhd-chat-launcher:hover,
  #fhd-chat-root.is-open .fhd-chat-launcher {
    animation: none;
  }
}
@keyframes fhd-pulse {
  0%, 100% { box-shadow: 0 10px 34px -10px rgba(0,0,0,0.55), 0 0 0 0 rgba(20,184,166,0.35); }
  50% { box-shadow: 0 10px 34px -10px rgba(0,0,0,0.55), 0 0 0 10px rgba(20,184,166,0); }
}

/* ---------- Panel ---------- */
.fhd-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(60px + var(--space-sm, 1rem));
  width: 360px;
  max-width: calc(100vw - 2rem);
  height: 500px;
  max-height: calc(100vh - 140px);
  background: var(--color-bg, #0B0F0E);
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 30px 70px -20px rgba(0,0,0,0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transform-origin: bottom right;
}
#fhd-chat-root.is-open .fhd-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (prefers-reduced-motion: no-preference) {
  .fhd-chat-panel {
    transition: opacity var(--dur-med, 0.5s) var(--ease-out, ease),
                transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .fhd-chat-panel { transition: opacity var(--dur-fast, 0.2s) linear; }
}

/* ---------- Header ---------- */
.fhd-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm, 1rem);
  padding: var(--space-sm, 1rem) var(--space-md, 1.5rem);
  border-bottom: 1px solid var(--color-border, rgba(255,255,255,0.08));
  background: var(--color-surface, #141A19);
  flex-shrink: 0;
}
.fhd-chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading, sans-serif);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--color-text, #F4F2ED);
}
.fhd-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success, #4ADE80);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
  flex-shrink: 0;
}
.fhd-chat-header-sub {
  font-size: 0.76rem;
  color: var(--color-text-faint, rgba(244,242,237,0.42));
  margin-top: 2px;
}
.fhd-chat-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted, rgba(244,242,237,0.66));
  flex-shrink: 0;
}
.fhd-chat-close:hover { color: var(--color-text, #F4F2ED); background: rgba(255,255,255,0.06); }
.fhd-chat-close svg { width: 16px; height: 16px; }

/* ---------- Message list ---------- */
.fhd-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 1rem);
}
.fhd-msg {
  max-width: 82%;
  padding: 0.65em 0.9em;
  border-radius: var(--radius-md, 12px);
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.fhd-msg.fhd-msg-user {
  align-self: flex-end;
  background: var(--color-accent, #14B8A6);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.fhd-msg.fhd-msg-model {
  align-self: flex-start;
  background: var(--color-surface-raised, #1B2322);
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
  color: var(--color-text, #F4F2ED);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.fhd-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.7em 0.9em;
  border-radius: var(--radius-md, 12px);
  border-bottom-left-radius: 4px;
  background: var(--color-surface-raised, #1B2322);
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
}
.fhd-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-faint, rgba(244,242,237,0.42));
}
@media (prefers-reduced-motion: no-preference) {
  .fhd-typing span { animation: fhd-bounce 1.1s ease-in-out infinite; }
  .fhd-typing span:nth-child(2) { animation-delay: 0.15s; }
  .fhd-typing span:nth-child(3) { animation-delay: 0.3s; }
}
@keyframes fhd-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Suggested question chips ---------- */
.fhd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 var(--space-md, 1.5rem) var(--space-sm, 1rem);
  flex-shrink: 0;
}
.fhd-chips[hidden] { display: none; }
.fhd-chip {
  font-size: 0.76rem;
  padding: 0.45em 0.85em;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--color-border-strong, rgba(255,255,255,0.16));
  color: var(--color-text-muted, rgba(244,242,237,0.66));
  background: transparent;
  white-space: nowrap;
}
.fhd-chip:hover {
  border-color: var(--color-accent-strong, #2DD4BF);
  color: var(--color-accent-strong, #2DD4BF);
}

/* ---------- Lead-capture card ---------- */
.fhd-lead-card {
  align-self: stretch;
  border: 1px solid var(--color-border-strong, rgba(255,255,255,0.16));
  border-radius: var(--radius-md, 12px);
  padding: var(--space-sm, 1rem);
  background: var(--color-surface, #141A19);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs, 0.5rem);
}
.fhd-lead-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-text-muted, rgba(244,242,237,0.66));
}
.fhd-lead-links {
  display: flex;
  gap: var(--space-sm, 1rem);
}
.fhd-lead-links a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--color-text-muted, rgba(244,242,237,0.66));
  transition: transform var(--dur-fast, 0.2s) var(--ease-out, ease), color var(--dur-fast, 0.2s) var(--ease-out, ease);
}
.fhd-lead-links a svg { width: 22px; height: 22px; }
.fhd-lead-links a:hover { color: var(--color-accent-strong, #2DD4BF); }
@media (prefers-reduced-motion: no-preference) {
  .fhd-lead-links a:hover { transform: scale(1.1); }
}

/* ---------- Input row ---------- */
.fhd-chat-inputrow {
  display: flex;
  align-items: center;
  gap: var(--space-2xs, 0.5rem);
  padding: var(--space-sm, 1rem);
  border-top: 1px solid var(--color-border, rgba(255,255,255,0.08));
  background: var(--color-surface, #141A19);
  flex-shrink: 0;
}
.fhd-chat-input {
  flex: 1;
  background: var(--color-surface-raised, #1B2322);
  border: 1px solid var(--color-border-strong, rgba(255,255,255,0.16));
  border-radius: var(--radius-pill, 999px);
  padding: 0.65em 1em;
  color: var(--color-text, #F4F2ED);
  font-size: 0.88rem;
  font-family: inherit;
}
.fhd-chat-input::placeholder { color: var(--color-text-faint, rgba(244,242,237,0.42)); }
.fhd-chat-input:focus { outline: 2px solid var(--color-accent, #14B8A6); outline-offset: 2px; }
.fhd-chat-input:disabled { opacity: 0.6; }

.fhd-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-accent, #14B8A6);
  color: #05100E;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--dur-fast, 0.2s) var(--ease-out, ease), opacity var(--dur-fast, 0.2s) var(--ease-out, ease);
}
.fhd-chat-send svg { width: 16px; height: 16px; }
.fhd-chat-send:hover:not(:disabled) { transform: scale(1.08); }
.fhd-chat-send:disabled { opacity: 0.5; cursor: default; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  #fhd-chat-root {
    right: var(--space-sm, 1rem);
    bottom: max(var(--space-sm, 1rem), env(safe-area-inset-bottom));
  }
  .fhd-chat-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .fhd-chat-launcher {
    position: relative;
    z-index: 2;
  }
}
