/* shared/ai-widget.css – floating AI chat widget */

:root {
  --ai-bg:       #161b22;
  --ai-surface:  #1c2230;
  --ai-line:     #2b3140;
  --ai-ink:      #e2e8f0;
  --ai-muted:    #7c879e;
  --ai-accent:   #f59e0b;
  --ai-soft:     #fcd34d;
  --ai-green:    #34d399;
  --ai-red:      #f87171;
  --ai-radius:   16px;
  --ai-shadow:   0 8px 40px rgba(0,0,0,.65);
}

/* ──────────────────────────────────────────
   FLOATING BUTTON
────────────────────────────────────────── */
#ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(245,158,11,.45), 0 2px 8px rgba(0,0,0,.4);
  transition: transform .18s, box-shadow .18s;
  font-size: 24px;
  color: #000;
  line-height: 1;
}
#ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(245,158,11,.6), 0 2px 10px rgba(0,0,0,.5);
}
#ai-fab:active { transform: scale(.95); }
#ai-fab[data-open="true"] { background: linear-gradient(135deg, #374151 0%, #1f2937 100%); }
#ai-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0d1117;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ──────────────────────────────────────────
   PANEL
────────────────────────────────────────── */
#ai-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 8999;
  width: min(96vw, 440px);
  max-height: min(82dvh, 680px);
  background: var(--ai-bg);
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity .2s, transform .2s;
}
#ai-panel[hidden] {
  display: none !important;
}
@media (max-width: 480px) {
  #ai-panel {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    max-height: 85dvh;
    border-radius: 20px 20px 0 0;
  }
  #ai-fab { bottom: 16px; right: 16px; }
  .ai-panel-close { width: 44px; height: 44px; font-size: 18px; }
  .ai-send-btn { width: 44px; height: 44px; }
  .ai-input { height: 44px; font-size: 16px; }
  .ai-qp-btn { padding: 10px 16px; font-size: 13px; min-height: 44px; }
  .ai-clear-btn { width: 44px; height: 44px; }
  .ai-action-chip { padding: 10px 16px; min-height: 44px; }
}

/* PANEL HEADER */
.ai-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--ai-line);
  background: var(--ai-surface);
  flex-shrink: 0;
}
.ai-panel-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-panel-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ai-ink);
}
.ai-panel-dept {
  font-size: 11px;
  color: var(--ai-muted);
  margin-top: 1px;
}
.ai-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--ai-line);
  background: transparent;
  color: var(--ai-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.ai-panel-close:hover { background: var(--ai-line); color: var(--ai-ink); }

/* QUICK PROMPTS */
.ai-quick-prompts {
  padding: 10px 14px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--ai-line);
  background: var(--ai-bg);
}
.ai-qp-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--ai-line);
  background: var(--ai-surface);
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, color .12s, background .12s;
}
.ai-qp-btn:hover {
  border-color: rgba(245,158,11,.4);
  color: var(--ai-soft);
  background: rgba(245,158,11,.08);
}

/* MESSAGES */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--ai-line); border-radius: 3px; }

/* user bubble */
.ai-msg-user {
  align-self: flex-end;
  max-width: 85%;
  padding: 9px 14px;
  border-radius: 14px 14px 4px 14px;
  background: rgba(245,158,11,.15);
  border: 1px solid rgba(245,158,11,.3);
  color: var(--ai-ink);
  font-size: 13px;
  line-height: 1.5;
}

/* assistant bubble */
.ai-msg-assistant {
  align-self: flex-start;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-msg-card {
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ai-ink);
  line-height: 1.55;
}
.ai-msg-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ai-soft);
  margin-bottom: 6px;
}
.ai-msg-summary { margin-bottom: 8px; }

.ai-insights {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.ai-insight-item {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--ai-muted);
}
.ai-insight-item::before { content: "•"; color: var(--ai-accent); flex-shrink: 0; }

.ai-warnings {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-warning-item {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--ai-red);
  background: rgba(239,68,68,.08);
  padding: 4px 8px;
  border-radius: 6px;
}
.ai-warning-item::before { content: "⚠"; flex-shrink: 0; }

.ai-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ai-action-chip {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid rgba(245,158,11,.3);
  background: rgba(245,158,11,.1);
  color: var(--ai-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.ai-action-chip:hover { background: rgba(245,158,11,.2); }
.ai-action-chip.dangerous {
  border-color: rgba(239,68,68,.4);
  background: rgba(239,68,68,.08);
  color: var(--ai-red);
}

/* thinking bubble */
.ai-msg-thinking {
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: 14px 14px 14px 4px;
  font-size: 13px;
  color: var(--ai-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-thinking-dots {
  display: flex;
  gap: 4px;
}
.ai-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-accent);
  animation: ai-dot-bounce .8s infinite alternate;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: .15s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot-bounce { from { opacity: .3; transform: translateY(0); } to { opacity: 1; transform: translateY(-4px); } }

/* error */
.ai-msg-error {
  align-self: flex-start;
  padding: 9px 14px;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 14px 14px 14px 4px;
  font-size: 13px;
  color: var(--ai-red);
}

/* empty state */
.ai-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ai-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}
.ai-empty-icon { font-size: 36px; }

/* INPUT BAR */
.ai-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ai-line);
  background: var(--ai-surface);
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--ai-line);
  background: var(--ai-bg);
  color: var(--ai-ink);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s;
  outline: none;
}
.ai-input:focus { border-color: rgba(245,158,11,.5); }
.ai-input::placeholder { color: var(--ai-muted); }
.ai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #000;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .12s, opacity .12s;
}
.ai-send-btn:hover:not(:disabled) { transform: scale(1.08); }
.ai-send-btn:disabled { opacity: .4; cursor: not-allowed; }
.ai-clear-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--ai-line);
  background: transparent;
  color: var(--ai-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-clear-btn:hover { background: var(--ai-line); color: var(--ai-ink); }

/* data points */
.ai-data-points {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ai-dp {
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.2);
  font-size: 11px;
  color: var(--ai-muted);
}
.ai-dp strong { color: var(--ai-ink); }
