/* Shared chat surfaces. Structural aliases also support independently released
   apps until their next build adds the explicit component classes. */
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgb(0 0 0 / .18);
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"])) {
  width: 420px;
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 104px);
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"])) > [role="log"] {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  padding: 18px 16px;
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"])) > :not([role="log"]) { flex-shrink: 0; }
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) :is(.bg-white, [class*="bg-slate-50"], [class*="bg-slate-100"]) {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) > :is(div:first-child, form) {
  background: hsl(var(--card));
  border-color: hsl(var(--border));
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) input {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
  font-size: 16px;
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) button {
  min-height: 40px;
  min-width: 40px;
  flex-shrink: 0;
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) :is(button[type="submit"], .justify-end > .rounded-xl) {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
}
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"]),
  .policy-chat-panel, div:has(> form input[placeholder="Ask anything about HR policies…"])) .rounded-xl {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.65;
}
:root :is(.chat-md, .policy-chat-md) { min-width: 0; overflow-wrap: anywhere; line-height: 1.65; }
:root :is(.chat-md, .policy-chat-md) :is(h1,h2,h3,h4,strong) { color: hsl(var(--foreground)); }
:root :is(.chat-md, .policy-chat-md) :is(p,ul,ol) { margin-block: .5em; }
:root :is(.chat-md, .policy-chat-md) :is(ul,ol) { padding-left: 1.35em; }
:root :is(.chat-md, .policy-chat-md) ul { list-style: disc; }
:root :is(.chat-md, .policy-chat-md) ol { list-style: decimal; }
:root :is(.chat-md, .policy-chat-md) pre {
  max-width: 100%; overflow-x: auto; padding: 12px; border-radius: 8px;
  background: hsl(var(--background)); color: hsl(var(--foreground));
}
:root :is(.chat-md, .policy-chat-md) pre code { background: transparent; color: inherit; }
:root .policy-chat-md table { display: block; max-width: 100%; overflow-x: auto; }
:root :is(.chat-md, .policy-chat-md) :is(th,td) { padding: 8px 10px; border: 1px solid hsl(var(--border)); }
:root .policy-chat-md th { background: hsl(var(--muted)); }
/* Consistent AI action affordance, including page-level summarize buttons. */
:root button:has(> svg.lucide-sparkles):not([role="tab"]):not([role="menuitem"]) {
  min-height: 40px;
  gap: 8px;
  border-radius: 10px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}
:root button:has(> svg.lucide-sparkles):not(:disabled):hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
:root button:has(> svg.lucide-sparkles) > svg { color: currentColor; flex-shrink: 0; }
:root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"])) button:focus-visible {
  outline: 2px solid hsl(var(--ring)); outline-offset: 2px;
}
@media (max-width: 639px) {
  :root :is(.ai-chat-drawer, [role="dialog"]:has(> [role="log"][aria-label="Chat messages"])) {
    left: 8px; right: 8px; width: auto; max-width: none;
    bottom: calc(80px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 96px - env(safe-area-inset-bottom));
  }
}
