/* ============================================================
   Ellis Car Care — Wash Planner Chatbot styles
   ------------------------------------------------------------
   Reuses the dark theme tokens from styles.css.
   ============================================================ */

/* ---- Floating action button ---- */
.chat-fab {
  position: fixed;
  left: var(--s-4);
  bottom: calc(96px + var(--s-3));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 12px 14px;
  background: var(--accent);
  color: #0E1014;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  z-index: 60;
  border: 1px solid rgba(0,0,0,0.12);
}
.chat-fab:hover {
  transform: translateY(-1px);
  background: var(--accent-deep);
}
.chat-fab.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}
.chat-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(14, 16, 20, 0.12);
}
.chat-fab-label {
  white-space: nowrap;
}

@media (max-width: 540px) {
  .chat-fab {
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(96px + 8px);
  }
  .chat-fab:hover {
    transform: translateX(-50%) translateY(-1px);
  }
}

/* ---- Panel ---- */
.chat-panel {
  position: fixed;
  right: var(--s-4);
  bottom: calc(96px + var(--s-3));
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 140px));
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 70;
  transform: translateY(20px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.chat-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 540px) {
  .chat-panel {
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
}

/* ---- Header ---- */
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 14px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-head-id {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #0E1014;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
}
.chat-title {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.1;
}
.chat-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 2px 0 0;
  letter-spacing: 0.02em;
}
.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-restart {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.chat-restart:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--ink-soft);
  transition: color 0.18s, background 0.18s;
}
.chat-close:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

/* ---- Log ---- */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.chat-log::-webkit-scrollbar {
  width: 8px;
}
.chat-log::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 0.95rem;
  word-wrap: break-word;
  animation: msgIn 0.22s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-bot {
  align-self: flex-start;
  background: var(--surface-soft);
  color: var(--ink);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--line);
}
.msg-bot strong { color: var(--accent); font-weight: 600; }
.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #0E1014;
  font-weight: 500;
  border-bottom-right-radius: 6px;
}

/* ---- Controls ---- */
.chat-controls {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  max-height: 50%;
  overflow-y: auto;
}

.chat-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 16px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-align: center;
  transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-btn:hover {
  background: var(--surface-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chat-btn:active {
  transform: scale(0.97);
}
.chat-btn.is-primary {
  flex-basis: 100%;
  background: var(--accent);
  color: #0E1014;
  font-weight: 600;
  border-color: var(--accent);
}
.chat-btn.is-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #0E1014;
}
.chat-btn.is-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}
.chat-btn.is-ghost:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
  background: transparent;
}
.chat-btn.is-small {
  flex: 0 0 auto;
  font-size: 0.82rem;
  padding: 8px 14px;
}

/* ---- Free-text input ---- */
.chat-input-form {
  flex: 1 1 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.chat-input {
  flex: 1;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.16s;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-input::placeholder {
  color: var(--muted);
}
.chat-input-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #0E1014;
  transition: background 0.16s, transform 0.12s;
  flex-shrink: 0;
}
.chat-input-send:hover {
  background: var(--accent-deep);
}
.chat-input-send:active {
  transform: scale(0.94);
}

/* ---- Hide sticky CTA when chat is open on mobile, prevent body scroll ---- */
@media (max-width: 540px) {
  body.chat-open {
    overflow: hidden;
  }
  body.chat-open .sticky-cta {
    display: none;
  }
}

/* On desktop, nudge sticky CTA so it doesn't overlap the panel */
@media (min-width: 541px) {
  body.chat-open .sticky-cta {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }
}

/* ---- "Plan your wash" buttons elsewhere on the page ---- */
.plan-cta-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* Inline pricing-helper link */
.pricing-helper {
  margin-top: var(--s-5);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.pricing-helper .link-btn {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.18s;
}
.pricing-helper .link-btn:hover {
  color: var(--accent-deep);
}

/* ============================================================
   AI mode UI
   ============================================================ */

/* Photo button next to text input */
.ai-form {
  flex-wrap: nowrap;
}
.chat-photo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.16s, border-color 0.16s, background 0.16s, transform 0.12s;
}
.chat-photo-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.chat-photo-btn:active { transform: scale(0.94); }
.chat-photo-btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Attached photo chip */
.chat-photo-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  flex: 1 1 100%;
  margin-bottom: 6px;
  max-width: 100%;
}
.chat-photo-chip img {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-photo-chip-name {
  font-size: 0.85rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.chat-photo-chip-remove {
  width: 24px; height: 24px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}
.chat-photo-chip-remove:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

/* Mode switch link */
.chat-mode-switch {
  flex: 1 1 100%;
  text-align: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  padding: 6px 0 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(138, 133, 121, 0.4);
  text-underline-offset: 3px;
  transition: color 0.18s;
}
.chat-mode-switch:hover {
  color: var(--ink-soft);
  text-decoration-color: var(--ink-soft);
}

/* Typing indicator */
.msg-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  min-height: 22px;
  /* Don't apply the msg fade-in to the typing bubble — the dots should
     start animating instantly so users see the "thinking" feedback. */
  animation: none;
}
.typing-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: typingPulse 1.1s infinite ease-in-out;
  will-change: opacity, transform;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingPulse {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-4px); }
}

/* Drag-and-drop visual */
.chat-panel.chat-dropping {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}
.chat-panel.chat-dropping::after {
  content: "Drop the photo here";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 16, 20, 0.85);
  color: var(--accent);
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  z-index: 5;
  pointer-events: none;
}

/* Reduce motion — but KEEP the typing indicator animating, just gentler.
   The pulsing IS the feedback that the AI is thinking; if we kill it,
   the bubble looks indistinguishable from a regular message. */
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-fab, .msg, .chat-btn { transition: none; animation: none; }
  .typing-dot {
    /* Slower, opacity-only animation — accessibility-friendly */
    animation: typingPulseReduced 1.8s infinite ease-in-out;
  }
}
@keyframes typingPulseReduced {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}
