#skyforce-chatbot-container,
#skyforce-chatbot-container *,
#skyforce-chatbot-container *::before,
#skyforce-chatbot-container *::after {
  box-sizing: border-box;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

#skyforce-chatbot-container {
  --sf-dark:        #0f3f3f;
  --sf-dark-2:      #135050;
  --sf-cyan:        #00cdd0;
  --sf-yellow:      #ffd406;
  --sf-yellow-hover:#ffc406;
  --sf-option:      #f0fffe;
  --sf-bg:          #fafbfc;
  --sf-text:        #1a1a1a;
  --sf-muted:       #6b7280;
  --sf-border:      rgba(15, 23, 42, 0.06);
  --sf-shadow:      0 8px 24px rgba(0,0,0,.10);
  --sf-radius:      20px;
}

.skyforce-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sf-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  padding: 0;
  user-select: none;
  cursor: pointer;
}

.skyforce-chat-bubble:hover {
  transform: translateY(-3px);
}

.skyforce-bubble-icon {
  width: 50px;
  height: 50px;
  display: block;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  object-fit: cover;
}

.skyforce-chat-bubble.rotating .skyforce-bubble-icon {
  animation: bubbleRotate 0.4s ease-in-out;
}

@keyframes bubbleRotate {
  0%   { transform: rotate(0deg)   scale(1);   opacity: 1;   }
  50%  { transform: rotate(180deg) scale(0.8); opacity: 0.5; }
  100% { transform: rotate(360deg) scale(1);   opacity: 1;   }
}

.skyforce-chat-bubble .notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  animation: pulse 2s infinite;
}

.skyforce-chat-bubble.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.6; }
}

@keyframes bubbleEntrance {
  0%   { opacity: 0; transform: translateY(24px) scale(0.65); }
  55%  { opacity: 1; transform: translateY(-5px)  scale(1.08); }
  75%  {             transform: translateY(2px)   scale(0.97); }
  100% { opacity: 1; transform: translateY(0)     scale(1);   }
}

.bubble-entering {
  animation: bubbleEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.skyforce-chat-window {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 100px);
  border-radius: var(--sf-radius);
  box-shadow: var(--sf-shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
  z-index: 999998;
  border: 1px solid var(--sf-border);
  transform-origin: bottom right;
}

.skyforce-chat-window.active {
  display: flex !important;
  animation: chatOpen 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.skyforce-chat-window.closing {
  display: flex !important;
  animation: chatClose 0.22s cubic-bezier(0.4, 0, 0.8, 0.4) forwards;
  pointer-events: none;
}

@keyframes chatOpen {
  from { opacity: 0; transform: scale(0.72) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

@keyframes chatClose {
  from { opacity: 1; transform: scale(1)    translateY(0);    }
  to   { opacity: 0; transform: scale(0.72) translateY(16px); }
}

.skyforce-chat-header {
  background: var(--sf-yellow);
  color: #0b1220;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.bot-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 212, 6, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bot-avatar-img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

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

.bot-info h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  color: #0b1220;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.close-chat,
.refresh-chat {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  outline: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--sf-dark) 0%, var(--sf-dark-2) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15, 63, 63, 0.25);
}

.close-chat:focus,
.refresh-chat:focus {
  outline: none;
  box-shadow: 0 2px 8px rgba(15, 63, 63, 0.25);
}

.close-chat:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 14px rgba(15, 63, 63, 0.35);
}

.refresh-chat:hover {
  transform: rotate(180deg);
  box-shadow: 0 4px 14px rgba(15, 63, 63, 0.35);
}

.chat-date {
  text-align: center;
  padding: 8px 12px 6px;
  background: var(--sf-bg);
  flex-shrink: 0;
}

.date-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--sf-muted);
  background: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--sf-border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.skyforce-chat-messages {
  flex: 1;
  padding: 10px 16px 10px 12px;
  background: var(--sf-bg);
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.skyforce-chat-messages::before {
  content: '';
  flex: 1 1 auto;
}

.skyforce-chat-messages::-webkit-scrollbar { width: 4px; }
.skyforce-chat-messages::-webkit-scrollbar-track { background: transparent; }
.skyforce-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 10px;
}
.skyforce-chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

.message {
  display: flex;
  gap: 7px;
  margin: 7px 0;
  align-items: flex-end;
  flex-shrink: 0;
  animation: messageSlideIn 0.3s ease;
}

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

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar-img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.bot-message .message-content {
  max-width: 75%;
  padding: 8px 11px;
  border-radius: 11px 11px 11px 2px;
  background: #fff;
  border: 1px solid var(--sf-border);
  color: var(--sf-text);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  word-wrap: break-word;
  overflow-wrap: break-word;
  flex-shrink: 0;
}

.bot-message .message-content p {
  margin: 0 0 5px 0;
  font-size: 13px;
  line-height: 1.5;
}

.bot-message .message-content p:last-child { margin-bottom: 0; }

.bot-message .message-content strong {
  font-weight: 600;
  color: var(--sf-dark);
  font-size: 13px;
}

.user-message { flex-direction: row-reverse; }

.user-message .message-content {
  max-width: 80%;
  padding: 8px 11px;
  border-radius: 11px 11px 2px 11px;
  background: #135050;
  border: none;
  color: #f0f0f0;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 6px rgba(0,0,0,0.12);
  word-wrap: break-word;
  overflow-wrap: break-word;
  flex-shrink: 0;
}

.user-message .message-content p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.message-time {
  font-size: 10px;
  font-weight: 500;
  color: rgba(0,0,0,.25);
  margin: 0 4px;
  align-self: flex-end;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 10px 0 0;
  flex-shrink: 0;
}

.quick-reply-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  border: 1.5px solid rgba(15, 63, 63, 0.22);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  color: var(--sf-dark);
  padding: 8px 18px;
  white-space: nowrap;
}

