/* --- CHATBOT DESIGN PREMIUM --- */

/* Police moderne */
#chat-container,
#chat-toggle-btn,
#chatbox-body,
#user-input {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  box-sizing: border-box;
}

/* 1. BOUTON FLOTTANT */
#chat-toggle-btn {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #1B5E20, #4CAF50);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(27, 94, 32, 0.35);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#chat-toggle-btn:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 30px rgba(27, 94, 32, 0.5);
}

/* 2. FENÊTRE DE CHAT */
#chat-container {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 380px;
  height: 550px;
  max-height: 80vh;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  z-index: 9998;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.5);

  /* Animation d'ouverture */
  transform-origin: bottom right;
  transform: scale(0) translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#chat-container.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* 3. EN-TÊTE */
#chatbox-header {
  background: linear-gradient(135deg, #1B5E20, #4CAF50);
  padding: 15px 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bot-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.3px;
}

.status-text {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: #00E676;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* --- SWITCH LANGUE (STYLE IPHONE) --- */
.lang-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  margin-right: 15px;
}

.lang-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.25);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #00E676;
  /* Vert actif */
}

input:checked+.slider:before {
  transform: translateX(16px);
}

/* Bouton fermer */
#close-chat-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s;
}

#close-chat-btn:hover {
  transform: scale(1.1);
  color: white;
}

/* 4. ZONE DE DISCUSSION */
#chatbox-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Messages */
.message {
  max-width: 80%;
  padding: 12px 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  animation: slideUp 0.3s ease forwards;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.bot-message {
  align-self: flex-start;
  background-color: #ffffff;
  color: #334155;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
  color: white;
  border-bottom-right-radius: 4px;
}

/* 5. ZONE DE SAISIE */
#input-area {
  padding: 15px;
  background: white;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #E2E8F0;
  border-radius: 25px;
  outline: none;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  background: #F8FAFC;
}

#user-input:focus {
  border-color: #4CAF50;
  background: white;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

#send-btn {
  background: #2E7D32;
  color: white;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.2s;
}

#send-btn:hover {
  background-color: #1B5E20;
  transform: scale(1.1);
}

/* Indicateur de frappe */
.typing-indicator {
  align-self: flex-start;
  background-color: #fff;
  padding: 10px 15px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  width: fit-content;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 10px;
  border: 1px solid #e2e8f0;
}

.dot {
  width: 6px;
  height: 6px;
  background: #94A3B8;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
  animation-delay: -0.32s;
}

.dot:nth-child(2) {
  animation-delay: -0.16s;
}

/* Animations */
@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* MODE ARABE (RTL) */
.rtl-mode {
  direction: rtl;
  text-align: right;
}

.rtl-mode #chatbox-header {
  flex-direction: row-reverse;
}

.rtl-mode .lang-switch-wrapper {
  margin-right: auto;
  margin-left: 15px;
}

.rtl-mode .header-info {
  align-items: flex-end;
}

.rtl-mode .bot-message {
  align-self: flex-start;
  /* Reste à gauche ou passe à droite selon préférence, ici on garde la logique conversationnelle */
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
}

.rtl-mode .user-message {
  align-self: flex-end;
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 4px;
}

/* Mobile */
@media (max-width: 480px) {
  #chat-container {
    width: 100%;
    height: 100%;
    max-height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  #chat-toggle-btn {
    bottom: 20px;
    right: 20px;
  }
}