.widgetContainer {
  position: fixed;
  width: var(--chat-window-width, 460px);
  height: var(--chat-window-height, 640px);
  z-index: var(--chat-z-index, 9999);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.widgetContainerOpen {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.toggleButton {
  position: fixed;
  width: var(--chat-button-size, 60px);
  height: var(--chat-button-size, 60px);
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  overflow: hidden;
  animation: bounce-in 0.6s ease, pulse-glow 2.5s ease-in-out infinite;
  z-index: calc(var(--chat-z-index, 9999) + 1);
  margin: 0;
  padding: 0;
}

.toggleButton::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.15) 50%, transparent 70%);
  animation: chatbot-shimmer 3s infinite;
  pointer-events: none;
  z-index: 1;
}

.toggleButton:hover {
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 25px rgba(255, 255, 255, 0.5);
  animation-play-state: paused;
}

.toggleButton:hover::after {
  animation-play-state: paused;
}

.toggleButton:hover svg {
  transform: scale(1.08);
}

.toggleButtonHidden {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
  visibility: hidden;
  animation: none !important;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.toggleButtonHidden::after {
  animation: none;
  opacity: 0;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pulse-glow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.4);
  }
}

@keyframes chatbot-shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

.position-bottom-right.widgetContainer {
  right: 20px;
  bottom: 24px;
  transform-origin: bottom right;
}

.position-bottom-left.widgetContainer {
  left: 20px;
  bottom: 24px;
  transform-origin: bottom left;
}

.position-top-right.widgetContainer {
  right: 20px;
  top: calc(var(--chat-button-size, 60px) + 20px + 24px);
  transform-origin: top right;
}

.position-top-left.widgetContainer {
  left: 20px;
  top: calc(var(--chat-button-size, 60px) + 20px + 24px);
  transform-origin: top left;
}

.position-bottom-right.toggleButton {
  bottom: 20px;
  right: 20px;
}

.position-bottom-left.toggleButton {
  bottom: 20px;
  left: 20px;
}

.position-top-right.toggleButton {
  top: 20px;
  right: 20px;
}

.position-top-left.toggleButton {
  top: 20px;
  left: 20px;
}

.widget {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.headerInfo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.headerText h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.headerText p {
  margin: 4px 0 0 0;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.headerActions {
  display: flex;
  align-items: center;
}

.statusIndicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse 2s infinite;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.closeButton {
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  margin: 0;
  position: relative;
  overflow: hidden;
}

.closeButton::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.closeButton:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.closeButton:hover::before {
  opacity: 1;
}

.closeButton:active {
  transform: scale(0.95);
}

.closeButtonIcon {
  width: 16px;
  height: 16px;
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
}

.closeButton:hover .closeButtonIcon {
  transform: rotate(90deg);
}

.messages {
  flex: 1;
  padding: 20px;
  background: #f8fafc;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 999px;
}

.messageWrapper {
  display: flex;
  gap: 8px;
  max-width: calc(100% - 40px);
  width: fit-content;
  align-items: flex-end;
}

.messageWrapperUser {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.messageWrapperBot {
  align-self: flex-start;
}

.messageAvatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
}

.message {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  animation: fade-in-up 0.25s ease;
  max-width: 320px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.messageUser {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.messageUser p {
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

.messageUser p:first-child {
  margin-top: 0;
  padding-top: 0;
}

.messageUser p:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.messageUser * {
  margin: 0;
  padding: 0;
}

.messageUser *:first-child {
  margin-top: 0;
  padding-top: 0;
}

.messageUser *:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.messageBot {
  background: white;
  color: #1f2937;
  border-bottom-left-radius: 4px;
  white-space: normal; /* Permet le wrapping normal */
}

.messageBot br {
  display: block;
  content: "";
  margin: 8px 0;
  line-height: 1.6;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.messageBot p {
  margin: 0 0 10px 0;
  line-height: 1.6;
}

.messageBot p:last-child {
  margin-bottom: 0;
}

.messageBot h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--chat-primary-dark);
  margin: 16px 0 8px 0;
  line-height: 1.4;
}

.messageBot h2:first-child {
  margin-top: 0;
}

.messageBot h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--chat-primary-dark);
  margin: 14px 0 6px 0;
  line-height: 1.4;
}

.messageBot h3:first-child {
  margin-top: 0;
}

.messageBot h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--chat-primary);
  margin: 12px 0 6px 0;
  line-height: 1.4;
}

.messageBot h4:first-child {
  margin-top: 0;
}

.messageBot ul {
  margin: 8px 0 10px 0;
  padding-left: 20px;
  list-style: none;
}

.messageBot ul li {
  position: relative;
  padding-left: 16px;
  margin: 6px 0;
  line-height: 1.5;
}

.messageBot ul li br {
  display: block;
  content: "";
  margin: 4px 0;
  line-height: 1.5;
}

.messageBot ul li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--chat-primary);
  font-weight: bold;
  font-size: 16px;
  line-height: 1.2;
}

.messageBot hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 12px 0;
}

.messageBot strong {
  color: var(--chat-primary-dark);
  font-weight: 600;
}

.messageBot em {
  font-style: italic;
  color: #4b5563;
}

