/* ============================================
   CHATBOT WIDGET - SK WEB
   ============================================ */

/* Bouton flottant */
.chatbot-button {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 6rem;
  height: 6rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.2);
  z-index: 9998;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
}

.chatbot-button.visible {
  opacity: 1;
  transform: scale(1);
}

.chatbot-button:hover {
  transform: scale(1.1);
  box-shadow: 0 0.6rem 2rem rgba(0, 0, 0, 0.3);
}

.chatbot-button svg {
  width: 3rem;
  height: 3rem;
  fill: white;
}

/* Bulle d'accroche */
.chatbot-bubble {
  position: fixed;
  bottom: 9rem;
  left: 2rem;
  background: white;
  padding: 1.2rem 1.6rem;
  border-radius: 1.2rem;
  box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.15);
  z-index: 9997;
  max-width: 25rem;
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s ease;
  pointer-events: none;
}

.chatbot-bubble.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chatbot-bubble p {
  margin: 0;
  font-size: 1.4rem;
  color: black;
  line-height: 1.5;
}

.chatbot-bubble::after {
  content: '';
  position: absolute;
  bottom: -0.8rem;
  left: 3rem;
  width: 0;
  height: 0;
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-top: 1rem solid white;
}

.chatbot-bubble-close {
  position: absolute;
  top: -0.4rem;
  right: 0.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: var(--color-text-muted);
  font-size: 1.6rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.chatbot-bubble-close:hover {
  opacity: 1;
}

/* Fenêtre de chat */
.chatbot-window {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 40rem;
  height: 60rem;
  background: white;
  border-radius: 0 1.2rem 0 0;
  box-shadow: 0.4rem 0 2rem rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.chatbot-window.open {
  transform: translateX(0);
}

/* Header du chat */
.chatbot-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: white;
  padding: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0 1.2rem 0 0;
}

.chatbot-header-info h3 {
  margin: 0 0 0.4rem 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.chatbot-header-info p {
  margin: 0;
  font-size: 1.2rem;
  opacity: 0.9;
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-close svg {
  width: 2rem;
  height: 2rem;
  stroke: white;
}

/* Zone de messages */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--color-secondary-light);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chatbot-message {
  display: flex;
  gap: 1rem;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.bot {
  align-self: flex-start;
}

.chatbot-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-avatar {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-avatar svg {
  width: 2rem;
  height: 2rem;
  fill: white;
}

.user .chatbot-avatar {
  background: var(--color-accent);
}

.chatbot-message-content {
  background: white;
  padding: 1.2rem 1.6rem;
  border-radius: 1.6rem;
  max-width: 75%;
  box-shadow: 0 0.2rem 0.4rem rgba(0, 0, 0, 0.1);
}

.user .chatbot-message-content {
  background: var(--color-primary-light);
  color: white;
}

.chatbot-message-content p {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.6;
  color: black;
}

.chatbot-timestamp {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
  opacity: 0.7;
}

/* Indicateur de typing */
.chatbot-typing {
  display: flex;
  gap: 0.4rem;
  padding: 1.2rem;
}

.chatbot-typing span {
  width: 0.8rem;
  height: 0.8rem;
  background: var(--color-primary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-0.8rem);
    opacity: 1;
  }
}

/* Suggestions rapides */
.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 0 2rem 1rem;
  background: var(--color-secondary-light);
}

.chatbot-suggestion {
  background: white;
  border: 1px solid var(--color-border);
  padding: 0.8rem 1.2rem;
  border-radius: 2rem;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  color: black;
}

.chatbot-suggestion:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Input zone */
.chatbot-input-wrapper {
  padding: 1.6rem 2rem;
  background: white;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 1rem;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 2.4rem;
  padding: 1.2rem 1.6rem;
  font-size: 1.6rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chatbot-input:focus {
  border-color: var(--color-primary);
}

.chatbot-send {
  background: var(--color-primary);
  border: none;
  color: white;
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
  background: var(--color-accent);
  transform: scale(1.05);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send svg {
  width: 2rem;
  height: 2rem;
  fill: white;
}

/* Responsive */
@media (max-width: 768px) {
  .chatbot-window {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport pour iOS */
    border-radius: 0;
    overflow: hidden;
  }
  
  .chatbot-header {
    border-radius: 0;
    padding-top: calc(2rem + env(safe-area-inset-top));
  }
  
  .chatbot-messages {
    width: 100%;
    box-sizing: border-box;
  }
  
  .chatbot-suggestions {
    width: 100%;
    box-sizing: border-box;
  }
  
  .chatbot-input-wrapper {
    width: 100%;
    box-sizing: border-box;
  }
  
  .chatbot-input {
    font-size: 1.6rem;
    min-width: 0;
  }
  
  .chatbot-button {
    bottom: 1.5rem;
    left: 1.5rem;
    width: 5.6rem;
    height: 5.6rem;
  }
  
  .chatbot-bubble {
    left: 1.5rem;
    bottom: 8rem;
    max-width: calc(100vw - 3rem);
  }
}

/* Bloquer le scroll du body quand chatbot ouvert */
body.chatbot-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  touch-action: none;
}

/* Scrollbar custom */
.chatbot-messages::-webkit-scrollbar {
  width: 0.6rem;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 0.3rem;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}
