/* ARAMAH brand overlay injected into LibreChat's built client.
   Loaded via <link> patched into index.html by chat/Dockerfile, after
   aramah-tokens.css.

   Colours come only from the shared tokens (assets/ui/aramah-tokens.css):
   --aramah-blue / -purple / -magenta / -grad are the tenant's primary,
   secondary and highlight colours (WBS 3.7), ARAMAH's own when unset, and
   --aramah-on-* the readable text colour on each. Don't redefine them here:
   a :root rule in this file would override the tenant theme. LibreChat's
   --surface-submit* variables are mapped in client/src/aramah/theme/token-map.css. */

/* ── Logo replacement ─────────────────────────────────────────────────────
   The login/register pages render <img src="/assets/logo.svg" alt="ARAMAH Logo">.
   Replace the rendered image with the ARAMAH logo (content: url works on <img>
   in Chromium). This is the reliable path; the Dockerfile also overwrites the
   logo.svg file as a fallback.
   --brand-logo / --brand-wordmark / --brand-login are set by the chat's BrandingProvider (aramah/branding)
   when the admin Settings page has a custom upload; unset, the built-in ARAMAH
   images apply. The login page prefers the wordmark (--brand-login).
   v0.8 renders the src as "assets/logo.svg" with no leading slash, and
   BrandingProvider relabels the alt to "<name> Logo" — so match the src
   without the slash, never the alt alone. */
img[src$="assets/logo.svg"],
img[alt="ARAMAH Logo" i],
img[src*="librechat" i],
img[alt*="librechat" i] {
  content: var(--brand-login, url("/images/aramah-logo.png")) !important;
}
/* LibreChat's logo box is only h-10 (40px) tall; give the ARAMAH logo room. */
div.bg-cover:has(> img[alt="ARAMAH Logo" i]),
div.bg-cover:has(> img[src$="assets/logo.svg"]) {
  height: 72px !important;
}

/* ── Footer wordmark (interface.customFooter) — size it for the footer ─────── */
img[src$="aramah-wordmark.png"] {
  height: 18px !important;
  width: auto !important;
  display: inline-block;
  vertical-align: middle;
}

/* ── Assistant "bot" icon → ARAMAH approved logo ──────────────────────────────
   LibreChat draws <svg class="lucide-bot …"> for the assistant (the greeting
   avatar, the model-picker button, sidebar conversation rows). Paint the ARAMAH
   logo in its place and hide the default robot paths. */
svg.lucide-bot {
  background: var(--brand-logo, url("/images/aramah-logo.png")) center / contain no-repeat !important;
}
svg.lucide-bot > * {
  display: none !important;
}

/* ── ARAMAH wordmark in the sidebar header (hides when the sidebar collapses) ──
   Anchored to the sidebar <nav> so it tracks the sidebar: shown when the sidebar
   is open, gone when collapsed. Placed in the gap between the collapse toggle and
   the bookmark/new-chat buttons; sized small so it never overlaps them. */
/* Scoped to the conversation sidebar, which is the only <nav> with a Chat
   History region inside it. A bare `nav::before` matched every nav LibreChat
   renders — Prompts, Brain, Files, Settings, MCP servers — and painted the
   wordmark across each panel's own header. It looked right only in the chat
   sidebar, which happens to have empty space at that offset. */
nav:has([aria-label="Chat History"]) {
  position: relative;
}
nav:has([aria-label="Chat History"])::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 52px;
  width: 96px;
  height: 18px;
  background: var(--brand-wordmark, url("/images/aramah-wordmark.png")) no-repeat left center / contain;
  z-index: 5;
  pointer-events: none;
}
/* Custom wordmark from admin Settings: the 96x18 slot above is sized for the
   very wide ARAMAH wordmark (8:1). An icon-plus-text wordmark (~3:1) shrank to
   ~50px wide in it, so give uploads a taller slot. contain keeps the ratio. */
html.aramah-brand-wordmark nav:has([aria-label="Chat History"])::before {
  top: 8px;
  width: 180px;
  height: 32px;
}
/* App renamed in admin Settings but no wordmark uploaded: the ARAMAH wordmark
   would contradict the new name, so print the name itself (set by
   BrandingProvider as the CSS string --brand-name). */
