/* ============================================
   CHATBOT OEIL GUINÉE - UX & Identité projet
   ============================================ */

/* Container & position */
.chatbot-widget {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Bouton d'ouverture */
.chatbot-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark, #1E40AF) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.2));
  transition: transform 0.2s var(--ease, cubic-bezier(0.4, 0, 0.2, 1)),
              box-shadow 0.2s,
              opacity 0.2s;
}

.chatbot-toggle:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px -4px rgba(37, 99, 235, 0.4);
}

.chatbot-toggle:focus-visible {
  outline: 3px solid rgba(13, 148, 136, 0.5);
  outline-offset: 2px;
}

.chatbot-toggle i {
  font-size: 1.25rem;
}

.chatbot-toggle .chatbot-toggle__label {
  display: none;
}

@media (min-width: 640px) {
  .chatbot-toggle .chatbot-toggle__label {
    display: inline;
  }
}

/* Panneau */
.chatbot-panel {
  position: absolute;
  bottom: 4rem;
  right: 0;
  width: min(380px, calc(100vw - 2rem));
  max-height: 75vh;
  background: var(--bg-dark, #0f172a);
  border-radius: var(--radius-lg, 1rem);
  box-shadow: var(--shadow-card, 0 10px 30px -10px rgba(0,0,0,0.5)),
              0 0 0 1px var(--surface-border, rgba(255,255,255,0.08));
  border: 1px solid var(--surface-border, rgba(255,255,255,0.1));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition: opacity 0.25s var(--ease, cubic-bezier(0.4, 0, 0.2, 1)),
              transform 0.25s var(--ease);
}

.chatbot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chatbot-panel[hidden] {
  display: none !important;
}

/* En-tête avec identité Oeil Guinée */
.chatbot-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark, #1E40AF) 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chatbot-panel__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chatbot-panel__brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.chatbot-panel__brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.chatbot-panel__brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chatbot-panel__brand-tagline {
  margin: 0;
  font-size: 0.7rem;
  opacity: 0.9;
  font-weight: 400;
}

.chatbot-panel__header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chatbot-header-btn,
.chatbot-panel__close {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm, 0.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chatbot-header-btn:hover,
.chatbot-panel__close:hover {
  background: rgba(255,255,255,0.25);
}

.chatbot-header-btn:focus-visible,
.chatbot-panel__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.chatbot-panel__close {
  font-size: 1.4rem;
}

/* Indicateur "Assistant disponible" */
.chatbot-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  margin-right: 0.35rem;
  vertical-align: middle;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.4);
  animation: chatbot-status-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Corps du panneau : ordre = questions (compact) → messages (espace principal) → saisie */
.chatbot-panel__body {
  padding: 1rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

/* Bandeau questions fréquentes : compact, ne vole pas l’espace des réponses */
.chatbot-suggested-section {
  flex-shrink: 0;
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--surface-border, rgba(255,255,255,0.12));
  background: var(--bg-dark, #0f172a);
}

.chatbot-suggested-label {
  margin: 0 0 0.5rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chatbot-suggested {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 4.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.chatbot-suggested button {
  padding: 0.4rem 0.7rem;
  background: var(--surface-glass, rgba(30, 41, 59, 0.6));
  color: var(--text-main, #f1f5f9);
  border: 1px solid var(--surface-border, rgba(255,255,255,0.1));
  border-radius: var(--radius-full, 9999px);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.chatbot-suggested button:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

.chatbot-suggested button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Zone messages : occupe tout l’espace disponible, réponses toujours visibles */
.chatbot-messages {
  flex: 1 1 0;
  min-height: 140px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
  -webkit-overflow-scrolling: touch;
  contain: layout;
}

/* Message bienvenue */
.chatbot-welcome {
  padding: 1rem;
  background: var(--primary-light, rgba(13, 148, 136, 0.12));
  border-radius: var(--radius, 0.75rem);
  border-left: 4px solid var(--primary);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-main, #f1f5f9);
}

.chatbot-welcome strong {
  color: var(--primary-light, #93c5fd);
}

/* Bulles de message */
.chatbot-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 100%;
  min-width: 0;
  animation: chatbot-msg-in 0.3s var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

@keyframes chatbot-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 90%;
}

.chatbot-msg--bot {
  align-self: flex-start;
  max-width: 95%;
}

.chatbot-msg--bot .chatbot-msg__bubble {
  max-width: 320px;
}

.chatbot-msg__bubble {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  text-align: left;
  white-space: normal;
}

.chatbot-msg--user .chatbot-msg__bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.chatbot-msg--bot .chatbot-msg__bubble {
  background: var(--surface-glass, rgba(30, 41, 59, 0.8));
  color: var(--text-main, #f1f5f9);
  border: 1px solid var(--surface-border, rgba(255,255,255,0.08));
  border-bottom-left-radius: 4px;
}

.chatbot-msg__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chatbot-msg--user .chatbot-msg__icon {
  background: var(--primary-dark, #1E40AF);
  color: #fff;
}

.chatbot-msg--bot .chatbot-msg__icon {
  background: var(--guinee-green, #009460);
  color: #fff;
}

/* Typing indicator */
.chatbot-typing {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  background: var(--surface-glass, rgba(30, 41, 59, 0.8));
  border-radius: 1rem;
  border-bottom-left-radius: 4px;
  width: fit-content;
  animation: chatbot-msg-in 0.3s var(--ease);
}

.chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted, #94a3b8);
  animation: chatbot-typing-bounce 1.2s ease-in-out infinite;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}


/* Zone saisie */
.chatbot-input-wrap {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--surface-border, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

.chatbot-input-row {
  display: flex;
  gap: 0.5rem;
}

.chatbot-char-count {
  margin: 0.35rem 0 0 0;
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  text-align: right;
}

.chatbot-char-count[data-near-limit="true"] {
  color: var(--accent, #f59e0b);
}

.chatbot-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--surface-border, rgba(255,255,255,0.1));
  border-radius: var(--radius, 0.75rem);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main, #f1f5f9);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chatbot-input::placeholder {
  color: var(--text-muted, #94a3b8);
}

.chatbot-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.22);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius, 0.75rem);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.2s, transform 0.15s;
}

.chatbot-send:hover {
  background: var(--primary-dark, #1E40AF);
  transform: scale(1.05);
}

.chatbot-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.chatbot-send:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Pied du panneau : liens rapides */
.chatbot-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--surface-border, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

.chatbot-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted, #94a3b8);
  text-decoration: none;
  transition: color 0.2s;
}

.chatbot-footer-link:hover {
  color: var(--primary, #3b82f6);
}

.chatbot-footer-link i {
  font-size: 0.8rem;
  opacity: 0.9;
}

/* Mobile : zone messages plus courte pour laisser la place aux suggestions et à la saisie */
@media (max-width: 480px) {
  .chatbot-panel {
    bottom: 3.5rem;
    width: calc(100vw - 1.5rem);
    right: 0.75rem;
    max-height: 85vh;
  }

  .chatbot-messages {
    max-height: 200px;
  }

  .chatbot-suggested-section {
    padding-top: 0.75rem;
    margin-top: 0.5rem;
  }

  .chatbot-suggested button {
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
  }

  .chatbot-widget {
    bottom: 1rem;
    right: 1rem;
  }
}
