/**
 * ============================================================================
 * ASSISTANT VIRTUEL & MOTEUR DE RECHERCHE - MANDIR DIOP
 * Fichier : chatbot/chatbot.css
 * Styles harmonisés avec la charte graphique du portfolio (#69b3a2)
 * ============================================================================
 */

:root {
  --mc-primary: #69b3a2;
  --mc-primary-dark: #52998a;
  --mc-primary-light: #eef8f5;
  --mc-dark: #212529;
  --mc-gray-bg: #f8fafc;
  --mc-border: #e2e8f0;
  --mc-text: #2d3748;
  --mc-text-muted: #64748b;
  --mc-radius: 16px;
  --mc-shadow: 0 12px 35px rgba(0, 0, 0, 0.16);
  --mc-font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Conteneur global */
#mandir-chatbot-wrapper {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 99999;
  font-family: var(--mc-font);
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}

#mandir-chatbot-wrapper *,
#mandir-chatbot-wrapper *::before,
#mandir-chatbot-wrapper *::after {
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------- */
/* BOUTON FLOTTANT LANCEUR                                                   */
/* -------------------------------------------------------------------------- */
#mandir-chat-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #69b3a2 0%, #4a8f80 100%);
  color: #ffffff;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(105, 179, 162, 0.45);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  font-size: 22px;
}

#mandir-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px rgba(105, 179, 162, 0.55);
}

#mandir-chat-launcher:active {
  transform: scale(0.96);
}

#mandir-chat-launcher .mandir-icon-open,
#mandir-chat-launcher .mandir-icon-close {
  position: absolute;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

#mandir-chat-launcher .mandir-icon-open {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#mandir-chat-launcher .mandir-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

#mandir-chatbot-wrapper.open #mandir-chat-launcher .mandir-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

#mandir-chatbot-wrapper.open #mandir-chat-launcher .mandir-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Pastille / Badge d'invitation discret */
#mandir-chat-badge {
  position: absolute;
  bottom: 72px;
  right: 0;
  background: #ffffff;
  color: #212529;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(105, 179, 162, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.3s ease;
  cursor: pointer;
}

#mandir-chat-badge .badge-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

#mandir-chatbot-wrapper:not(.open) #mandir-chat-badge.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* -------------------------------------------------------------------------- */
/* FENÊTRE PRINCIPALE DU CHAT                                                 */
/* -------------------------------------------------------------------------- */
#mandir-chat-window {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 385px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: var(--mc-radius);
  box-shadow: var(--mc-shadow);
  border: 1px solid var(--mc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#mandir-chatbot-wrapper.open #mandir-chat-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* En-tête */
.mandir-chat-header {
  background: linear-gradient(135deg, #212529 0%, #2c3e50 100%);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--mc-primary);
  flex-shrink: 0;
}

.mandir-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mandir-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--mc-primary);
  object-fit: cover;
  background-color: #ffffff;
}

.mandir-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.mandir-header-info p {
  margin: 2px 0 0 0;
  font-size: 11px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mandir-status-indicator {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.mandir-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mandir-header-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 14px;
}

.mandir-header-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Zone des messages */
.mandir-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: var(--mc-gray-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.mandir-chat-body::-webkit-scrollbar {
  width: 6px;
}
.mandir-chat-body::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 3px;
}

/* Bulles de messages */
.mandir-message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: slide-in 0.25s ease forwards;
}

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

.mandir-message.bot {
  align-self: flex-start;
}

.mandir-message.user {
  align-self: flex-end;
}

