/* Copyright (c) 2026 Weiwei CHEN — TrustOR / Praetor0. All rights reserved. */
/* AI Assistants — 3 couches d'invocation (AI-ASSISTANTS-UX-1) */

/* ══════════════════════════════════════════════════════════════════════════════
   COUCHE 1 — Command palette Cmd+K
   ══════════════════════════════════════════════════════════════════════════════ */

.ai-palette-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 10100;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
  animation: aiOverlayIn .15s ease;
}
@keyframes aiOverlayIn { from { opacity: 0; } to { opacity: 1; } }

.ai-palette {
  width: 560px; max-width: calc(100vw - 32px);
  background: #1a1625;
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: 14px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(129, 140, 248, 0.1);
  overflow: hidden;
  animation: aiPaletteIn .18s cubic-bezier(.22, 1, .36, 1);
  font-family: 'Inter', system-ui, sans-serif;
}
@keyframes aiPaletteIn {
  from { opacity: 0; transform: scale(.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.ai-palette-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ai-palette-icon { width: 18px; height: 18px; color: #818cf8; flex-shrink: 0; }
.ai-palette-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 15px; color: #e0d4f5;
  font-family: 'Inter', system-ui, sans-serif;
  caret-color: #818cf8;
}
.ai-palette-input::placeholder { color: #4b5563; }
.ai-palette-hint {
  font-size: 11px; color: #4b5563; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 7px; border-radius: 5px;
}

.ai-palette-section {
  padding: 6px 0 2px;
}
.ai-palette-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: #4b5563; padding: 0 16px 4px;
}

.ai-palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px; cursor: pointer;
  transition: background .1s;
}
.ai-palette-item:hover,
.ai-palette-item.ai-palette-item--active {
  background: rgba(129, 140, 248, 0.1);
}
.ai-palette-item--active .ai-palette-item-label { color: #a5b4fc; }

.ai-palette-item-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0; color: #818cf8;
}
.ai-palette-item-icon svg { width: 16px; height: 16px; }

.ai-palette-item-body { flex: 1; min-width: 0; }
.ai-palette-item-label {
  font-size: 13px; font-weight: 500; color: #e0d4f5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-palette-item-desc { font-size: 11px; color: #6b7280; margin-top: 1px; }

.ai-palette-item-tag {
  font-size: 10px; padding: 2px 7px; border-radius: 8px;
  background: rgba(167, 139, 250, 0.1); color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.2); flex-shrink: 0;
}
.ai-palette-item-tag--orch {
  background: rgba(245, 158, 11, 0.1); color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.ai-palette-item-kbd {
  font-size: 10px; color: #4b5563;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 7px; border-radius: 5px; flex-shrink: 0;
}

.ai-palette-empty {
  padding: 24px 16px; text-align: center;
  font-size: 13px; color: #4b5563;
}

.ai-palette-footer {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px; color: #374151;
}
.ai-palette-footer kbd {
  font-size: 10px; background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 6px; border-radius: 4px;
  color: #6b7280; font-family: inherit;
}

/* ══════════════════════════════════════════════════════════════════════════════
   COUCHE 2 — FAB flottant ✨
   ══════════════════════════════════════════════════════════════════════════════ */

#ai-launcher-fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #818cf8 0%, #f59e0b 100%);
  box-shadow: 0 4px 16px rgba(129, 140, 248, 0.35);
  cursor: pointer; z-index: 9990; border: none;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s, opacity .2s;
  opacity: .92;
}
#ai-launcher-fab:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 24px rgba(129, 140, 248, 0.55);
  opacity: 1;
}
#ai-launcher-fab svg { width: 22px; height: 22px; color: #fff; pointer-events: none; }

/* FAB popover */
.ai-fab-popover {
  position: fixed; bottom: 84px; right: 24px;
  width: 260px;
  background: #1a1625;
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 9991;
  animation: aiFabPopIn .18s cubic-bezier(.22, 1, .36, 1);
  font-family: 'Inter', system-ui, sans-serif;
  overflow: hidden;
}
@keyframes aiFabPopIn {
  from { opacity: 0; transform: scale(.9) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ai-fab-popover-header {
  font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: #4b5563; padding: 10px 14px 6px;
}
.ai-fab-popover-agents { display: flex; flex-direction: column; gap: 2px; padding: 0 8px 8px; }

.ai-fab-agent-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid transparent;
  cursor: pointer; transition: background .15s, border-color .15s;
  text-align: left; width: 100%;
  font-family: 'Inter', system-ui, sans-serif;
}
.ai-fab-agent-btn:hover {
  background: rgba(129, 140, 248, 0.08); border-color: rgba(129, 140, 248, 0.2);
}
.ai-fab-agent-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-fab-agent-icon svg { width: 15px; height: 15px; }
.ai-fab-agent-name { font-size: 12px; font-weight: 600; color: #e0d4f5; }
.ai-fab-agent-desc { font-size: 11px; color: #6b7280; }

.ai-fab-popover-more {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 8px 14px;
  font-size: 11px; color: #6b7280; cursor: pointer; text-align: center;
}
.ai-fab-popover-more:hover { color: #818cf8; }

/* ══════════════════════════════════════════════════════════════════════════════
   COUCHE 3 — Agent drawer
   ══════════════════════════════════════════════════════════════════════════════ */

#ai-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9992; opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
#ai-drawer-overlay.visible { opacity: 1; pointer-events: auto; }

#ai-drawer {
  position: fixed; top: 0; right: 0;
  width: 480px; max-width: 100vw; height: 100vh;
  background: #15151f;
  border-left: 1px solid rgba(129, 140, 248, 0.25);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1);
  z-index: 9993;
  font-family: 'Inter', system-ui, sans-serif;
}
#ai-drawer.ai-drawer--open { transform: translateX(0); }

/* Drawer header */
.ai-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.ai-drawer-identity { display: flex; align-items: center; gap: 10px; }
.ai-drawer-identity-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
  border: 1px solid rgba(129, 140, 248, 0.3); flex-shrink: 0;
}
.ai-drawer-identity-icon svg { width: 18px; height: 18px; color: #818cf8; }
.ai-drawer-title { font-size: 15px; font-weight: 700; color: #e0d4f5; }
.ai-drawer-version {
  font-size: 10px; color: #4b5563;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 1px 6px; border-radius: 5px; margin-left: 4px;
}
.ai-drawer-close {
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07);
  color: #6b7280; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.ai-drawer-close:hover { background: rgba(239, 68, 68, 0.12); color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }

/* Drawer messages area */
.ai-drawer-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.ai-drawer-body::-webkit-scrollbar { width: 4px; }
.ai-drawer-body::-webkit-scrollbar-track { background: transparent; }
.ai-drawer-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }

/* Chat messages */
.ai-chat-msg {
  display: flex; flex-direction: column; gap: 4px;
  animation: aiMsgIn .2s ease;
}
@keyframes aiMsgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.ai-chat-msg--user { align-items: flex-end; }
.ai-chat-msg--assistant { align-items: flex-start; }

.ai-chat-bubble {
  max-width: 88%; padding: 10px 13px; border-radius: 12px;
  font-size: 13px; line-height: 1.5;
}
.ai-chat-msg--user .ai-chat-bubble {
  background: rgba(129, 140, 248, 0.15); color: #e0d4f5;
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: 12px 12px 3px 12px;
}
.ai-chat-msg--assistant .ai-chat-bubble {
  background: rgba(255, 255, 255, 0.04); color: #c4b5e0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px 12px 12px 3px;
}
.ai-chat-meta {
  font-size: 10px; color: #4b5563; padding: 0 4px;
}

/* Typing indicator */
.ai-typing-indicator { display: flex; gap: 4px; align-items: center; padding: 10px 13px; }
.ai-typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #818cf8; opacity: .5;
  animation: aiTyping 1.2s ease-in-out infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: .2s; }
.ai-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes aiTyping { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

/* Quick actions */
.ai-drawer-actions {
  padding: 8px 16px;
  display: flex; flex-wrap: wrap; gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}
.ai-action-btn {
  padding: 5px 12px; border-radius: 7px; font-size: 11px; font-weight: 500;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.09);
  color: #9D8BB8; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  font-family: 'Inter', system-ui, sans-serif;
  display: flex; align-items: center; gap: 5px;
}
.ai-action-btn svg { width: 12px; height: 12px; }
.ai-action-btn:hover { background: rgba(129, 140, 248, 0.1); border-color: rgba(129, 140, 248, 0.25); color: #a5b4fc; }

/* Input area */
.ai-drawer-input-wrap {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; gap: 8px; align-items: flex-end;
  flex-shrink: 0;
}
.ai-drawer-textarea {
  flex: 1; background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px; padding: 9px 12px;
  font-size: 13px; color: #e0d4f5; resize: none;
  outline: none; font-family: 'Inter', system-ui, sans-serif;
  transition: border-color .15s;
  min-height: 40px; max-height: 120px;
  caret-color: #818cf8;
}
.ai-drawer-textarea:focus { border-color: rgba(129, 140, 248, 0.4); }
.ai-drawer-textarea::placeholder { color: #4b5563; }
.ai-drawer-send {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(129, 140, 248, 0.15); border: 1px solid rgba(129, 140, 248, 0.3);
  color: #818cf8; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.ai-drawer-send:hover { background: rgba(129, 140, 248, 0.28); }
.ai-drawer-send svg { width: 16px; height: 16px; }

/* ⭐ Self-governance footer */
.ai-drawer-governance {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.07) 0%, rgba(245, 158, 11, 0.04) 100%);
  border-top: 1px solid rgba(129, 140, 248, 0.15);
  padding: 10px 16px;
  flex-shrink: 0;
}
.ai-gov-title {
  font-size: 9px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase;
  color: #4b5563; margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
}
.ai-gov-title svg { width: 11px; height: 11px; color: #818cf8; }
.ai-gov-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: #6b7280; margin-bottom: 3px; flex-wrap: wrap;
}
.ai-gov-row:last-child { margin-bottom: 0; }
.ai-gov-row code {
  background: rgba(129, 140, 248, 0.12); color: #818cf8;
  padding: 1px 5px; border-radius: 4px; font-size: 10px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
}
.ai-gov-score { color: #10b981; font-weight: 700; }
.ai-gov-links { display: flex; gap: 10px; margin-top: 4px; }
.ai-gov-links a {
  font-size: 10px; color: #5A3B7A; text-decoration: none;
  transition: color .15s;
}
.ai-gov-links a:hover { color: #818cf8; text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════════════════════
   STUB badge — V1 indicator
   ══════════════════════════════════════════════════════════════════════════════ */

.ai-stub-notice {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 4px;
  background: rgba(245, 158, 11, 0.07); border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px; font-size: 11px; color: #9D8BB8;
}
.ai-stub-notice svg { width: 14px; height: 14px; color: #f59e0b; flex-shrink: 0; }
.ai-stub-notice strong { color: #f59e0b; }

/* Stub info variant (blue-ish) */
.ai-stub-notice--info {
  background: rgba(99, 179, 237, 0.07); border-color: rgba(99, 179, 237, 0.2);
}
.ai-stub-notice--info svg { color: #63b3ed; }
.ai-stub-notice--info strong { color: #63b3ed; }

/* Error / success state on messages */
.ai-chat-msg--error .ai-chat-bubble {
  border-left: 2px solid #ef4444;
  background: rgba(239, 68, 68, 0.06);
}
.ai-chat-msg--stub .ai-chat-bubble {
  border-left: 2px solid #f59e0b;
  background: rgba(245, 158, 11, 0.05);
}

/* Correlation ID & tool count footer chip */
.ai-chat-corr {
  font-size: 10px; color: #4b5563; font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.04); border-radius: 4px; padding: 0 5px;
  cursor: default;
}

/* Retry button inline in bubble */
.ai-chat-retry {
  display: inline-block; margin-top: 6px;
  font-size: 11px; color: #818cf8; background: rgba(129, 140, 248, 0.1);
  border: 1px solid rgba(129, 140, 248, 0.25); border-radius: 6px;
  padding: 2px 8px; cursor: pointer; transition: background .15s;
}
.ai-chat-retry:hover { background: rgba(129, 140, 248, 0.2); }

/* Markdown rendering inside assistant bubbles */
.ai-chat-bubble p  { margin: 0 0 6px; }
.ai-chat-bubble p:last-child { margin-bottom: 0; }
.ai-chat-bubble strong { color: #e0d4f5; font-weight: 700; }
.ai-chat-bubble em    { color: #c4b5fd; font-style: italic; }
.ai-chat-bubble code  {
  background: rgba(129, 140, 248, 0.13); color: #a5b4fc;
  padding: 1px 5px; border-radius: 4px;
  font-size: .92em; font-family: 'JetBrains Mono', 'Courier New', monospace;
}
.ai-chat-bubble h3, .ai-chat-bubble h4 {
  margin: 8px 0 4px; font-size: 12px; font-weight: 700; color: #e0d4f5;
  letter-spacing: .3px;
}
.ai-chat-bubble ul { margin: 4px 0 6px 16px; padding: 0; }
.ai-chat-bubble li { margin-bottom: 2px; font-size: 12px; }
