/* ============================================================
   BethIA Chatbot Widget — Sam (CSS)
   Aligné sur la DA du site : palette + Manrope
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

/* Palette BethIA */
#beth-launcher, #beth-window {
  --sam-bg: #faf7f2;
  --sam-bg-alt: #f3ede3;
  --sam-ink: #0d1b2a;
  --sam-ink-soft: #2a3a4f;
  --sam-muted: #6b7a8a;
  --sam-line: #d9cfc0;
  --sam-accent: #c8965a;
  --sam-accent-dark: #a37a42;
  --sam-white: #ffffff;
  --sam-success: #2d6a4f;
  --sam-shadow: 0 20px 60px rgba(13, 27, 42, .18);
  --sam-shadow-soft: 0 8px 24px rgba(13, 27, 42, .1);
  --sam-font: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Bouton flottant ─── */
#beth-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--sam-accent);
  color: var(--sam-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sam-font);
  font-weight: 600;
  font-size: 24px;
  box-shadow: var(--sam-shadow);
  z-index: 9998;
  transition: transform .25s ease, background .2s ease, box-shadow .25s ease;
}
#beth-launcher:hover {
  transform: translateY(-2px);
  background: var(--sam-accent-dark);
  box-shadow: 0 24px 70px rgba(13, 27, 42, .25);
}
#beth-launcher.open {
  background: var(--sam-ink);
}

#beth-launcher .beth-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 12px; height: 12px;
  background: var(--sam-success);
  border-radius: 50%;
  border: 2px solid var(--sam-bg);
}
#beth-launcher * {
  pointer-events: none;
}

/* ─── Fenêtre de chat ─── */
#beth-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--sam-bg);
  border: 1px solid var(--sam-line);
  border-radius: 16px;
  box-shadow: var(--sam-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: var(--sam-font);
  color: var(--sam-ink);
}
#beth-window.open { display: flex; }

/* ─── Header ─── */
.beth-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--sam-line);
  background: var(--sam-bg-alt);
  display: flex;
  align-items: center;
  gap: 12px;
}
.beth-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--sam-accent);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--sam-shadow-soft);
}
.beth-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.beth-header-text { display: flex; flex-direction: column; gap: 2px; }
.beth-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--sam-ink);
  letter-spacing: -.2px;
}
.beth-status {
  font-size: 12px;
  color: var(--sam-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.beth-status::before {
  content: ""; width: 6px; height: 6px; background: var(--sam-success); border-radius: 50%;
}
#beth-close {
  margin-left: auto;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sam-muted);
  flex-shrink: 0;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
#beth-close:hover {
  background: var(--sam-accent);
  border-color: var(--sam-accent);
  color: var(--sam-white);
  transform: rotate(90deg);
}
#beth-close svg {
  pointer-events: none;
}

/* ─── Zone messages ─── */
.beth-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sam-bg);
}
.beth-messages::-webkit-scrollbar { width: 6px; }
.beth-messages::-webkit-scrollbar-thumb { background: var(--sam-line); border-radius: 3px; }
.beth-messages::-webkit-scrollbar-track { background: transparent; }

.beth-msg {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-weight: 400;
}
.beth-msg.bot {
  background: var(--sam-bg-alt);
  color: var(--sam-ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--sam-line);
}
.beth-msg.user {
  background: var(--sam-ink);
  color: var(--sam-bg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.beth-msg a {
  color: var(--sam-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.beth-msg.user a { color: var(--sam-accent); }
.beth-msg.bot a:hover { color: var(--sam-accent-dark); }

/* ─── Indicateur "Sam écrit" ─── */
.beth-typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  background: var(--sam-bg-alt);
  border: 1px solid var(--sam-line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}
.beth-typing span {
  width: 7px; height: 7px;
  background: var(--sam-muted);
  border-radius: 50%;
  animation: bethBlink 1.4s infinite;
}
.beth-typing span:nth-child(2) { animation-delay: .2s; }
.beth-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bethBlink {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ─── Zone d'input ─── */
.beth-input-zone {
  border-top: 1px solid var(--sam-line);
  padding: 14px 16px;
  background: var(--sam-bg-alt);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#beth-input {
  flex: 1;
  background: var(--sam-white);
  border: 1px solid var(--sam-line);
  color: var(--sam-ink);
  border-radius: 12px;
  padding: 10px 14px;
  padding-right: 10px;
  font-family: var(--sam-font);
  font-size: 14px;
  font-weight: 400;
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--sam-line) transparent;
}
#beth-input::-webkit-scrollbar { width: 4px; }
#beth-input::-webkit-scrollbar-track { background: transparent; margin: 6px; }
#beth-input::-webkit-scrollbar-thumb {
  background: var(--sam-line);
  border-radius: 4px;
}
#beth-input::-webkit-scrollbar-thumb:hover { background: var(--sam-accent); }
#beth-input::placeholder { color: var(--sam-muted); }
#beth-input:focus {
  border-color: var(--sam-accent);
  box-shadow: 0 0 0 3px rgba(200, 150, 90, .12);
}
#beth-input:focus::-webkit-scrollbar-thumb { background: rgba(200, 150, 90, .4); }
#beth-send {
  background: var(--sam-accent);
  color: var(--sam-white);
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s ease;
}
#beth-send:hover:not(:disabled) { background: var(--sam-accent-dark); }
#beth-send:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Footer ─── */
.beth-footer {
  padding: 10px 16px;
  font-size: 11px;
  color: var(--sam-muted);
  text-align: center;
  border-top: 1px solid var(--sam-line);
  background: var(--sam-bg-alt);
  font-weight: 500;
}

/* ─── Mobile ─── */
@media (max-width: 480px) {
  #beth-window {
    bottom: 90px;
    right: 12px;
    left: 12px;
    width: auto;
    height: calc(100vh - 110px);
  }
  #beth-launcher {
    bottom: 16px;
    right: 16px;
  }
}