/**
 * Certiwize - Styles du chatbot
 */

/* ============================================
   CONTENEUR PRINCIPAL
   ============================================ */

.chatbot-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  font-family: inherit;
}

/* ============================================
   BOUTON D'OUVERTURE
   ============================================ */

.chatbot-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  border: none;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(124, 58, 237, 0.5);
}

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

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: transform 0.3s ease;
}

/* Badge de notification */
.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  background: #EF4444;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  animation: pulse 2s infinite;
}

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

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

/* ============================================
   FENÊTRE DE CHAT
   ============================================ */

.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

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

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

/* ============================================
   HEADER
   ============================================ */

.chatbot-header {
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.chatbot-minimize {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chatbot-minimize svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ============================================
   ZONE DE MESSAGES
   ============================================ */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-elev);
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

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

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

/* ============================================
   MESSAGES
   ============================================ */

.chatbot-message {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

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

.chatbot-message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.5;
}

.chatbot-message-user .chatbot-message-content {
  background: var(--brand);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chatbot-message-bot .chatbot-message-content {
  background: var(--bg);
  color: var(--text);
  align-self: flex-start;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom-left-radius: 4px;
}

.dark .chatbot-message-bot .chatbot-message-content {
  background: var(--bg-elev);
  border-color: rgba(255, 255, 255, 0.1);
}

.chatbot-message-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  align-self: flex-end;
}

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

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

/* Support du markdown dans les messages */
.chatbot-message-content strong {
  font-weight: 600;
}

.chatbot-message-content em {
  font-style: italic;
}

.chatbot-message-content code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

/* ============================================
   INDICATEUR DE FRAPPE
   ============================================ */

.chatbot-typing {
  display: flex;
  align-items: center;
  padding: 0 20px 12px;
  background: var(--bg-elev);
}

.chatbot-typing.hidden {
  display: none;
}

.chatbot-typing-indicator {
  display: flex;
  gap: 4px;
}

.chatbot-typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: 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 typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ============================================
   INPUT ET ENVOI
   ============================================ */

.chatbot-input-container {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.dark .chatbot-input-container {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.chatbot-input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s;
}

.dark .chatbot-input {
  border-color: rgba(255, 255, 255, 0.1);
}

.chatbot-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}

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

.chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
  background: var(--brand-600);
  transform: scale(1.05);
}

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

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

.chatbot-send svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ============================================
   FOOTER
   ============================================ */

.chatbot-footer {
  padding: 8px 20px;
  text-align: center;
  background: var(--bg);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.dark .chatbot-footer {
  border-top-color: rgba(255, 255, 255, 0.05);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
  }
}