/*
 * Lessimp Sales Chat Widget — vanilla CSS, no dependencies.
 * Loaded by web/landing.html and web/index.html.
 *
 * State is toggled via data-* attributes from sales-chat.js:
 *   data-open="true"          on .lessimp-chat-popup → visible
 *   data-hidden="true"        on inner panels        → hidden
 *
 * Brand red #EA3A47 matches transactional emails in
 * visitor-chat-service.ts:70,79,118,131.
 */

/* ─── Launcher (collapsed bubble) ─────────────────────────── */
.lessimp-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #EA3A47;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  transition: transform 0.18s ease;
}
.lessimp-chat-launcher:hover {
  transform: scale(1.06);
}
.lessimp-chat-launcher[aria-expanded="true"] {
  display: none;
}

/* ─── Popup (expanded) ────────────────────────────────────── */
.lessimp-chat-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #222;
}
.lessimp-chat-popup[data-open="true"] {
  display: flex;
}

@media (max-width: 600px) {
  .lessimp-chat-popup {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
}

/* ─── Header ──────────────────────────────────────────────── */
.lessimp-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #eee;
}
.lessimp-chat-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.lessimp-chat-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.lessimp-chat-close:hover {
  color: #222;
}

.lessimp-chat-subtitle {
  padding: 0 20px 12px;
  font-size: 14px;
  color: #666;
  margin: 0;
}

/* ─── 4 CTA buttons (initial menu) ────────────────────────── */
.lessimp-chat-cta-row {
  padding: 4px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lessimp-chat-cta-row[data-hidden="true"] {
  display: none;
}
.lessimp-chat-cta {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: #222;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.lessimp-chat-cta:hover {
  background: #f7f7f7;
  border-color: #ccc;
}

/* ─── Message list (visitor right, AI left) ───────────────── */
.lessimp-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
  max-height: 300px;
}
.lessimp-chat-messages[data-hidden="true"] {
  display: none;
}

.msg-visitor {
  align-self: flex-end;
  background: #EA3A47;
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 85%;
  word-wrap: break-word;
}
.msg-ai {
  align-self: flex-start;
  background: #fff;
  color: #222;
  border: 1px solid #eee;
  border-radius: 14px 14px 14px 4px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 85%;
  word-wrap: break-word;
}
.msg-ai-typing {
  align-self: flex-start;
  color: #888;
  font-style: italic;
  padding: 8px 12px;
  font-size: 14px;
}

/* ─── Consent gate (above composer, pre-first-message) ───── */
.lessimp-chat-consent {
  padding: 12px 20px;
  font-size: 12px;
  color: #666;
  line-height: 1.4;
  border-top: 1px solid #eee;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fff;
}
.lessimp-chat-consent[data-hidden="true"] {
  display: none;
}
.lessimp-chat-consent input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}
.lessimp-chat-consent a {
  color: #EA3A47;
  text-decoration: underline;
}

/* ─── Composer ────────────────────────────────────────────── */
.lessimp-chat-composer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid #eee;
  background: #fff;
}
.lessimp-chat-composer[data-hidden="true"] {
  display: none;
}
.lessimp-chat-composer input[type="text"] {
  flex: 1 1 auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.lessimp-chat-composer input[type="text"]:focus {
  border-color: #EA3A47;
}
.lessimp-chat-send {
  background: #EA3A47;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease;
}
.lessimp-chat-send:disabled {
  background: #c0c0c0;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ─── Inline escalation contact form ───────────────────── */
.lessimp-chat-escalation {
  padding: 12px 20px;
  background: #fff9f0;
  border-top: 1px solid #f0e0c0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #555;
}
.lessimp-chat-escalation[data-hidden="true"] {
  display: none;
}
.lessimp-chat-escalation input[type="email"],
.lessimp-chat-escalation input[type="text"] {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.lessimp-chat-escalation button {
  background: #EA3A47;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* ─── Error toast ────────────────────────────────────────── */
.lessimp-chat-error {
  padding: 8px 20px;
  background: #fff0f0;
  color: #b00020;
  font-size: 13px;
  border-top: 1px solid #f0c0c0;
}
.lessimp-chat-error[data-hidden="true"] {
  display: none;
}

/* ─── Footer ─────────────────────────────────────────────── */
.lessimp-chat-footer {
  padding: 8px 20px 10px;
  font-size: 11px;
  color: #999;
  text-align: center;
  background: #fafafa;
  border-top: 1px solid #eee;
}
.lessimp-chat-footer a {
  color: #999;
  text-decoration: underline;
}