.messageBot code {
  background: rgba(74, 124, 89, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 13px;
  color: var(--chat-primary-dark);
  font-weight: 500;
}

.messageBot a {
  color: var(--chat-primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(74, 124, 89, 0.3);
  transition: all 0.2s ease;
}

.messageBot a:hover {
  color: var(--chat-primary-dark);
  border-bottom-color: var(--chat-primary-dark);
}

.typingBubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  position: relative;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.28);
  backdrop-filter: blur(14px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.typingBubble::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 70%);
  pointer-events: none;
}

.typingDot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0.65;
  animation: typing-wave 1.1s infinite ease-in-out;
}

.typingDot:nth-child(2) {
  animation-delay: 0.18s;
}

.typingDot:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typing-wave {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.inputArea {
  padding: 16px 20px 12px;
  background: #fff;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.inputGroup {
  flex: 1;
  position: relative;
}

.input {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 18px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 96px;
  line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.sendButton {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(74, 124, 89, 0.25), 0 2px 4px rgba(74, 124, 89, 0.15);
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.sendButton::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sendButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 2px 4px rgba(74, 124, 89, 0.1);
  transform: none;
}

.sendButton:disabled::before {
  display: none;
}

.sendButton:not(:disabled):hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 20px rgba(74, 124, 89, 0.35), 0 4px 8px rgba(74, 124, 89, 0.2);
  background: linear-gradient(135deg, var(--chat-primary-dark) 0%, var(--chat-primary) 100%);
}

.sendButton:not(:disabled):hover::before {
  opacity: 1;
}

.sendButton:not(:disabled):active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px rgba(74, 124, 89, 0.25);
}

.sendButtonIcon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 1;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sendButtonIcon svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

.sendButton:not(:disabled):hover .sendButtonIcon {
  transform: translateX(2px) translateY(-2px);
}

.footer {
  padding: 4px 20px 6px;
  text-align: center;
  background: linear-gradient(to top, rgba(248, 250, 252, 0.5), white);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
}

.footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--chat-primary), transparent);
  opacity: 0.3;
}

.errorBanner {
  margin: 0 20px 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(254, 226, 226, 0.8);
  color: #b91c1c;
  font-size: 12px;
  text-align: left;
}

.poweredBy {
  font-size: 10px;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
  letter-spacing: 0.01em;
}

.poweredByHighlight {
  color: var(--chat-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.poweredByHighlight::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--chat-primary-dark);
  transition: width 0.2s ease;
}

.poweredByHighlight:hover {
  color: var(--chat-primary-dark);
}

.poweredByHighlight:hover::after {
  width: 100%;
}

/* Responsive pour tablettes */
@media (max-width: 768px) {
  .widgetContainer {
    width: calc(100vw - 40px) !important;
    max-width: 460px;
    height: calc(100vh - 120px) !important;
    max-height: 640px;
  }

  .message {
    max-width: calc(100% - 20px);
  }
}

/* Responsive pour mobiles */
@media (max-width: 480px) {
  .widgetContainer {
    width: calc(100vw - 20px) !important;
    height: calc(100vh - 100px) !important;
    max-height: 80vh;
    border-radius: 12px;
  }

  .widgetContainer.position-bottom-right,
  .widgetContainer.position-bottom-left {
    bottom: calc(10px + var(--chat-button-size, 56px) + 12px);
    right: 10px;
    left: 10px;
  }

  .widgetContainer.position-top-right,
  .widgetContainer.position-top-left {
    top: calc(10px + var(--chat-button-size, 56px) + 12px);
    right: 10px;
    left: 10px;
  }

  .toggleButton {
    width: 54px;
    height: 54px;
  }

  .toggleButton.position-bottom-right,
  .toggleButton.position-bottom-left {
    bottom: 10px;
  }

  .toggleButton.position-top-right,
  .toggleButton.position-top-left {
    top: 10px;
  }

  .header {
    padding: 14px 16px;
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .headerText h3 {
    font-size: 14px;
  }

  .headerText p {
    font-size: 10px;
  }

  .messages {
    padding: 16px;
  }

  .message {
    max-width: calc(100% - 10px);
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.4;
  }

  .messageAvatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .inputArea {
    padding: 12px 16px 10px;
  }

  .input {
    font-size: 13px;
    padding: 8px 12px;
    min-height: 36px;
    line-height: 1.4;
  }

  .sendButton {
    width: 40px;
    height: 40px;
  }

  .sendButtonIcon {
    width: 18px;
    height: 18px;
  }

  .messageBot h2 {
    font-size: 15px;
  }

  .messageBot h3 {
    font-size: 14px;
  }

  .messageBot h4 {
    font-size: 13px;
  }
}

/* Très petits écrans */
@media (max-width: 360px) {
  .widgetContainer {
    width: calc(100vw - 16px) !important;
    height: calc(100vh - 90px) !important;
  }

  .toggleButton {
    width: 50px;
    height: 50px;
  }

  .header {
    padding: 12px 14px;
  }

  .messages {
    padding: 12px;
  }
}

.toggleButton svg,
.toggleButtonIcon {
  width: 28px;
  height: 28px;
  transition: transform 0.2s ease;
  position: relative;
  z-index: 2;
}

.enhancedToggle::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  opacity: 0.3;
  z-index: -1;
  animation: pulse-ring 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse-ring {
  0%, 100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.toggleButton:focus-visible {
  outline: 3px solid var(--chat-primary);
  outline-offset: 4px;
}
