/* Agentic AI bar — scoped for tender viewer (matches @ainorthstar/agentic-ai-bar/react.css) */
:root {
  --agentic-line: var(--border-bright, rgba(0, 0, 0, 0.15));
  --agentic-field: var(--bg, #faf7f5);
  --agentic-ink: var(--text, #1a1a1a);
  --agentic-soft: var(--surface-recessed, #f4f0ec);
  --agentic-accent: var(--accent, #c45d3e);
  --agentic-accent-ink: #fff;
  --agentic-muted: var(--text-dim, #666);
}

body.has-ai-bar { padding-bottom: 132px; }
body.has-ai-bar.ai-panel-open { padding-bottom: min(72vh, 640px); }

.ai-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 96px;
  z-index: 90;
  max-width: 920px;
  margin: 0 auto;
  display: none;
  flex-direction: column;
  max-height: min(58vh, 520px);
  background: var(--surface-elevated, #fff);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}
.ai-panel.open { display: flex; }

.ai-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ai-panel__title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.ai-panel__close {
  border: 1px solid var(--border-bright);
  background: var(--surface-recessed);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.ai-panel__body {
  overflow: auto;
  padding: 14px 16px 16px;
  min-height: 0;
}

.ai-run-query {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin-bottom: 12px;
  color: var(--text);
}

.ai-trace-id {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-bottom: 10px;
}

.ai-timeline { display: grid; gap: 8px; margin-bottom: 14px; }
.ai-step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.ai-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid var(--border-bright);
  margin-top: 4px;
}
.ai-step.running .ai-dot {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: ai-spin 820ms linear infinite;
}
.ai-step.complete .ai-dot { background: var(--accent); border-color: var(--accent); }
.ai-step.failed .ai-dot { background: var(--rose); border-color: var(--rose); }
.ai-step-title { font-size: 0.84rem; font-weight: 600; }
.ai-step-kind { font-size: 0.72rem; color: var(--text-faint); font-family: var(--font-mono); }
.ai-step-detail {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  background: var(--surface-recessed);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-mono);
}

.ai-answer {
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-answer p { margin: 0 0 10px; }
.ai-answer code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-recessed);
  padding: 1px 5px;
  border-radius: 4px;
}
.ai-answer pre {
  background: var(--surface-recessed);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
  font-size: 0.82rem;
}

.ai-composer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  padding: 18px 16px 16px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(250, 247, 245, 0));
  pointer-events: none;
}
.ai-composer-wrap > form { pointer-events: auto; }

.agentic-composer {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  max-width: 920px;
  margin: 0 auto;
  padding: 10px;
  background: var(--surface-elevated, #fff);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

.agentic-model-select,
.agentic-input,
.agentic-send {
  font: inherit;
  border-radius: 8px;
}

.agentic-model-select {
  min-height: 44px;
  min-width: 0;
  border: 1px solid var(--agentic-line);
  background: var(--agentic-field);
  color: var(--agentic-ink);
  padding: 0 10px;
  font-size: 0.82rem;
}

.agentic-input {
  min-height: 44px;
  max-height: 120px;
  min-width: 0;
  border: 1px solid var(--agentic-line);
  background: var(--agentic-field);
  color: var(--agentic-ink);
  padding: 10px 12px;
  resize: vertical;
  font-size: 0.9rem;
}

.agentic-model-select:focus,
.agentic-input:focus {
  outline: none;
  border-color: var(--agentic-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--agentic-accent) 16%, transparent);
}

.agentic-send {
  min-height: 44px;
  border: none;
  cursor: pointer;
  padding: 0 18px;
  font-weight: 600;
  background: var(--agentic-accent);
  color: var(--agentic-accent-ink);
  font-size: 0.88rem;
}
.agentic-send:disabled { opacity: 0.6; cursor: wait; }

.ai-hint {
  max-width: 920px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  pointer-events: none;
}

@keyframes ai-spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .agentic-composer { grid-template-columns: 1fr; }
  body.has-ai-bar { padding-bottom: 180px; }
  .ai-panel { left: 10px; right: 10px; bottom: 150px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --agentic-field: var(--bg);
    --agentic-soft: var(--surface-recessed);
  }
  .ai-composer-wrap {
    background: linear-gradient(to top, var(--bg) 70%, rgba(18, 18, 18, 0));
  }
}
