:root {
  --primary-chat-ai-color: #0073aa;
  --chat-ai-btn-top: auto;
  --chat-ai-btn-right: 20px;
  --chat-ai-btn-bottom: 20px;
  --chat-ai-btn-left: auto;
  --chat-ai-win-top: auto;
  --chat-ai-win-right: 20px;
  --chat-ai-win-bottom: 90px;
  --chat-ai-win-left: auto;
  --chat-ai-font-family: Arial, sans-serif;
  --chat-ai-font-size: 14px;
}

#chat-toggle {
  position: fixed;
  top: var(--chat-ai-btn-top);
  right: var(--chat-ai-btn-right);
  bottom: var(--chat-ai-btn-bottom);
  left: var(--chat-ai-btn-left);
  background: linear-gradient(135deg, var(--primary-chat-ai-color), #005f94);
  color: white;
  font-size: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  text-align: center;
  line-height: 60px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
  z-index: 1000;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#chat-toggle #chat-notif {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: red;
  color: #fff;
  font-size: 12px;
  border-radius: 50%;
  line-height: 20px;
  display: none;
}

#chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 24px rgba(0,0,0,0.4);
}

#chat-window {
  position: fixed;
  top: var(--chat-ai-win-top);
  right: var(--chat-ai-win-right);
  bottom: var(--chat-ai-win-bottom);
  left: var(--chat-ai-win-left);
  width: 300px;
  max-height: 600px;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  z-index: 1000;
  overflow: hidden;
  font-family: var(--chat-ai-font-family);
  font-size: var(--chat-ai-font-size);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s ease;
}

#chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header du chat */
#chat-header {
  background-color: var(--primary-chat-ai-color);
  color: white;
  padding: 10px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#chat-header button {
  border: none;
  background: none;
}

#chat-header button:hover {
  border: none;
  background: none;
}

/* Zone des messages */
#chat-messages {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
  min-height: 400px;
  height: 400px;
}

#chat-messages .message {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 80%;
  clear: both;
  font-size: small;
  overflow-wrap: anywhere;
  animation: fade-in 0.25s ease;
}

#chat-messages .message.sent {
  background-color: #DCF8C6;
  align-self: flex-end;
  text-align: right;
  margin-left: auto;
}

#chat-messages .message.received {
  background-color: #f1f0f0;
  align-self: flex-start;
}

#chat-messages .timestamp {
  font-size: 11px;
  color: #888;
  text-align: right;
}

/* Champ de saisie */
#chat-input {
  display: flex;
  border-top: 1px solid #ddd;
}

#chat-input input {
  flex: 1;
  border: none;
  padding: 10px;
  outline: none;
  border-radius: 0;
}

#chat-input input:focus {
  background-color: #f9f9f9;
}

#chat-input button {
  background-color: var(--primary-chat-ai-color);
  color: white;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#chat-input button:hover {
  background-color: #005f94;
}

#chat-messages .chat-loading {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  margin: 10px 0;
  background: #f1f1f1;
  border-radius: 16px;
  max-width: fit-content;
  font-style: italic;
  font-size: 14px;
  color: #666;
}

#chat-messages .chat-loading .dot {
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background-color: #333;
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}

#chat-messages .chat-loading .dot:nth-child(2) {
  animation-delay: 0.2s;
}

#chat-messages .chat-loading .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 80%, 100% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
}

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

/* Rating section */
#chat-rating {
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #ddd;
}

#chat-rating.message,
#chat-thank.message {
  background-color: #f1f0f0;
  border-radius: 10px;
  max-width: 80%;
  align-self: flex-start;
  margin-bottom: 10px;
  border-top: none;
}

#chat-rating p {
  margin-bottom: 0px;
}

#chat-rating button {
    background-color: transparent;
    border: 1px solid var(--primary-chat-ai-color);
    border-radius: 3px;
    color: var(--primary-chat-ai-color);
    display: inline-block;
    font-size: 1rem;
    font-weight: 400;
    padding: .5rem 1rem;
    text-align: center;
    transition: all .3s;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    white-space: nowrap;
}

#chat-rating button:hover {
    background-color: var(--primary-chat-ai-color);
    color: white;
}

#chat-rating .stars {
  display: flex;
  gap: 5px;
  cursor: pointer;
}

#chat-rating .star {
  font-size: 20px;
  color: #ccc;
}

#chat-rating .star.filled {
  color: var(--primary-chat-ai-color);
}

#chat-rating textarea {
  width: 100%;
  resize: vertical;
}

#chat-thank {
  padding: 10px;
  text-align: center;
  display: none;
}

@keyframes chat-ai-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

#chat-toggle.chat-move {
  animation: chat-ai-bounce 0.6s ease-in-out 5;
}

#chat-powered-by {
  text-align: center;
  font-size: 10px;
  margin-top: 4px;
  color: #aaa;
}

#chat-powered-by a {
  color: inherit;
  text-decoration: none;
}
