#chatbot-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  height: 600px;
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  display: none; /* Masqué par défaut */
  flex-direction: column;
  z-index: 9999;
  font-family: "Open Sans", "Segoe UI", Tahoma, sans-serif;
  color: var(--text-main);
  overflow: hidden;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

#whatsapp-button {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 60px;
  height: 60px;
  background: #25d366;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  transition:
    transform 0.2s,
    background 0.2s;
  text-decoration: none;
  color: white;
}

#whatsapp-button svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#whatsapp-button:hover {
  transform: scale(1.1);
  background: #1fa956;
}

#whatsapp-button:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Desktop only: Afficher le bouton WhatsApp SEULEMENT en desktop */
@media (max-width: 768px) {
  #whatsapp-button {
    display: none;
  }
}

#chatbot-trigger {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  transition:
    transform 0.2s,
    background 0.2s;
}

.trigger-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#chatbot-trigger:hover {
  transform: scale(1.1);
}

#chatbot-trigger:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
.chat-header {
  background: linear-gradient(
    135deg,
    var(--color-primary) 0,
    var(--color-primary-dark) 100%
  );
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.8);
}
.chat-header h3 {
  font-family: Outfit, sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}
.chat-header .subtitle {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
}
.close-btn {
  background: 0 0;
  border: 2px solid transparent;
  border-radius: 4px;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}
.close-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  border-color: #fff;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-page);
}
.message {
  display: flex;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 8px;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.45;
}
.message.bot {
  align-self: flex-start;
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.message.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
}
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-section);
}
.input-group {
  display: flex;
  gap: 8px;
}
#chat-input {
  flex: 1;
  border: 1px solid var(--border-color);
  background: var(--bg-section);
  color: var(--text-main);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  min-height: 40px;
}
#chat-input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
  border-color: transparent;
}
.send-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.send-btn:hover {
  background: var(--color-primary-dark);
}
.send-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.action-btn {
  flex: 1;
  min-width: 80px;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  text-align: center;
}
.action-btn:hover {
  background: var(--bg-card-alt);
}
.action-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
#budget-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.budget-btn {
  flex: 1;
  min-width: 80px;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  text-align: center;
}
.budget-btn:hover {
  background: var(--bg-card-alt);
}
.budget-btn.selected {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.budget-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
.form-field {
  margin: 10px 0;
}
.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.form-field input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-section);
  color: var(--text-main);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.form-field input:focus-visible {
  outline: 2px solid var(--color-accent);
  border-color: transparent;
}
#show-history-btn {
  display: none; /* Masqué par défaut */
  position: fixed;
  right: 20px;
  bottom: 640px;
  width: 44px;
  height: 44px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition:
    background 0.2s,
    transform 0.2s;
}
#show-history-btn:hover {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}
#show-history-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
#chat-history-panel {
  display: none;
  position: fixed;
  right: 420px;
  bottom: 20px;
  width: 350px;
  height: 500px;
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  z-index: 9998;
  overflow-y: auto;
  padding: 16px;
  flex-direction: column;
  font-family: inherit;
  color: var(--text-main);
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}
.history-header label {
  font-family: Outfit, sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.close-history-btn {
  background: 0 0;
  border: 2px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.close-history-btn:hover {
  background: var(--bg-card);
}
.close-history-btn:focus-visible {
  outline: 2px solid var(--color-accent);
}
#history-list {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
}
.history-item {
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.history-item:hover {
  background: var(--bg-card-alt);
  border-color: var(--text-light);
}
.history-item:focus-visible {
  outline: 2px solid var(--color-accent);
}
.history-item-time {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-primary);
}
.history-item-meta {
  color: var(--text-muted);
  margin-bottom: 4px;
  font-size: 11px;
}
.history-item-preview {
  color: var(--text-light);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#admin-export {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
#admin-export label {
  font-weight: 700;
  margin-bottom: 8px;
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}
.admin-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#export-csv-btn,
#clear-history-btn {
  width: 100%;
  min-height: 38px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  transition: filter 0.2s;
}
#export-csv-btn {
  background: var(--color-primary);
  color: #fff;
}
#clear-history-btn {
  background: var(--color-cta);
  color: #fff;
}
#export-csv-btn:hover,
#clear-history-btn:hover {
  filter: brightness(1.08);
}
#export-csv-btn:focus-visible,
#clear-history-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
@media (max-width: 768px) {
  #chatbot-widget {
    width: 380px;
    right: 20px;
    bottom: 20px;
  }
  #chat-history-panel {
    right: 0;
    top: 0;
    bottom: 0;
    width: 350px;
    height: 100%;
    border-radius: 0;
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10000;
  }
  #show-history-btn {
    bottom: 640px;
    right: 20px;
  }
}
@media (max-width: 480px) {
  #chatbot-widget {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
  #chat-history-panel {
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    z-index: 10001;
  }
  #show-history-btn {
    right: auto;
    left: 20px;
    bottom: 20px;
    z-index: 10000;
  }
  .message {
    max-width: 90%;
  }
}
