/* =========================================
   Karbonn Chatbot — Kaï
   ========================================= */

/* ---- Invite bar (bouton flottant animé) ---- */
#kai-invite {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 56px;
  padding: 8px 18px 8px 8px;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: inviteSlideIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

@keyframes inviteSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#kai-invite:hover {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

#kai-invite.hidden {
  display: none;
}

.kai-invite-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.12);
}

.kai-invite-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kai-invite-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}

.kai-invite-tagline {
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  max-width: 180px;
}

/* Texte qui se tape lettre par lettre */
.kai-invite-tagline::after {
  content: '|';
  animation: blink-cursor 0.9s step-end infinite;
  color: var(--accent, #0c04ff);
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.kai-invite-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse-green 2s ease-out infinite;
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ---- Bouton fermer (X) quand fenêtre ouverte ---- */
#kai-close-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9001;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: color 0.2s ease, border-color 0.2s ease;
}

#kai-close-btn.visible {
  display: flex;
}

#kai-close-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* ---- Overlay flouté ---- */
#kai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8998;
  background: rgba(0, 0, 0, 0.615);
  backdrop-filter: blur(28px) saturate(1.2);
  -webkit-backdrop-filter: blur(28px) saturate(1.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#kai-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

/* ---- Fenêtre de chat (plein écran centré, glassmorphisme) ---- */
#karbonn-chat-window {
  position: fixed;
  inset: 0;
  z-index: 8999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: transparent;
  transform: scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#karbonn-chat-window.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Conteneur intérieur glassmorphisme */
.chat-glass-inner {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Header avec avatar Kaï ---- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.chat-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.chat-status-label {
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.06em;
}

/* ---- Messages ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  min-height: 280px;
  max-height: calc(100vh - 260px);
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 2px; }

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.55;
  animation: bubbleIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.chat-bubble.bot {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  background: var(--accent, #0c04ff);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ---- Typing ---- */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: typing 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
  30%           { opacity: 1;    transform: scale(1.15); }
}

/* ---- Error ---- */
.chat-error {
  font-family: "Source Code Pro", monospace;
  font-size: 11px;
  color: rgba(239, 68, 68, 0.8);
  text-align: center;
  padding: 6px;
  align-self: center;
}

/* ---- Suggestions ---- */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
  width: 100%;
  margin-bottom: 2px;
}

.chat-suggestion-btn {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 7px 14px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  text-align: left;
  width: fit-content;
  max-width: 100%;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.chat-suggestion-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
}

/* ---- Input area ---- */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 4px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 100px;
  line-height: 1.5;
}

.chat-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.chat-input:focus { outline: none; }

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent, #0c04ff);
  border: none;
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) { opacity: 0.85; transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---- Mobile ---- */
@media (max-width: 480px) {
  #karbonn-chat-window {
    padding: 16px 12px;
  }

  .chat-glass-inner {
    max-height: calc(100vh - 32px);
  }

  .chat-messages {
    max-height: calc(100vh - 220px);
  }

  .chat-input {
    font-size: 16px;
  }

  #kai-invite,
  #kai-close-btn {
    right: 14px;
    bottom: 20px;
  }
}
