/* =====================================================
   Alfred Chat Widget — styles
   Palette : variables du site (--bg-card, --accent, …)
   ===================================================== */

/* ---------- Bouton flottant ---------- */
#alfredLauncher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--border, #2a2a3e);
  background: linear-gradient(135deg, var(--accent, #6366f1), #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: alfred-pop 0.5s ease both 0.8s;
}
#alfredLauncher:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}
#alfredLauncher.active {
  transform: rotate(90deg) scale(1.05);
}
#alfredLauncher .alfred-launcher-face {
  font-size: 1.7rem;
  line-height: 1;
}
#alfredLauncher .alfred-launcher-pulse {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 2px solid var(--accent-light, #818cf8);
  opacity: 0;
  animation: alfred-pulse 2.4s ease-out infinite 2s;
  pointer-events: none;
}
@keyframes alfred-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes alfred-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ---------- Panneau ---------- */
.alfred-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 2000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #2a2a3e);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.alfred-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ---------- En-tête ---------- */
.alfred-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.10));
  border-bottom: 1px solid var(--border, #2a2a3e);
}
.alfred-header-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.alfred-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary, #12121a);
  border: 1px solid var(--border, #2a2a3e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.alfred-header-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.alfred-header-text strong {
  font-size: 1rem;
  color: var(--text-primary, #fff);
}
.alfred-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted, #6a6a80);
}
.alfred-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success, #10b981);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: alfred-pulse-dot 2s infinite;
}
@keyframes alfred-pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
.alfred-close {
  background: none;
  border: none;
  color: var(--text-secondary, #a0a0b0);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}
.alfred-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #fff);
}

/* ---------- Corps (messages) ---------- */
.alfred-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-secondary, #12121a);
  scroll-behavior: smooth;
}
.alfred-body::-webkit-scrollbar { width: 8px; }
.alfred-body::-webkit-scrollbar-thumb {
  background: var(--border, #2a2a3e);
  border-radius: 4px;
}
.alfred-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
}
.alfred-msg--alfred { align-self: flex-start; }
.alfred-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.alfred-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #2a2a3e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.alfred-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary, #fff);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.alfred-msg--alfred .alfred-bubble {
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #2a2a3e);
  border-top-left-radius: 4px;
}
.alfred-msg--user .alfred-bubble {
  background: linear-gradient(135deg, var(--gradient-start, #6366f1), var(--gradient-end, #8b5cf6));
  border-top-right-radius: 4px;
}
.alfred-bubble strong { color: var(--accent-light, #818cf8); font-weight: 700; }
.alfred-msg--user .alfred-bubble strong { color: #fff; }
.alfred-bubble code {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border, #2a2a3e);
  padding: 1px 6px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}
.alfred-li { color: var(--success, #10b981); font-weight: 700; }

/* ---------- Indicateur "réfléchit…" ---------- */
.alfred-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 4px;
  font-size: 0.85rem;
  color: var(--text-muted, #6a6a80);
  background: var(--bg-secondary, #12121a);
}
.alfred-typing[hidden] { display: none; }
.alfred-typing-dots { display: inline-flex; gap: 4px; }
.alfred-typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-light, #818cf8);
  animation: alfred-typing-bounce 1.2s infinite;
}
.alfred-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.alfred-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes alfred-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Barre de saisie ---------- */
.alfred-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--bg-card, #1a1a2e);
  border-top: 1px solid var(--border, #2a2a3e);
}
.alfred-inputbar textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  background: var(--bg-secondary, #12121a);
  border: 1px solid var(--border, #2a2a3e);
  border-radius: 10px;
  color: var(--text-primary, #fff);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.45;
  transition: border-color 0.2s ease;
}
.alfred-inputbar textarea:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
}
.alfred-inputbar textarea::placeholder { color: var(--text-muted, #6a6a80); }
.alfred-send {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gradient-start, #6366f1), var(--gradient-end, #8b5cf6));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.alfred-send:hover:not(:disabled) { transform: translateY(-2px); }
.alfred-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Note de pied ---------- */
.alfred-footer-note {
  padding: 6px 12px 10px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted, #6a6a80);
  background: var(--bg-card, #1a1a2e);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  #alfredLauncher { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .alfred-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: calc(100vh - 80px);
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
    border-right: none;
    border-bottom: none;
  }
}
