/* ============================================================
   AI CHATBOT DRAWER — CrypView
   À ajouter à la fin de styles/index.css (landing page)
   ou dans un fichier séparé styles/ai-drawer.css
   ============================================================ */

/* ── Bouton "Assistant IA" dans la nav ──────────────────────── */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0, 255, 136, 0.07);
  border: 1px solid rgba(0, 255, 136, 0.35);
  padding: 8px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-ai-btn:hover {
  background: rgba(0, 255, 136, 0.14);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.15);
}

/* Icône IA (étoile SVG inline) */
.nav-ai-btn .ai-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── Overlay sombre derrière le drawer ──────────────────────── */
#ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#ai-overlay.open {
  display: block;
}

#ai-overlay.visible {
  opacity: 1;
}

/* ── Panneau latéral (drawer) ───────────────────────────────── */
#ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  z-index: 9001;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 48px rgba(0, 0, 0, 0.6);
}

#ai-drawer.open {
  transform: translateX(0);
}

/* ── En-tête du drawer ──────────────────────────────────────── */
.ai-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.ai-drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-drawer-title-icon {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(0, 255, 136, 0.3);
  background: rgba(0, 255, 136, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-drawer-title-icon svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.ai-drawer-title-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ai-drawer-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.ai-drawer-sub {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Indicateur live dans l'en-tête */
.ai-drawer-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 0.12em;
  margin-left: auto;
  margin-right: 14px;
}

.ai-drawer-live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

/* Bouton de fermeture */
.ai-drawer-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
  padding: 0;
  min-height: unset;
}

.ai-drawer-close:hover {
  color: var(--red, #ff3d5a);
  border-color: var(--red, #ff3d5a);
  background: rgba(255, 61, 90, 0.07);
}

/* ── Corps du drawer ────────────────────────────────────────── */
.ai-drawer-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Pied du drawer ─────────────────────────────────────────── */
.ai-drawer-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════
   CHAT UI — Messages & Input
   ══════════════════════════════════════════════════════════════ */

/* ── Zone de messages scrollable ───────────────────────────── */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar custom */
.ai-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 136, 0.3);
}

/* ── Bulle générique ────────────────────────────────────────── */
.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 90%;
  animation: msgIn 0.2s ease;
}

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

/* Bot → gauche */
.ai-msg--bot {
  align-self: flex-start;
  align-items: flex-start;
}

/* User → droite */
.ai-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.ai-msg-bubble {
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.6;
  font-family: 'DM Mono', monospace;
  word-break: break-word;
}

/* Bulle bot */
.ai-msg--bot .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-left: 2px solid rgba(0, 255, 136, 0.5);
  color: var(--text, #e2e8f0);
  border-radius: 0 6px 6px 0;
}

/* Bulle user */
.ai-msg--user .ai-msg-bubble {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: var(--accent);
  border-radius: 6px 0 0 6px;
}

/* Horodatage */
.ai-msg-time {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.07em;
  padding: 0 2px;
}

/* Inline code dans les bulles */
.ai-msg-bubble code {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.ai-msg-bubble strong {
  color: var(--accent);
  font-weight: 600;
}

/* ── Indicateur "en train de taper" ────────────────────────── */
.ai-msg--typing .ai-msg-bubble {
  padding: 12px 16px;
}

.ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 14px;
}

.ai-typing-dots span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

/* ── Message d'erreur ───────────────────────────────────────── */
.ai-msg--error .ai-msg-bubble {
  border-left-color: var(--red, #ff3d5a);
  color: var(--red, #ff3d5a);
  background: rgba(255, 61, 90, 0.05);
}

/* ── Zone de saisie ─────────────────────────────────────────── */
.ai-chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.ai-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 8px 10px;
  transition: border-color 0.2s;
}

.ai-input-wrapper:focus-within {
  border-color: rgba(0, 255, 136, 0.4);
  box-shadow: 0 0 0 1px rgba(0, 255, 136, 0.1);
}

.ai-chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text, #e2e8f0);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: none;
  min-height: 20px;
  max-height: 120px;
  overflow-y: auto;
  padding: 0;
  caret-color: var(--accent);
}

.ai-chat-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.ai-send-btn {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: var(--accent);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  border-radius: 3px;
  padding: 0;
  min-height: unset;
}

.ai-send-btn:hover:not(:disabled) {
  background: rgba(0, 255, 136, 0.2);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.15);
}

.ai-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Suggestions rapides (initial state) ────────────────────── */
.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
}

.ai-suggestion-chip {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  border-radius: 2px;
  white-space: nowrap;
}

.ai-suggestion-chip:hover {
  color: var(--accent);
  border-color: rgba(0, 255, 136, 0.4);
  background: rgba(0, 255, 136, 0.06);
}

/* ── Responsive mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-ai-btn {
    padding: 6px 12px;
    font-size: 10px;
    gap: 5px;
  }

  #ai-drawer {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .ai-drawer-header {
    padding: 12px 14px;
  }
}

@media (max-width: 480px) {
  .nav-ai-btn .ai-btn-label {
    display: none;
  }

  .nav-ai-btn {
    padding: 7px 10px;
  }
}

/* ── Light theme ────────────────────────────────────────────── */
.light-theme #ai-drawer {
  background: #ffffff;
  border-left-color: #d0d7e3;
  box-shadow: -8px 0 48px rgba(0, 0, 0, 0.15);
}

.light-theme .ai-drawer-header {
  background: rgba(0, 0, 0, 0.03);
  border-bottom-color: #d0d7e3;
}

.light-theme .ai-drawer-close {
  border-color: #d0d7e3;
}

.light-theme .ai-drawer-footer {
  border-top-color: #d0d7e3;
}

.light-theme .nav-ai-btn {
  color: #005c30;
  background: rgba(0, 92, 48, 0.06);
  border-color: rgba(0, 92, 48, 0.3);
}

.light-theme .nav-ai-btn:hover {
  background: rgba(0, 92, 48, 0.12);
  border-color: #005c30;
  box-shadow: 0 0 14px rgba(0, 92, 48, 0.12);
}

.light-theme .ai-msg--bot .ai-msg-bubble {
  background: rgba(0, 0, 0, 0.03);
  border-color: #d0d7e3;
  border-left-color: #00703c;
  color: #1a202c;
}

.light-theme .ai-msg--user .ai-msg-bubble {
  background: rgba(0, 92, 48, 0.08);
  border-color: rgba(0, 92, 48, 0.3);
  color: #005c30;
}

.light-theme .ai-input-wrapper {
  background: rgba(0, 0, 0, 0.02);
  border-color: #d0d7e3;
}

.light-theme .ai-chat-input {
  color: #1a202c;
}

.light-theme .ai-chat-input-area {
  background: rgba(0, 0, 0, 0.02);
}

.light-theme .ai-send-btn {
  color: #005c30;
  background: rgba(0, 92, 48, 0.08);
  border-color: rgba(0, 92, 48, 0.3);
}

.light-theme .ai-suggestion-chip {
  background: rgba(0, 0, 0, 0.02);
  border-color: #d0d7e3;
  color: #4a5568;
}

.light-theme .ai-suggestion-chip:hover {
  color: #005c30;
  border-color: rgba(0, 92, 48, 0.4);
  background: rgba(0, 92, 48, 0.06);
}

/* ── Animations globales ────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