.quick-reply-btn:hover {
  background: rgba(15, 63, 63, 0.05);
  border-color: rgba(15, 63, 63, 0.4);
}

.quick-reply-primary {
  background: var(--sf-dark);
  color: #fff;
  border-color: var(--sf-dark);
  flex: 0 1 100%;
  border-radius: 14px;
  padding: 11px 20px;
}

.quick-reply-primary:hover {
  background: var(--sf-dark-2);
  border-color: var(--sf-dark-2);
  opacity: 0.92;
}

.quick-reply-secondary {
  background: #fff;
  color: var(--sf-dark);
  border-color: rgba(15, 63, 63, 0.22);
}

.quick-reply-secondary:hover {
  background: rgba(15, 63, 63, 0.05);
  border-color: rgba(15, 63, 63, 0.4);
}

.quick-reply-back {
  background: transparent;
  border: 1.5px solid rgba(15, 63, 63, 0.15);
  color: var(--sf-muted);
  font-weight: 500;
  font-size: 12px;
}

.quick-reply-back:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(15, 63, 63, 0.3);
  color: var(--sf-dark);
}

#skyforce-typing-indicator {
  display: none;
  pointer-events: none;
}

#skyforce-typing-indicator.is-visible {
  display: flex;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--sf-bg);
  flex-shrink: 0;
}

.typing-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
}

.typing-avatar img { width: 18px; height: 18px; }

.typing-dots { display: flex; gap: 3px; }

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0,0,0,.3);
  animation: typing 1.4s infinite ease-in-out;
}

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

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

.skyforce-chat-input {
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--sf-border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#skyforce-user-input {
  flex: 1;
  height: 36px;
  border-radius: 18px;
  border: 1.5px solid var(--sf-border);
  padding: 0 12px;
  outline: none;
  font-size: 13px;
  background: var(--sf-bg);
  transition: all 0.2s ease;
  color: var(--sf-text);
}

#skyforce-user-input::placeholder {
  color: var(--sf-muted);
  font-size: 13px;
}

#skyforce-user-input:focus {
  border-color: var(--sf-cyan);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 205, 208, 0.08);
}

#skyforce-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--sf-dark) 0%, var(--sf-dark-2) 100%);
  color: #fff;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15, 63, 63, 0.2);
}

#skyforce-send-btn:hover {
  transform: scale(1.08) rotate(12deg);
  box-shadow: 0 4px 14px rgba(15, 63, 63, 0.3);
}

#skyforce-send-btn .send-icon { width: 16px; height: 16px; }

@media (max-width: 768px) and (min-width: 481px) {
  .skyforce-chat-window {
    width: 420px;
    max-width: calc(100vw - 40px);
    right: 20px;
    bottom: 20px;
    height: 580px;
    max-height: calc(100vh - 80px);
    border-radius: var(--sf-radius);
  }
}

