#chatbot-container {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 24px;
  font-family: 'Segoe UI', sans-serif;
  z-index: 9999;
}

.chatbot-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.chatbot-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  background: #0A1A44;
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: 2px solid #0A1A44;
  font-size: 22px;
  box-shadow: 0 12px 30px rgba(10,26,68,0.25);
  transition: all 0.35s ease;
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 35px rgba(10,26,68,0.35);
}

.chatbot-toggle::after {
  content: "";
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(10,26,68,0.15);
  animation: pulse 2.5s infinite;
  z-index: -1;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  70% { transform: scale(1.6); opacity: 0; }
  100% { opacity: 0; }
}

.chatbot-tooltip {
  background: white;
  color: #0A1A44;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
  position: relative;
  transition: all 0.35s ease;
}

.chatbot-tooltip::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: white;
  transition: all 0.35s ease;
}

.chatbot-wrapper:hover .chatbot-toggle {
  background: white;
  color: #0A1A44;
  box-shadow: 0 14px 35px rgba(0,0,0,0.18);
}

.chatbot-wrapper:hover .chatbot-tooltip {
  background: #0A1A44;
  color: white;
}

.chatbot-wrapper:hover .chatbot-tooltip::after {
  background: #0A1A44;
}

.chatbot-tooltip.hide {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(10px);
  }
}

#chatbot {
  display: none;
  width: 380px;
  height: 520px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.18);
  flex-direction: column;
  overflow: hidden;
}

#chatbot.active {
  display: flex;
  animation: openChat 0.25s ease;
}

@keyframes openChat {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* AJOUTÉ : quand le chat est ouvert */
#chatbot-container.is-open .chatbot-toggle {
  display: none;
}

#chatbot-container.is-open .chatbot-tooltip {
  display: none;
}

#chat-header {
  background: linear-gradient(135deg, #0A1A44, #102a6d);
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

#status {
  font-size: 12px;
  opacity: 0.85;
}

#chatbot-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#chatbot-close:hover {
  background: white;
  color: #0A1A44;
  transform: translateY(-2px);
}

#chat-window {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f4f6fc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  padding: 12px 18px;
  border-radius: 24px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.5;
  animation: fadeInMsg 0.3s ease;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  background: linear-gradient(135deg, #0A1A44, #132f7c);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 8px;
}

.message.bot {
  background: white;
  color: #111;
  margin-right: auto;
  border-bottom-left-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

.msg-status {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

#quick-replies {
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: white;
}

#quick-replies button {
  border: 1px solid rgba(10,26,68,0.25);
  background: white;
  color: #0A1A44;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s ease;
}

#quick-replies button:hover {
  background: #0A1A44;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(10,26,68,0.25);
}

#chat-form {
  display: flex;
  padding: 12px;
  background: white;
  border-top: 1px solid #eef0f5;
}

#user-input {
  flex: 1;
  border-radius: 30px;
  border: 1px solid transparent;
  padding: 10px 18px;
  background: #f4f6fb;
  transition: 0.25s ease;
}

#user-input:focus {
  border-color: #0A1A44;
  background: white;
  box-shadow: 0 0 0 3px rgba(10,26,68,0.08);
  outline: none;
}

#chat-form button {
  margin-left: 8px;
  background: #0A1A44;
  border: none;
  color: white;
  border-radius: 30px;
  padding: 0 18px;
  cursor: pointer;
  transition: 0.25s ease;
}

#chat-form button:hover:not(:disabled) {
  background: #132f7c;
}

#chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-icon {
  width: 34px;
  height: 34px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.chatbot-lang-ar #chatbot {
  direction: rtl;
}

.chatbot-lang-ar .chatbot-wrapper {
  direction: ltr;
}

.chatbot-lang-ar .chatbot-tooltip {
  direction: rtl;
  text-align: right;
}

.chatbot-lang-ar #chat-header,
.chatbot-lang-ar .message,
.chatbot-lang-ar #user-input,
.chatbot-lang-ar #quick-replies {
  text-align: right;
}

.chatbot-lang-ar #chat-form button {
  margin-left: 0;
  margin-right: 8px;
}

.chatbot-lang-ar .message.user {
  margin-left: 0;
  margin-right: auto;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 24px;
}

.chatbot-lang-ar .message.bot {
  margin-right: 0;
  margin-left: auto;
  border-bottom-right-radius: 8px;
  border-bottom-left-radius: 24px;
}

.hidden {
  display: none;
}

@media (prefers-color-scheme: dark) {
  #chatbot { background: #151a2e; }
  #chat-window { background: #1d2238; }
  .message.bot { background: #252b45; color: white; }
  .chatbot-tooltip { background: #252b45; color: white; }
  .chatbot-tooltip::after { background: #252b45; }
  #chat-form { background: #1d2238; }
  #user-input { background: #252b45; border-color: #333a55; color: white; }
}

@media (max-width: 1199.98px) {
  .chatbot-tooltip {
    display: none !important;
  }
}

@media (max-width: 767.98px) {
  #chatbot-container {
    right: 8px !important;
  }
}