/* ---------- AI integration: the customer's own assistant reading PMAS ---------- */
.aisec { background: var(--paper); color: var(--ink); padding: clamp(72px, 9vw, 120px) 0; }
.aisec > .wrap { max-width: 1400px; }
.aisec-title { text-align: center; margin: 0 auto 14px; }
.aisec-sub { text-align: center; max-width: 34em; margin: 0 auto clamp(36px, 5vw, 56px); color: var(--muted); font-size: clamp(1.02rem, 1.3vw, 1.15rem); line-height: 1.5; }

.ai-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: stretch; }

/* questions: the same tab pattern as the analytics switcher, on paper */
.ai-list { display: grid; grid-auto-rows: 1fr; gap: 10px; }
.ai-list button {
  position: relative; display: grid; gap: 6px; align-content: center; text-align: left; width: 100%;
  padding: 16px 18px 18px; border-radius: 12px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}
.ai-list button:hover { border-color: #b9c3cd; }
.ai-list button[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 10px 30px -18px rgba(0,46,91,.45); }
.aq-k { display: flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.aq-k .bi { color: var(--accent); }
.aq-t { font-weight: 680; font-size: 1.05rem; line-height: 1.35; font-variation-settings: "wdth" 104; }
.aq-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.aq-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.ai-list button[aria-selected="true"] .aq-progress { background: rgba(90,169,255,.15); }

/* the chat window, in the PMAS app palette */
.ai-chat {
  --g900: #111a33; --g800: #192444; --g700: #283759; --g500: #64739e; --g400: #8fa0c4; --g300: #b9c4de;
  display: flex; flex-direction: column; height: clamp(540px, 44vw, 620px); border-radius: 16px; overflow: hidden;
  background: var(--g900); color: #f4f6fb; font-family: "Manrope", system-ui, sans-serif;
  box-shadow: 0 40px 90px -40px rgba(0,30,60,.55);
}
.ai-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--g800); }
.ai-who { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem; }
.ai-who .bi { color: #3fd0e8; }
.ai-conn { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--g400); padding: 4px 10px; border-radius: 999px; background: var(--g800); }
.ai-conn i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.18); }

.ai-log { flex: 1; min-height: 0; overflow: hidden; padding: 22px 22px 8px; display: flex; flex-direction: column; gap: 14px; font-size: .95rem; line-height: 1.55; }
.ai-msg { animation: ai-in .35s ease-out both; }
@keyframes ai-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ai-msg.user { align-self: flex-end; max-width: 75%; padding: 10px 14px; border-radius: 14px 14px 4px 14px; background: #4573e8; color: #fff; font-weight: 500; }
.ai-tools { display: grid; gap: 6px; }
.ai-tool { display: inline-flex; align-items: center; gap: 10px; width: max-content; max-width: 100%; padding: 6px 12px; border-radius: 8px; background: var(--g800); color: var(--g300); font-family: var(--mono); font-size: .78rem; }
.ai-tool .st { width: 14px; height: 14px; flex: none; display: grid; place-items: center; }
.ai-tool .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--g700); border-top-color: #3fd0e8; animation: ai-spin .7s linear infinite; }
.ai-tool .ok { color: #4ade80; font-size: .9rem; }
.ai-tool .src { color: var(--g500); }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-msg.bot { max-width: 92%; color: #dfe5f3; }
.ai-msg.bot p { margin: 0 0 10px; }
.ai-msg.bot p:last-child { margin-bottom: 0; }
.ai-msg.bot p.li { position: relative; padding-left: 16px; margin-bottom: 6px; }
.ai-msg.bot h6 { margin: 14px 0 6px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #3fd0e8; }
.ai-tool.done { animation: ai-in .3s ease-out both; }
.ai-tool.done .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-msg.bot p.li .dot { position: absolute; left: 0; color: #3fd0e8; }
.ai-msg.bot b { color: #fff; font-weight: 700; }
.ai-msg.bot .w { opacity: 0; transition: opacity .25s; }
.ai-msg.bot .w.on { opacity: 1; }

.ai-input { display: flex; align-items: center; gap: 2px; margin: 8px 16px 16px; padding: 12px 12px 12px 16px; border-radius: 12px; background: var(--g800); color: #fff; font-size: .95rem; min-height: 50px; }
.ai-typed:empty::before { content: "Ask about your production…"; color: var(--g500); }
.ai-caret { width: 2px; height: 1.1em; background: #3fd0e8; animation: ai-blink 1s steps(1) infinite; }
.ai-send { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--g700); color: var(--g400); transition: background .2s, color .2s; }
.ai-input.ready .ai-send { background: #4573e8; color: #fff; }
@keyframes ai-blink { 50% { opacity: 0; } }

.ai-facts { list-style: none; padding: 0; margin: clamp(28px, 4vw, 44px) 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ai-facts li { display: flex; gap: 12px; align-items: flex-start; font-size: .88rem; line-height: 1.4; color: var(--muted); }
.ai-facts .bi { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(90,169,255,.14); color: #2f7fdc; font-size: .95rem; }
.ai-facts strong { display: block; color: var(--ink); font-weight: 650; font-size: .98rem; margin-bottom: 2px; }

@media (max-width: 900px) {
  .ai-grid { grid-template-columns: 1fr; }
  .ai-list { display: flex; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 4px; }
  .ai-list button { flex: 0 0 240px; }
  .ai-chat { height: 520px; }
  .ai-facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .ai-chat { height: 660px; }
  .ai-facts { grid-template-columns: 1fr; }
  .ai-log { padding: 16px 14px 6px; font-size: .9rem; }
  .ai-msg.user { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-msg, .ai-tool .spin, .ai-caret { animation: none; }
  .ai-msg.bot .w { transition: none; }
}
