/* Chatbot Widget - Valentin.solutions */

/* Chat button - bottom right */
#chatbot-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #ffffff;
  color: #0D0D0D;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 9998;
  transition: transform 0.2s ease, box-shadow 0.2s ease, width 0.2s ease, height 0.2s ease;
  will-change: transform;
  contain: layout style paint;
}

/* Same size as send button when chat is open (42px like send button) */
#chatbot-button.chat-open {
  width: 42px;
  height: 42px;
}

#chatbot-button.chat-open svg {
  width: 20px;
  height: 20px;
}

#chatbot-button svg {
  width: 28px;
  height: 28px;
  transition: width 0.2s ease, height 0.2s ease;
}

#chatbot-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* Chat window */
#chatbot-window {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 320px;
  max-width: calc(100vw - 2rem);
  height: 480px;
  max-height: calc(100vh - 8rem);
  background: var(--bg, #fff);
  border-radius: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  font-family: var(--font-body, 'Source Sans 3', sans-serif);
  /* Prevent layout shift */
  contain: layout style paint;
}

#chatbot-window.visible {
  display: flex;
}

/* Header */
#chatbot-header {
  background: var(--accent, #000);
  color: var(--bg, #fff);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

#chatbot-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  font-family: 'Source Sans 3', sans-serif;
}

#chatbot-header button {
  background: none;
  border: none;
  color: var(--bg, #fff);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#chatbot-header button:hover {
  opacity: 1;
}

/* Messages container */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--bg-light, #f8f8f8);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Welcome message */
#chatbot-welcome {
  background: var(--bg, #fff);
  padding: 1rem;
  border-radius: 0;
  border-left: 3px solid var(--accent, #000);
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text, #333);
}

#chatbot-welcome strong {
  color: var(--accent, #000);
}

/* Message bubble */
.chatbot-message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 80%;
  animation: fadeIn 0.3s ease;
}

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

.chatbot-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chatbot-message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chatbot-message-content {
  padding: 0.75rem 1rem;
  border-radius: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.chatbot-message.user .chatbot-message-content {
  background: var(--accent, #000);
  color: var(--bg, #fff);
  border-bottom-right-radius: 4px;
}

.chatbot-message.assistant .chatbot-message-content {
  background: var(--bg, #fff);
  color: var(--text, #333);
  border: 1px solid rgba(0,0,0,0.08);
  border-bottom-left-radius: 4px;
}

.chatbot-message-time {
  font-size: 0.7rem;
  color: var(--mid, #999);
  padding: 0 0.5rem;
}

/* Typing indicator */
.chatbot-typing {
  display: flex;
  gap: 0.3rem;
  padding: 0.75rem 1rem;
  background: var(--bg, #fff);
  border-radius: 0;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid rgba(0,0,0,0.08);
}

.chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mid, #999);
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* Input form */
#chatbot-input-form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg, #fff);
  border-top: 1px solid rgba(0,0,0,0.08);
}

#chatbot-input {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 0;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

#chatbot-input::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

#chatbot-input:focus {
  border-color: var(--accent, #000);
}

#chatbot-send {
  background: var(--accent, #000);
  color: var(--bg, #fff);
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

#chatbot-send:hover:not(:disabled) {
  transform: scale(1.05);
}

#chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error message */
.chatbot-error {
  background: #fee;
  color: #c33;
  padding: 0.75rem 1rem;
  border-radius: 0;
  font-size: 0.85rem;
  border: 1px solid #fcc;
}

/* Warning message (conversation limit approaching) */
.message.system-warning {
  background: #fff3cd;
  color: #856404;
  padding: 0.75rem 1rem;
  border-radius: 0;
  font-size: 0.85rem;
  border: 1px solid #ffeaa7;
  margin: 1rem 0;
  text-align: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
  #chatbot-window {
    width: calc(100vw - 2rem);
    height: calc(100vh - 10rem);
    bottom: 5rem;
    right: 1rem;
  }
  
  #chatbot-button {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 50px;
    height: 50px;
  }
  
  #chatbot-button svg {
    width: 24px;
    height: 24px;
  }
}

/* Scrollbar styling */
#chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}

/* ===== Charte glennbeaudet.fr : design clair, titre et icônes noirs ===== */
#chatbot-button {
  background: #ffffff;
  color: #0D0D0D; /* icône bulle ET croix (currentColor), ouvert ou fermé */
}
#chatbot-button.chat-open {
  color: #0D0D0D;
}
#chatbot-header {
  background: #ffffff;
  color: #0D0D0D;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
#chatbot-header h3 {
  color: #0D0D0D; /* titre "Assistant virtuel" + icône (currentColor) */
}
#chatbot-header button {
  color: #0D0D0D;
}
#chatbot-send {
  background: #0D0D0D;
  color: #ffffff;
  border: none;
}
