/* ============================================================
   LHS Web Chatbot — UI
   ============================================================ */

:root {
  --lhs-green:       #2d7a4f;
  --lhs-green-dark:  #1e5c3a;
  --lhs-green-light: #e8f5ee;
  --lhs-accent:      #f0a500;
  --lhs-white:       #ffffff;
  --lhs-gray-1:      #f7f8f6;
  --lhs-gray-2:      #e8ebe6;
  --lhs-gray-3:      #9ba89a;
  --lhs-text:        #1a2318;
  --lhs-shadow:      0 8px 40px rgba(0,0,0,0.18);
  --lhs-radius:      16px;
  --lhs-font:        'Outfit', 'Segoe UI', sans-serif;
}

/* ── Bubble ─────────────────────────────────────────────── */
#lhs-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--lhs-green);
  box-shadow: 0 4px 20px rgba(45,122,79,0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

#lhs-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(45,122,79,0.55);
}

#lhs-chat-bubble:active {
  transform: scale(0.96);
}

.lhs-bubble-icon {
  font-size: 24px;
  line-height: 1;
}

.lhs-bubble-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--lhs-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--lhs-font);
}

/* ── Widget ─────────────────────────────────────────────── */
#lhs-chat-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 20px);
  height: 580px;
  max-height: calc(100dvh - 110px);
  background: var(--lhs-white);
  border-radius: var(--lhs-radius);
  box-shadow: var(--lhs-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--lhs-font);
  animation: lhsChatIn 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
  /* nécessaire pour que le lead screen overlay fonctionne */
  isolation: isolate;
}

@keyframes lhsChatIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────── */
.lhs-chat-header {
  background: linear-gradient(135deg, var(--lhs-green-dark) 0%, var(--lhs-green) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.lhs-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lhs-chat-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.lhs-chat-title {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.lhs-chat-status {
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.lhs-status-dot {
  width: 7px;
  height: 7px;
  background: #7df5a2;
  border-radius: 50%;
  display: inline-block;
  animation: lhsPulse 2s infinite;
}

@keyframes lhsPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.lhs-chat-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.lhs-chat-close:hover {
  background: rgba(255,255,255,0.28);
}

/* ── Messages ───────────────────────────────────────────── */
.lhs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--lhs-gray-1);
  scroll-behavior: smooth;
}

.lhs-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.lhs-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.lhs-chat-messages::-webkit-scrollbar-thumb {
  background: var(--lhs-gray-2);
  border-radius: 2px;
}

.lhs-msg {
  display: flex;
  animation: lhsMsgIn 0.2s ease both;
}

@keyframes lhsMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lhs-msg-bot {
  justify-content: flex-start;
}

.lhs-msg-user {
  justify-content: flex-end;
}

.lhs-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.lhs-msg-bot .lhs-msg-bubble {
  background: var(--lhs-white);
  color: var(--lhs-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.lhs-msg-user .lhs-msg-bubble {
  background: var(--lhs-green);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing ─────────────────────────────────────────────── */
.lhs-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--lhs-white);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.lhs-typing span {
  width: 7px;
  height: 7px;
  background: var(--lhs-gray-3);
  border-radius: 50%;
  animation: lhsTyping 1.2s infinite ease-in-out;
}

.lhs-typing span:nth-child(2) { animation-delay: 0.2s; }
.lhs-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lhsTyping {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Preview images ─────────────────────────────────────── */
.lhs-chat-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 0;
  background: #fff;
}

.lhs-preview-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dfe7df;
  background: #f5f7f5;
}

.lhs-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lhs-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

/* ── Input row ──────────────────────────────────────────── */
.lhs-chat-input-row {
  padding: 10px 12px;
  background: var(--lhs-white);
  border-top: 1px solid var(--lhs-gray-2);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.lhs-chat-attach {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f3f6f3;
  border: 1px solid #d9e3db;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

#lhs-chat-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--lhs-gray-2);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--lhs-font);
  color: var(--lhs-text);
  background: var(--lhs-gray-1);
  outline: none;
  transition: border-color 0.15s;
}

#lhs-chat-input:focus {
  border-color: var(--lhs-green);
  background: var(--lhs-white);
}

#lhs-chat-input::placeholder {
  color: var(--lhs-gray-3);
}

#lhs-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lhs-green);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#lhs-chat-send:hover {
  background: var(--lhs-green-dark);
}

#lhs-chat-send:active {
  transform: scale(0.93);
}

#lhs-chat-send:disabled {
  background: var(--lhs-gray-2);
  cursor: not-allowed;
}

/* ── Suggestions ────────────────────────────────────────── */
.lhs-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 4px 0;
}

