/* Ask AI — floating launcher + slide-over chat panel.
 *
 * Sits above the liquid dock (z-index 140) but is dismissible by scrim, close
 * button or Escape, so it never traps a user on a page.
 */

.ai-fab {
  position: fixed;
  right: 18px;
  /* Clear of the bottom nav dock, which owns the bottom centre. */
  bottom: 96px;
  z-index: 130;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 16px;
  border: none;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 750;
  color: #fff;
  background: linear-gradient(135deg, var(--ebid-accent), var(--ebid-primary-darkest));
  box-shadow: 0 10px 26px -10px rgba(30, 64, 175, 0.7);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
.ai-fab svg { width: 17px; height: 17px; }
.ai-fab:hover { filter: brightness(1.08); transform: translateY(-2px); }
.ai-fab:active { transform: translateY(0) scale(0.97); }

@media (prefers-reduced-motion: reduce) {
  .ai-fab:hover, .ai-fab:active { transform: none; }
}

@media (max-width: 460px) {
  .ai-fab span { display: none; }
  .ai-fab { padding: 13px; border-radius: 50%; }
}

/* --- panel ---------------------------------------------------------------- */

.ai-root { position: fixed; inset: 0; z-index: 140; }

.ai-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 60, 0.34);
  backdrop-filter: blur(2px);
}

.ai-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  overflow: hidden;
  animation: ai-in var(--dur-med) var(--ease-out);
}

@keyframes ai-in {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .ai-panel { animation: none; } }

.ai-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--stage-border);
  flex: none;
}

.ai-head-icon {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ebid-accent), var(--ebid-primary-darkest));
}
.ai-head-icon svg { width: 17px; height: 17px; }

.ai-head-text { flex: 1; min-width: 0; }
.ai-head-title { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }
.ai-head-sub { font-size: 10.5px; color: var(--text-tertiary); }

.ai-close {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--stage-border);
  background: var(--stage-3);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ai-close svg { width: 14px; height: 14px; }
.ai-close:hover { border-color: var(--stage-border-strong); color: var(--text-primary); }

/* --- transcript ----------------------------------------------------------- */

.ai-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ai-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-msg-user {
  align-self: flex-end;
  background: var(--ebid-primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.ai-msg-bot {
  align-self: flex-start;
  background: var(--stage-0);
  border: 1px solid var(--stage-border);
  color: var(--text-primary);
  border-bottom-left-radius: 5px;
}

/* A tool result is something that HAPPENED, not something the model said —
   styled distinctly so the user can tell an action from an answer. */
.ai-msg-tool {
  align-self: flex-start;
  background: var(--ebid-bg-tint);
  border: 1px solid var(--ebid-primary-tint);
  color: var(--ebid-primary-dark);
  font-weight: 650;
  font-size: 12.5px;
}

.ai-msg-error {
  align-self: flex-start;
  background: var(--ebid-orange-soft);
  border: 1px solid var(--ebid-orange-border);
  color: var(--ebid-orange-strong);
  font-size: 12.5px;
}

.ai-typing { display: flex; gap: 4px; align-items: center; padding: 12px; }
.ai-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-tertiary);
  animation: ai-bounce 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-bounce { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-typing span { animation: none; } }

/* --- empty state ----------------------------------------------------------- */

.ai-empty { margin: auto 0; text-align: center; padding: 16px 4px; }

.ai-empty-icon {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 14px;
  color: var(--ebid-primary);
  background: var(--ebid-primary-tint);
}
.ai-empty-icon svg { width: 22px; height: 22px; }

.ai-empty-lead { font-size: 13px; line-height: 1.6; color: var(--text-secondary); margin: 0 0 10px; }

.ai-notice {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ebid-orange-strong);
  background: var(--ebid-orange-soft);
  border: 1px solid var(--ebid-orange-border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin: 0 0 12px;
}

.ai-suggestions { display: flex; flex-direction: column; gap: 6px; }

.ai-suggestion {
  padding: 9px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--stage-border);
  background: var(--stage-3);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ai-suggestion:hover { border-color: var(--ebid-accent); color: var(--ebid-accent); }

/* --- composer --------------------------------------------------------------- */

.ai-composer {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--stage-border);
}

