/* Portal-wide AI sidecar.
 *
 * This is deliberately part of the application chrome, not a floating mascot.
 * A compact top-bar control keeps it reachable everywhere; the work surface only
 * exists while the user asks for it. It follows the portal's flat, neutral design
 * language and uses elevation only for the drawer that actually overlays a page.
 */
.ai-dock-launch {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}
.ai-dock-launch:hover,
.ai-dock-launch[aria-expanded="true"] {
  border-color: #b9b9b9;
  background: var(--surface-2);
}
.ai-dock-mark {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 2px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.ai-dock {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  z-index: 48;
  width: min(440px, calc(100vw - 64px));
  min-width: 340px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  background: #fafafa;
  border-left: 1px solid #cfcfcf;
  box-shadow: var(--shadow-over);
  transform: translateX(101%);
  visibility: hidden;
  transition: transform 150ms ease, visibility 0s linear 150ms;
}
.ai-dock.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 150ms ease;
}
.ai-dock-head {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-section);
  background: #fff;
}
.ai-dock-title {
  min-width: 0;
  flex: 1;
  display: grid;
  line-height: 1.25;
}
.ai-dock-title b { font-size: 13px; }
.ai-dock-title span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-dock-iconbtn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.ai-dock-iconbtn:hover { background: var(--surface-2); }
.ai-dock-context {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-row);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}
.ai-dock-context b {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-dock-thread {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}
.ai-dock-empty {
  margin: auto 0;
  padding: 22px 10px;
  text-align: center;
}
.ai-dock-empty h2 {
  margin: 0 0 5px;
  font-size: 16px;
}
.ai-dock-empty p {
  margin: 0 auto 14px;
  max-width: 330px;
  color: var(--muted);
  font-size: 12px;
}
.ai-dock-suggestions {
  display: grid;
  gap: 6px;
  max-width: 330px;
  margin: 0 auto;
}
.ai-dock-suggestions button {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.ai-dock-suggestions button:hover { border-color: #b9b9b9; background: var(--surface-2); }
.ai-dock-msg {
  max-width: 92%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  line-height: 1.48;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.ai-dock-msg.user {
  align-self: flex-end;
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.ai-dock-msg.bot { align-self: flex-start; }
.ai-dock-msg.error {
  align-self: stretch;
  max-width: none;
  border-color: #e0b3b3;
  background: #fff7f7;
  color: var(--bad);
}
.ai-dock-msg.pending { color: var(--muted); }
.ai-dock-artifacts {
  display: grid;
  gap: 5px;
  width: min(92%, 330px);
  align-self: flex-start;
}
.ai-dock-artifacts button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}
.ai-dock-composer {
  padding: 9px 10px 7px;
  border-top: 1px solid var(--line-section);
  background: #fff;
}
.ai-dock-inputrow {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.ai-dock-inputrow:focus-within { border: 2px solid var(--teal); padding: 5px; }
.ai-dock-inputrow textarea {
  min-width: 0;
  min-height: 38px;
  max-height: 120px;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  padding: 6px;
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
}
.ai-dock-send {
  min-width: 58px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.ai-dock-send:hover { background: var(--red-dark); border-color: var(--red-dark); }
.ai-dock-send:disabled { cursor: default; opacity: .55; }
.ai-dock-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 10.5px;
}
.ai-dock-full {
  border: 0;
  background: transparent;
  color: var(--red-dark);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.ai-dock-full:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .ai-dock-launch-label { display: none; }
  .ai-dock-launch { padding-right: 5px; }
  .ai-dock {
    left: 0;
    width: 100%;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-dock { transition: none; }
}
