/* Agent panel styling. Everything is expressed through the host app's CSS
   variables (--panel, --panel2, --panel3, --line, --text, --muted, --accent),
   so the panel follows your theme — including light/dark — with no work.
   Define those six variables in your app and this file needs no edits. */

#agent-root {
  position: fixed;
  z-index: 900;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100vw - 32px);
  font-size: 13.5px;
}

@media (max-width: 720px) {
  #agent-root { width: calc(100vw - 16px); bottom: env(safe-area-inset-bottom, 0px); }
  #agent-root .agbar { margin-bottom: 8px; padding: 8px 12px; }
  #agent-root.open .agwin { height: min(520px, 68dvh); margin-bottom: 8px; }
}

/* --- minimized home bar --- */
#agent-root .agbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 9px 14px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
  cursor: text;
}
#agent-root.open .agbar { display: none; }
#agent-root .agstar { color: var(--accent); flex: none; }
#agent-root .agbarin {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font: inherit;
}
#agent-root .agbarin::placeholder { color: var(--muted); }

/* --- expanded window (grows upward from the bar's slot) --- */
#agent-root .agwin { display: none; }
#agent-root.open .agwin {
  display: flex; flex-direction: column;
  margin-bottom: 16px;
  height: min(520px, 72vh);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .35);
  overflow: hidden;
}
#agent-root .aghead {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
#agent-root .agtitle { font-weight: 600; }
#agent-root .agdot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
#agent-root .agdot.open { background: #47c98a; }
#agent-root .agdot.connecting { background: #f2b13e; }
#agent-root .agdot.closed { background: #f2665e; }
#agent-root .agmin {
  margin-left: auto; background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; padding: 2px 6px; border-radius: 6px;
}
#agent-root .agmin:hover { background: var(--panel3); color: var(--text); }

/* --- log --- */
#agent-root .aglog { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
#agent-root .agmsg { max-width: 88%; padding: 8px 12px; border-radius: 10px; line-height: 1.45; overflow-wrap: break-word; }
#agent-root .agmsg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
#agent-root .agmsg.assistant { align-self: flex-start; background: var(--panel2); color: var(--text); border-bottom-left-radius: 4px; white-space: pre-wrap; }
#agent-root .agmsg.assistant p,
#agent-root .agmsg.assistant ul,
#agent-root .agmsg.assistant h4,
#agent-root .agmsg.assistant table,
#agent-root .agmsg.assistant pre { white-space: normal; margin: 0 0 8px; }
#agent-root .agmsg.assistant > :last-child { margin-bottom: 0; }
#agent-root .agmsg.assistant ul { padding-left: 18px; }
#agent-root .agmsg.system { align-self: center; color: var(--muted); font-size: 12px; background: none; }
#agent-root .agmsg.error { align-self: flex-start; background: rgba(242, 102, 94, .12); color: #f2665e; }
#agent-root .agmsg pre { background: var(--panel3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 12px; }
#agent-root .agmsg code { background: var(--panel3); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
#agent-root .agmsg table { border-collapse: collapse; font-size: 12.5px; }
#agent-root .agmsg th, #agent-root .agmsg td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }

/* Blex blocks. The container is what the shared renderer (blex-render.js) fills;
   .blex-fallback is the raw fence, shown when nothing claims the container —
   a denied type, or blex failing to load. Both beat a blank rectangle. */
#agent-root .blex-block-container { margin: 6px 0; border-radius: 8px; overflow: hidden; max-width: 100%; }
#agent-root .blex-fallback { margin: 0; padding: 8px 10px; background: var(--panel3); border: 1px solid var(--line); border-radius: 8px; font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; opacity: .85; overflow-x: auto; }

#agent-root .agactivity { align-self: flex-start; color: var(--muted); font-size: 12px; padding: 0 4px; animation: agpulse 1.4s ease-in-out infinite; }
@keyframes agpulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
/* Browser tests set data-test-mode to kill animation timing races. */
[data-test-mode="true"] #agent-root .agactivity { animation: none; }

/* --- export-tier confirm chip --- */
#agent-root .agconfirm { align-self: stretch; background: var(--panel2); border: 1px solid #f2b13e88; border-radius: 10px; padding: 10px 12px; }
#agent-root .agconfirmrow { display: flex; gap: 8px; margin-top: 8px; }
#agent-root .agconfirmdone { color: var(--muted); margin-top: 6px; font-size: 12px; }
#agent-root .agbtn {
  font: inherit; padding: 5px 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel3); color: var(--text); border: 1px solid var(--line);
}
#agent-root .agbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- composer row --- */
#agent-root .aginrow { display: flex; gap: 8px; flex: none; padding: 10px 12px; border-top: 1px solid var(--line); }
#agent-root .again {
  flex: 1; resize: none; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; color: var(--text); font: inherit; outline: none;
}
#agent-root .again:focus { border-color: var(--accent); }
#agent-root .agsend {
  align-self: flex-end; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer; font-size: 15px;
}