.lhs-suggestion-btn {
  background: var(--lhs-white);
  border: 1.5px solid var(--lhs-green);
  color: var(--lhs-green);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-family: var(--lhs-font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.lhs-suggestion-btn:hover {
  background: var(--lhs-green);
  color: #fff;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Widget : plein écran bas, au dessus du clavier virtuel */
  #lhs-chat-widget {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    /* dvh = dynamic viewport height — se met à jour quand le clavier iOS apparaît */
    height: 75dvh;
    height: 75vh; /* fallback navigateurs sans dvh */
    max-height: 75dvh;
    max-height: 75vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.18);
  }

  /* Bubble : plus petite, respecte la safe area iPhone */
  #lhs-chat-bubble {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
  }

  /* Header plus compact */
  .lhs-chat-header {
    padding: 12px 14px;
  }
  .lhs-chat-title  { font-size: 15px; }
  .lhs-chat-status { font-size: 11px; }
  .lhs-chat-avatar { width: 34px; height: 34px; font-size: 18px; }

  /* Zone messages */
  .lhs-chat-messages {
    padding: 12px 10px;
    gap: 8px;
  }
  .lhs-msg-bubble {
    max-width: 90%;
    font-size: 14px;
    line-height: 1.5;
    padding: 9px 12px;
  }

  /* Input row : safe area en bas pour iPhone X+ */
  .lhs-chat-input-row {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 7px;
  }

  /* Input : font-size 16px évite le zoom automatique iOS */
  #lhs-chat-input {
    font-size: 16px;
    padding: 10px 14px;
    min-width: 0;
  }

  /* Boutons envoi et photo : zone de touch 44px minimum (guidelines Apple/Google) */
  #lhs-chat-send,
  .lhs-chat-attach {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Preview images */
  .lhs-chat-preview {
    padding: 6px 10px 0;
    gap: 6px;
  }
  .lhs-preview-thumb {
    width: 52px;
    height: 52px;
  }

  /* Suggestions */
  .lhs-suggestions {
    gap: 6px;
  }
  .lhs-suggestion-btn {
    font-size: 12px;
    padding: 5px 11px;
  }
}

/* iPhone notch / Dynamic Island — safe area supplémentaire */
@supports (padding: max(0px)) {
  .lhs-chat-input-row {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}
/* ============================================================
   LEAD CAPTURE SCREEN
   ============================================================ */

.lhs-lead-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--lhs-white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  border-radius: inherit;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lhs-lead-body {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.lhs-lead-icon {
  font-size: 40px;
  margin-bottom: 12px;
  animation: lhsBounce 1.2s ease infinite alternate;
}
@keyframes lhsBounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-5px); }
}

.lhs-lead-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--lhs-text);
  margin: 0 0 6px;
  font-family: var(--lhs-font);
}

.lhs-lead-subtitle {
  font-size: 13.5px;
  color: var(--lhs-gray-3);
  text-align: center;
  margin: 0 0 20px;
  line-height: 1.5;
  font-family: var(--lhs-font);
}

.lhs-lead-fields {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.lhs-lead-fields input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--lhs-gray-2);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--lhs-font);
  color: var(--lhs-text);
  background: var(--lhs-gray-1);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.lhs-lead-fields input:focus {
  border-color: var(--lhs-green);
  background: var(--lhs-white);
}
.lhs-lead-fields input::placeholder {
  color: var(--lhs-gray-3);
}

.lhs-lead-error {
  width: 100%;
  background: #fff0f0;
  border: 1px solid #fca5a5;
  color: #c0392b;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--lhs-font);
  margin-bottom: 10px;
}

.lhs-lead-submit {
  width: 100%;
  background: var(--lhs-green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--lhs-font);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-bottom: 12px;
}
.lhs-lead-submit:hover   { background: var(--lhs-green-dark); }
.lhs-lead-submit:active  { transform: scale(0.98); }
.lhs-lead-submit:disabled {
  background: var(--lhs-gray-2);
  color: var(--lhs-gray-3);
  cursor: not-allowed;
}

.lhs-lead-privacy {
  font-size: 11.5px;
  color: var(--lhs-gray-3);
  text-align: center;
  margin: 0;
  font-family: var(--lhs-font);
}

/* Widget doit être position:relative pour l'overlay lead */
#lhs-chat-widget {
  position: fixed !important;
}

/* ── Mobile lead screen ─────────────────────────────────── */
@media (max-width: 430px) {
  #lhs-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .lhs-lead-body {
    padding: 0 8px;
  }
  .lhs-lead-screen {
    padding: 20px 16px;
    align-items: flex-start;
    padding-top: 40px;
  }
}




/* V2.3.4 — liens webchat réellement cliquables + bouton propre pour suivi */
.lhs-msg-link {
    color: #1d4ed8 !important;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 5;
}
.lhs-msg-bot .lhs-msg-link {
    color: #166534 !important;
}
.lhs-msg-user .lhs-msg-link {
    color: #ffffff !important;
}
.lhs-msg-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border-radius: 999px;
    background: #166534 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(22,101,52,.18);
    line-height: 1.2;
}
.lhs-msg-link-button::after {
    content: " ↗";
    font-weight: 800;
}
.lhs-msg-bot .lhs-msg-link-button {
    color: #ffffff !important;
}