@media (max-width: 480px) and (min-width: 391px) {
  .skyforce-chat-bubble { right: 14px; bottom: 14px; }

  .skyforce-chat-window {
    position: fixed !important;
    right: 12px !important;
    left: 12px !important;
    bottom: 14px !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    height: 80dvh !important;
    max-height: 80dvh !important;
    border-radius: var(--sf-radius) !important;
    border: 1px solid var(--sf-border) !important;
    overflow: hidden;
    transform-origin: bottom center;
  }

  .skyforce-chat-window.active  { animation: chatOpenMobile  0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
  .skyforce-chat-window.closing { animation: chatCloseMobile 0.22s cubic-bezier(0.4, 0, 0.8, 0.4)   forwards; }

  .skyforce-chat-messages { padding: 8px 16px 8px 12px; }
  .bot-message .message-content  { max-width: 85%; font-size: 14px; line-height: 1.5; }
  .bot-message .message-content p { font-size: 14px; line-height: 1.5; }
  .bot-message .message-content strong { font-size: 14px; }
  .user-message .message-content { max-width: 88%; font-size: 14px; line-height: 1.5; }
  .user-message .message-content p { font-size: 14px; }
  .message-time { font-size: 11px; }
  .quick-reply-btn { font-size: 14px; }
  .skyforce-chat-input { padding: 10px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  #skyforce-user-input { height: 42px; font-size: 16px; }
  #skyforce-send-btn   { width: 42px; height: 42px; }
  .quick-replies { gap: 6px; }
  .quick-reply-primary { flex: 0 1 100%; }
}

@media (max-width: 390px) {
  .skyforce-chat-bubble {
    right: 14px;
    bottom: 14px;
    width: 50px;
    height: 50px;
  }

  .skyforce-bubble-icon { width: 30px; height: 30px; }

  .skyforce-chat-window {
    position: fixed !important;
    right: 10px !important;
    left: 10px !important;
    bottom: 14px !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    height: 84dvh !important;
    max-height: 84dvh !important;
    /* Fenêtre flottante : coins arrondis sur les 4 côtés */
    border-radius: var(--sf-radius) !important;
    border: 1px solid var(--sf-border) !important;
    overflow: hidden;
    transform-origin: bottom center;
  }

  .skyforce-chat-window.active  { animation: chatOpenMobile  0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
  .skyforce-chat-window.closing { animation: chatCloseMobile 0.22s cubic-bezier(0.4, 0, 0.8, 0.4)   forwards; }

  .skyforce-chat-header { padding: 12px 14px; }
  .skyforce-chat-messages { padding: 8px 16px 8px 12px; }
  .bot-message .message-content  { max-width: 88%; font-size: 14px; line-height: 1.5; }
  .bot-message .message-content p { font-size: 14px; line-height: 1.5; }
  .bot-message .message-content strong { font-size: 14px; }
  .user-message .message-content { max-width: 90%; font-size: 14px; line-height: 1.5; }
  .user-message .message-content p { font-size: 14px; }
  .message-time { font-size: 11px; }
  .quick-reply-btn { font-size: 14px; }
  .skyforce-chat-input { padding: 10px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  #skyforce-user-input { height: 42px; font-size: 16px; }
  #skyforce-send-btn   { width: 42px; height: 42px; }
  .quick-replies { gap: 6px; }
  .quick-reply-primary { flex: 0 1 100%; }
}

@keyframes chatOpenMobile {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes chatCloseMobile {
  from { opacity: 1; transform: translateY(0)    scale(1);    }
  to   { opacity: 0; transform: translateY(30px) scale(0.97); }
}
#skyforce-user-input {
  flex: 1;
  min-height: 36px;
  max-height: 120px;        /* ~4 lignes max */
  border-radius: 18px;
  border: 1.5px solid var(--sf-border);
  padding: 8px 12px;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  background: var(--sf-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  color: var(--sf-text);
  resize: none;
  overflow-y: hidden;       /* caché tant qu'on n'atteint pas max-height */
  overflow-x: hidden;
  line-height: 1.5;
  display: block;
  box-sizing: border-box;
}

#skyforce-user-input::placeholder {
  color: var(--sf-muted);
  font-size: 13px;
}

#skyforce-user-input:focus {
  border-color: var(--sf-cyan);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 205, 208, 0.08);
}

/* Le bouton doit rester aligné en bas quand le textarea grandit */
.skyforce-chat-input {
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--sf-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;    /* ← flex-end au lieu de center */
  flex-shrink: 0;
}

/* Ajuster les media queries mobiles aussi */
@media (max-width: 480px) and (min-width: 391px) {
  #skyforce-user-input { min-height: 42px; font-size: 16px; }
}
@media (max-width: 390px) {
  #skyforce-user-input { min-height: 42px; font-size: 16px; }
}

#skyforce-scroll-bottom {
  position: absolute;
  bottom: 68px; /* juste au-dessus de la zone de saisie */
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--sf-dark);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
  white-space: nowrap;
}

#skyforce-scroll-bottom.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

#skyforce-scroll-bottom:hover {
  background: var(--sf-dark-2);
}

/* Le parent doit être en position relative */
.skyforce-chat-window {
  position: fixed; /* déjà défini, ajouter : */
  /* rien à changer, overflow:hidden est déjà là */
}

/* Wrapper qui reçoit le position:relative */
.sf-messages-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* skyforce-chat-messages : retirer flex:1 car c'est le wrapper qui le porte */
.skyforce-chat-messages {
  flex: 1;
  padding: 10px 16px 10px 12px;
  background: var(--sf-bg);
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Bouton scroll — positionné dans le wrapper */
#skyforce-scroll-bottom {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--sf-dark);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
  white-space: nowrap;
}

#skyforce-scroll-bottom.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

#skyforce-scroll-bottom:hover {
  background: var(--sf-dark-2);
}