.mandir-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.mandir-message.bot .mandir-bubble {
  background-color: #ffffff;
  color: var(--mc-text);
  border: 1px solid var(--mc-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.mandir-message.user .mandir-bubble {
  background: linear-gradient(135deg, var(--mc-primary) 0%, var(--mc-primary-dark) 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(105, 179, 162, 0.3);
}

.mandir-msg-time {
  font-size: 10px;
  color: var(--mc-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.mandir-message.user .mandir-msg-time {
  align-self: flex-end;
}

/* Cartes de résultats */
.mandir-chat-card {
  margin-top: 10px;
  background: #ffffff;
  border: 1px solid var(--mc-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.mandir-chat-card:hover {
  border-color: var(--mc-primary);
  box-shadow: 0 6px 16px rgba(105, 179, 162, 0.18);
}

.mandir-card-img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.mandir-card-body {
  padding: 12px;
}

.mandir-card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--mc-primary-dark);
  background-color: var(--mc-primary-light);
  padding: 2px 8px;
  border-radius: 12px;
  margin-bottom: 6px;
  border: 1px solid rgba(105, 179, 162, 0.2);
}

.mandir-card-title {
  margin: 0 0 6px 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--mc-dark);
}

.mandir-card-desc {
  margin: 0 0 10px 0;
  font-size: 12px;
  color: var(--mc-text-muted);
  line-height: 1.4;
}

.mandir-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
  background-color: var(--mc-primary);
  color: #ffffff !important;
  text-decoration: none !important;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.mandir-card-btn:hover {
  background-color: var(--mc-primary-dark);
  color: #ffffff !important;
  transform: translateY(-1px);
}

/* Badges de boutons d'action */
.mandir-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* Indicateur de frappe */
.mandir-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--mc-border);
  width: fit-content;
}

.mandir-typing-dot {
  width: 6px;
  height: 6px;
  background-color: #94a3b8;
  border-radius: 50%;
  animation: typing-blink 1.4s infinite ease-in-out both;
}

.mandir-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.mandir-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.mandir-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typing-blink {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; background-color: var(--mc-primary); }
}

/* Raccourcis de questions (Chips) */
.mandir-chat-chips {
  padding: 10px 14px;
  background-color: #ffffff;
  border-top: 1px solid var(--mc-border);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.mandir-chat-chips::-webkit-scrollbar {
  height: 4px;
}
.mandir-chat-chips::-webkit-scrollbar-thumb {
  background-color: #e2e8f0;
  border-radius: 2px;
}

.mandir-chip-btn {
  background-color: var(--mc-primary-light);
  color: var(--mc-primary-dark);
  border: 1px solid rgba(105, 179, 162, 0.35);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mandir-chip-btn i {
  color: var(--mc-primary);
  font-size: 12px;
}

.mandir-chip-btn:hover {
  background-color: var(--mc-primary);
  color: #ffffff;
  border-color: var(--mc-primary);
  transform: translateY(-1px);
}

.mandir-chip-btn:hover i {
  color: #ffffff;
}

/* Barre de saisie inférieure */
.mandir-chat-footer {
  padding: 10px 14px;
  background-color: #ffffff;
  border-top: 1px solid var(--mc-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mandir-chat-input {
  flex: 1;
  border: 1px solid var(--mc-border);
  border-radius: 20px;
  padding: 9px 15px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
  background-color: var(--mc-gray-bg);
}

.mandir-chat-input:focus {
  border-color: var(--mc-primary);
  background-color: #ffffff;
}

.mandir-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--mc-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-size: 14px;
}

.mandir-chat-send:hover {
  background-color: var(--mc-primary-dark);
  transform: scale(1.05);
}

/* -------------------------------------------------------------------------- */
/* RESPONSIVE SMARTPHONES & TABLETTES (< 600px)                              */
/* -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  #mandir-chatbot-wrapper {
    bottom: 18px;
    right: 18px;
  }

  #mandir-chat-launcher {
    width: 54px;
    height: 54px;
    font-size: 20px;
  }

  #mandir-chat-window {
    width: calc(100vw - 28px);
    right: -4px;
    bottom: 68px;
    height: calc(100vh - 100px);
    max-height: 560px;
    border-radius: 14px;
  }

  #mandir-chat-badge {
    display: none !important;
  }

  .mandir-bubble {
    font-size: 13px;
  }
}