.ai-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--stage-border);
  background: var(--stage-3);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}
.ai-input:focus { border-color: var(--ebid-primary); box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.14); }

.ai-send {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ebid-accent), var(--ebid-primary));
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ai-send svg { width: 17px; height: 17px; }
.ai-send:hover { filter: brightness(1.06); }

/* --- entry points on tenders ---------------------------------------------- */

/* On a bid card. Deliberately quiet — it sits next to "Details", and the card's
   job is still to show the tender, not to sell the assistant. */
.bc-foot-actions { display: inline-flex; align-items: center; gap: 10px; }

.bc-ask {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--ebid-primary-tint);
  background: var(--ebid-bg-tint);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--ebid-primary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.bc-ask:hover { border-color: var(--ebid-accent); background: var(--surface-solid); }

/* On the detail page, where there's room to say what it does. */
.btn-ask {
  border-color: var(--ebid-primary-tint) !important;
  background: var(--ebid-bg-tint) !important;
  color: var(--ebid-primary) !important;
}
.btn-ask:hover { border-color: var(--ebid-accent) !important; background: var(--surface-solid) !important; }

/* --- quick actions --------------------------------------------------------- */

.ai-quick {
  flex: none;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px 0;
}

/* Inside the empty state the chips stack, so each reads as a full suggestion
   rather than a truncated pill. */
.ai-quick-empty { flex-direction: column; padding: 0; }

.ai-chip {
  padding: 7px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--stage-border);
  background: var(--stage-3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ai-chip:hover { border-color: var(--ebid-accent); color: var(--ebid-accent); }

/* The launcher shows the ✨ glyph itself, so it needs emoji-safe sizing. */
.ai-fab { font-size: 15px; line-height: 1; }

/* --- inline answer on a card ------------------------------------------------ */

.bc-ai {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--ebid-bg-tint);
  border: 1px solid var(--ebid-primary-tint);
}

.bc-ai-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.bc-ai-tag { font-size: 10px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ebid-primary); }

.bc-ai-x {
  border: none; background: none; cursor: pointer; padding: 0 2px;
  font-size: 12px; color: var(--text-tertiary); font-family: inherit;
}
.bc-ai-x:hover { color: var(--text-primary); }

.bc-ai-chips { display: flex; gap: 5px; flex-wrap: wrap; }

.bc-ai-chip {
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--ebid-primary-tint);
  background: var(--surface-solid);
  font-family: inherit;
  font-size: 11px;
  font-weight: 650;
  color: var(--ebid-primary);
  cursor: pointer;
}
.bc-ai-chip:hover { border-color: var(--ebid-accent); }

.bc-ai-q { font-size: 11.5px; font-weight: 700; color: var(--ebid-primary-dark); margin-bottom: 5px; }
.bc-ai-a { font-size: 12.5px; line-height: 1.6; color: var(--text-primary); white-space: pre-wrap; }
.bc-ai-a.is-error { color: var(--ebid-orange-strong); }

.bc-ai-more {
  margin-top: 8px;
  border: none; background: none; padding: 0;
  font-family: inherit; font-size: 11px; font-weight: 700;
  color: var(--ebid-accent); cursor: pointer;
}
.bc-ai-more:hover { text-decoration: underline; }

/* Shared three-dot loader for the inline answer and the compare panel. */
.bc-ai-a.is-loading, .cmp-out.is-loading { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.bc-ai-a.is-loading span, .cmp-out.is-loading span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ebid-primary);
  animation: ai-bounce 1.2s ease-in-out infinite;
}
.bc-ai-a.is-loading span:nth-child(2), .cmp-out.is-loading span:nth-child(2) { animation-delay: .15s; }
.bc-ai-a.is-loading span:nth-child(3), .cmp-out.is-loading span:nth-child(3) { animation-delay: .3s; }

/* --- compare bar on the saved list ------------------------------------------ */

.cmp-bar { padding: 14px 16px; margin-bottom: 14px; }

.cmp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cmp-title { font-size: 13.5px; font-weight: 800; color: var(--text-primary); }
.cmp-sub { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }

.cmp-out {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--stage-border);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text-primary);
}
.cmp-out.is-error { color: var(--ebid-orange-strong); }
