/**
 * Styles du Chatbot IA RNI France
 * Widget flottant moderne et responsive
 */

/* ========== VARIABLES ========== */
:root {
  --chatbot-primary: #18ABF8;
  --chatbot-primary-dark: #0e6fa8;
  --chatbot-primary-light: #4FC3F7;
  --chatbot-white: #FFFFFF;
  --chatbot-gray-50: #FAFAFA;
  --chatbot-gray-100: #F5F5F5;
  --chatbot-gray-200: #EEEEEE;
  --chatbot-gray-300: #E0E0E0;
  --chatbot-gray-700: #616161;
  --chatbot-gray-900: #212121;
  --chatbot-success: #28a745;
  --chatbot-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  --chatbot-shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.2);
  --chatbot-radius: 16px;
  --chatbot-radius-sm: 8px;
  --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== BOUTON FLOTTANT ========== */
.chatbot-floating-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  border-radius: 50%;
  box-shadow: var(--chatbot-shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: var(--chatbot-transition);
  animation: chatbot-bounce 2s infinite;
}

.chatbot-floating-button:hover {
  transform: scale(1.1);
  box-shadow: 0 16px 32px rgba(24, 171, 248, 0.4);
}

.chatbot-floating-button.chatbot-button-hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.chatbot-button-icon {
  color: var(--chatbot-white);
  font-size: 28px;
  position: relative;
}

.chatbot-button-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--chatbot-success);
  color: var(--chatbot-white);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: chatbot-pulse 2s infinite;
}

/* Animation de rebond */
@keyframes chatbot-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes chatbot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ========== FENÊTRE DE CHAT ========== */
.chatbot-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 48px);
  background: var(--chatbot-white);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transition: var(--chatbot-transition);
}

.chatbot-window.chatbot-hidden {
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

.chatbot-window.chatbot-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ========== EN-TÊTE ========== */
.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  color: var(--chatbot-white);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 48px;
  height: 48px;
  background: var(--chatbot-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  padding: 6px;
}

.chatbot-avatar .chatbot-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}

.chatbot-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chatbot-name {
  font-weight: 600;
  font-size: 16px;
}

.chatbot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.chatbot-status-dot {
  width: 8px;
  height: 8px;
  background: var(--chatbot-success);
  border-radius: 50%;
  animation: chatbot-pulse 2s infinite;
}

.chatbot-close-btn {
  background: transparent;
  border: none;
  color: var(--chatbot-white);
  font-size: 24px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-transition);
}

.chatbot-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* ========== ZONE DE MESSAGES ========== */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--chatbot-gray-50);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Scrollbar personnalisée */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-gray-300);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-gray-700);
}

/* ========== MESSAGES ========== */
.chatbot-message {
  display: flex;
  gap: 8px;
  animation: chatbot-fadeIn 0.3s ease-out;
}

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

.chatbot-message-user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.chatbot-message-bot {
  flex-direction: row;
}

.chatbot-avatar-small {
  width: 32px;
  height: 32px;
  background: var(--chatbot-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  padding: 4px;
}

.chatbot-avatar-small .chatbot-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}

.chatbot-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--chatbot-radius-sm);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chatbot-message-user .chatbot-message-content {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  color: var(--chatbot-white);
  border-bottom-right-radius: 4px;
}

.chatbot-message-bot .chatbot-message-content {
  background: var(--chatbot-white);
  color: var(--chatbot-gray-900);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chatbot-message-content strong {
  font-weight: 600;
}

.chatbot-message-content a {
  color: var(--chatbot-primary);
  text-decoration: underline;
}

.chatbot-message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.chatbot-message-content li {
  margin: 4px 0;
}

.chatbot-message-content code {
  background: var(--chatbot-gray-200);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.chatbot-message-time {
  font-size: 11px;
  color: var(--chatbot-gray-700);
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}

.chatbot-message-user .chatbot-message-time {
  text-align: left;
}

/* ========== INDICATEUR DE FRAPPE ========== */
.chatbot-typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.chatbot-typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-gray-700);
  border-radius: 50%;
  animation: chatbot-typing 1.4s infinite;
}

.chatbot-typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatbot-typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ========== INSTRUCTIONS API ========== */
.chatbot-api-instructions {
  background: var(--chatbot-gray-100);
  padding: 16px;
  border-radius: var(--chatbot-radius-sm);
  margin-top: 8px;
}

.chatbot-api-instructions h4 {
  margin: 0 0 12px 0;
  color: var(--chatbot-primary);
  font-size: 14px;
}

.chatbot-api-instructions ol {
  margin: 8px 0;
  padding-left: 20px;
}

.chatbot-api-instructions li {
  margin: 6px 0;
  font-size: 13px;
}

.chatbot-api-instructions p {
  margin: 12px 0 0 0;
  font-size: 12px;
  color: var(--chatbot-gray-700);
}

/* ========== ZONE D'INPUT ========== */
.chatbot-input-container {
  border-top: 1px solid var(--chatbot-gray-200);
  background: var(--chatbot-white);
}

.chatbot-input-wrapper {
  display: flex;
  gap: 8px;
  padding: 16px;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  border: 2px solid var(--chatbot-gray-200);
  border-radius: 24px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: var(--chatbot-transition);
  font-family: inherit;
}

.chatbot-input:focus {
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(24, 171, 248, 0.1);
}

.chatbot-input::placeholder {
  color: var(--chatbot-gray-700);
  opacity: 0.6;
}

.chatbot-send-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  border: none;
  border-radius: 50%;
  color: var(--chatbot-white);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-transition);
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(24, 171, 248, 0.4);
}

.chatbot-send-btn:active {
  transform: scale(0.95);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== SUGGESTIONS RAPIDES ========== */
.chatbot-suggestions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chatbot-suggestions::-webkit-scrollbar {
  display: none;
}

.chatbot-suggestion-btn {
  background: var(--chatbot-gray-100);
  border: 1px solid var(--chatbot-gray-300);
  border-radius: 16px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--chatbot-gray-900);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--chatbot-transition);
  flex-shrink: 0;
}

.chatbot-suggestion-btn:hover {
  background: var(--chatbot-primary);
  color: var(--chatbot-white);
  border-color: var(--chatbot-primary);
  transform: translateY(-2px);
}

/* ========== FOOTER ========== */
.chatbot-footer {
  padding: 12px 16px;
  background: var(--chatbot-gray-50);
  border-top: 1px solid var(--chatbot-gray-200);
  text-align: center;
}

.chatbot-powered {
  font-size: 11px;
  color: var(--chatbot-gray-700);
  opacity: 0.7;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .chatbot-floating-button {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .chatbot-button-icon {
    font-size: 24px;
  }

  .chatbot-button-badge {
    display: none;
  }

  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .chatbot-message-content {
    max-width: 85%;
    font-size: 13px;
  }

  .chatbot-input {
    font-size: 16px; /* Éviter le zoom sur iOS */
  }
}

@media (max-width: 480px) {
  .chatbot-suggestions {
    padding: 0 12px 12px 12px;
  }

  .chatbot-suggestion-btn {
    font-size: 11px;
    padding: 6px 12px;
  }
}

/* ========== MODE SOMBRE (optionnel) ========== */
@media (prefers-color-scheme: dark) {
  /* Désactivé pour l'instant - peut être ajouté plus tard */
}
