/* ================================================
   CHATBOT IA SKINWRAPS - Pieuvre 3D animée
   Utilise 6 frames d'animation pour un coucou réaliste
   ================================================ */

.chatbot-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: var(--font-body);
}

/* === LAUNCHER (sans cadre, juste la pieuvre flottante) === */
.chatbot-launcher {
  position: relative;
  width: 110px;
  height: 110px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(140px) scale(0.5);
  transition: opacity 0.7s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  filter: drop-shadow(0 12px 30px rgba(168, 19, 140, 0.5));
}

.chatbot-launcher.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chatbot-launcher.hide {
  opacity: 0;
  transform: translateY(140px) scale(0.5);
  pointer-events: none;
}

/* Frames de la pieuvre (toutes superposées, une seule visible à la fois) */
.octopus-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.05s linear;
}

.octopus-frame.active {
  opacity: 1;
}

/* === ÉTAT REPOS (frame 1) - flottement subtil === */
.chatbot-launcher .octopus-frames {
  position: relative;
  width: 100%;
  height: 100%;
  animation: octopus-float 3.5s ease-in-out infinite;
}

@keyframes octopus-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-6px) rotate(1deg); }
}

/* Effet hover : zoom léger */
.chatbot-launcher:hover .octopus-frames {
  animation: octopus-bounce 0.5s ease-in-out;
}

@keyframes octopus-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.08); }
}

/* === Pulse subtil derrière la pieuvre quand coucou === */
.chatbot-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  margin-top: -40px;
  margin-left: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194,25,159,0.4) 0%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.chatbot-launcher.waving .chatbot-pulse-ring {
  animation: chatbot-pulse 1.5s ease-out 3;
}

@keyframes chatbot-pulse {
  0% { transform: scale(0.8); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Notif rouge */
.chatbot-notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border: 2.5px solid white;
  border-radius: 50%;
  font-size: 10px;
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
  z-index: 10;
}

.chatbot-launcher.has-notif .chatbot-notif-dot {
  opacity: 1;
  transform: scale(1);
}

/* === BULLE === */
.chatbot-bubble {
  position: absolute;
  bottom: 130px;
  right: 0;
  background: white;
  color: #1a1a1a;
  padding: 14px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(10px) scale(0.85);
  transform-origin: bottom right;
  transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.chatbot-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  cursor: pointer;
}

.chatbot-bubble-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1a1a1a;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: transform 0.2s ease;
}

.chatbot-bubble-close:hover { transform: scale(1.15); }

/* === FENÊTRE CHAT === */
.chatbot-window {
  position: absolute;
  bottom: 130px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 56px);
  height: 540px;
  max-height: calc(100vh - 180px);
  background: var(--bg-secondary, #111114);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.chatbot-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, #c2199f 0%, #a8138c 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-header-avatar {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

.chatbot-header-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #c2199f;
}

.chatbot-header-avatar img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.chatbot-header-info { flex: 1; min-width: 0; }

.chatbot-header-title {
  font-family: var(--font-display, serif);
  font-weight: 600;
  color: white;
  font-size: 1.05rem;
  line-height: 1.2;
}

.chatbot-header-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 2px;
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.chatbot-close:hover { background: rgba(255, 255, 255, 0.25); }
.chatbot-close svg { width: 18px; height: 18px; }

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-primary, #0a0a0c);
}

.chatbot-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: msg-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

.chatbot-msg.bot {
  background: var(--bg-secondary, #1a1a1f);
  color: var(--text-primary, #fff);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chatbot-msg.user {
  background: linear-gradient(135deg, #c2199f 0%, #a8138c 100%);
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chatbot-msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  align-self: flex-start;
  font-size: 0.85rem;
}

.chatbot-typing {
  align-self: flex-start;
  background: var(--bg-secondary, #1a1a1f);
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

.chatbot-typing span {
  width: 7px;
  height: 7px;
  background: var(--text-tertiary, #888);
  border-radius: 50%;
  animation: typing-dot 1.3s infinite ease-in-out;
}

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

@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chatbot-input-area {
  padding: 14px 16px;
  background: var(--bg-secondary, #111114);
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  padding: 11px 16px;
  background: var(--bg-primary, #0a0a0c);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 22px;
  color: var(--text-primary, #fff);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.chatbot-input:focus { border-color: var(--accent, #a8138c); }
.chatbot-input::placeholder { color: var(--text-tertiary, #666); }

.chatbot-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c2199f 0%, #a8138c 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) { transform: scale(1.1); }
.chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chatbot-send svg { width: 18px; height: 18px; }

@media (max-width: 600px) {
  .chatbot-container {
    bottom: 16px;
    right: 12px;
  }

  .chatbot-launcher {
    width: 90px;
    height: 90px;
  }

  .chatbot-window {
    width: calc(100vw - 24px);
    height: 500px;
    max-height: calc(100vh - 160px);
    bottom: 105px;
    right: 0;
  }

  .chatbot-bubble {
    font-size: 0.85rem;
    padding: 12px 14px;
    bottom: 105px;
    max-width: calc(100vw - 56px);
    white-space: normal;
  }
}