html.aramah-brand-textmark nav:has([aria-label="Chat History"])::before {
  content: var(--brand-name, "");
  background: none;
  width: 120px;
  font: 700 14px/18px system-ui, sans-serif;
  letter-spacing: .5px;
  color: var(--text-primary, currentColor);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Responsive: don't show the wordmark on narrow viewports where the header is tight. */
@media (max-width: 768px) {
  nav:has([aria-label="Chat History"])::before { display: none; }
}

/* ── Primary buttons / "Continue" / submit → ARAMAH brand gradient ────────────
   LibreChat has several conventions for primary actions: .btn-primary,
   .bg-green-* Tailwind utilities, and the raw form[type=submit]. Override all
   three, and repeat the override with !important on hover so LibreChat's
   .hover:bg-green-* rules can't restore the teal on mouseover.
   Scoped to button/a: a bare .bg-green-500 is also LibreChat's "connected"
   status dot, which must stay green, not turn into a purple gradient. */
.btn-primary,
button.bg-green-500, button.bg-green-550, button.bg-green-600, button.bg-green-700,
a.bg-green-500, a.bg-green-550, a.bg-green-600, a.bg-green-700,
form button[type="submit"] {
  background-color: var(--aramah-blue) !important;
  background-image: var(--aramah-grad) !important;
  border-color: var(--aramah-blue) !important;
  color: var(--aramah-on-grad) !important;
}
.btn-primary:hover,
.hover\:bg-green-500:hover, .hover\:bg-green-550:hover,
.hover\:bg-green-600:hover, .hover\:bg-green-700:hover,
form button[type="submit"]:hover {
  /* Must be !important so LibreChat's own .hover:bg-green-* declarations don't
     win the cascade and repaint the button teal on hover. */
  background-color: var(--aramah-purple) !important;
  background-image: var(--aramah-grad) !important;
  border-color: var(--aramah-purple) !important;
  filter: brightness(1.08);
}

/* ── Auth links ("Sign up" / "Login") and other green text → brand magenta ── */
.text-green-500, .text-green-600,
a[href="/register"], a[href="/login"] {
  color: var(--aramah-magenta) !important;
}

/* ── Auth input fields → ARAMAH brand colours ─────────────────────────────────
   The login/register email + password inputs focus green/teal in LibreChat;
   recolour the border, typed text and focus ring to the ARAMAH palette. (The
   chat composer is a textarea, so these input[type] rules don't touch it.) */
input[type="email"], input[type="password"], input[type="text"] {
  border-color: var(--aramah-blue) !important;
  color: var(--aramah-blue) !important;
}
input[type="email"]:focus, input[type="password"]:focus, input[type="text"]:focus {
  border-color: var(--aramah-purple) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--aramah-purple) 30%, transparent) !important;
  outline: none !important;
}
/* Green/teal borders + the floating field labels used on the auth form → brand. */
[class*="border-green"] {
  border-color: var(--aramah-blue) !important;
}
label[class*="text-green"], [class*="peer-focus:text-green"] {
  color: var(--aramah-purple) !important;
}

/* ── Loaders / "thinking" indicator → ANIMATED ARAMAH infinity loader ─────────
   LibreChat's spinners are <svg class="animate-spin …">. We hide the default
   spinner and render the ARAMAH animated loader on its parent via content:url —
   the SVG's internal CSS animation runs when it's an image (content:url / <img>),
   which it does NOT as a CSS background-image. :has() picks the spinner's parent
   without needing LibreChat's hashed class names. */
svg.animate-spin {
  display: none !important;
}
*:has(> svg.animate-spin)::after {
  content: url("/images/aramah-infinity-loader-animated.svg");
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
}

/* ── Hide the Code Interpreter button (paid external service; subscriptions
   unavailable). Belt-and-suspenders to interface.runCode:false — covers the
   likely aria-label / test-id / id the toggle uses. */
button[aria-label*="code interpreter" i],
button[aria-label*="run code" i],
button[aria-label*="interpreter" i],
[data-testid*="code-interpreter" i],
[data-testid*="run-code" i],
[id*="code-interpreter" i] {
  display: none !important;
}

/* ── Sidebar: accent the top rail with ARAMAH blue ───────────────────────── */
nav, [class*="sidebar"], [class*="Sidebar"] {
  border-right-color: var(--aramah-blue) !important;
}

/* ── Generic unstyled links → brand blue ──────────────────────────────────── */
a:not([class]) {
  color: var(--aramah-blue);
}

/* ── Toast notifications → ARAMAH gradient (was LibreChat green) ─────────────
   LibreChat's success toasts render as .alert-root with an arbitrary Tailwind
   background bg-[#02855E]. Target the semantic class so we catch every toast
   regardless of variant. Text takes the primary's readable colour. */
.alert-root {
  background: var(--aramah-grad) !important;
  background-color: var(--aramah-blue) !important;
  border-color: transparent !important;
  color: var(--aramah-on-grad) !important;
}
.alert-root svg { color: var(--aramah-on-grad) !important; }

/* ── Always-visible message metadata (datetime, tokens on hover-only in stock) ──
   v0.8 renders <time datetime="…"> and per-message token counts inside a
   message-footer subtree that's hidden until hover. Force it visible with a
   subdued style so users can see when + how expensive each turn was without
   hovering. Response time (elapsed) is NOT in the DOM — that would need JS. */
[class*="message"] time,
[class*="message"] [class*="token"] {
  display: inline !important;
  opacity: 0.6;
  font-size: 11px;
  color: var(--aramah-text-muted);
}
