/*
  ConnectCPA Lens — Custom CSS
  Injected via the <custom_css> config key in .chainlit/config.toml.
  Overrides Chainlit's default styles to match the ConnectCPA brand system.

  Brand tokens:
    Navy:   #222936
    Teal:   #1AA8C0
    Light:  #f4f5f7
    Border: #e8e9eb
    Muted:  #A4A7A9
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── Global font ── */
*, body, button, input, textarea {
  font-family: 'Inter', sans-serif !important;
}

/* ── Hide Chainlit branding & unnecessary chrome ── */
#chainlit-copilot-button,
a[href*="chainlit.io"],
.watermark {
  display: none !important;
}

/* ── Login page — replace Chainlit branding with ConnectCPA Lens ── */

/* Hide the default Chainlit logo SVG on the login page */
[class*="login"] svg,
[class*="Login"] svg,
[class*="auth"] svg,
[class*="Auth"] svg {
  display: none !important;
}

/* Hide the default Chainlit wordmark text on the login page */
[class*="login"] [class*="brand"],
[class*="Login"] [class*="brand"],
[class*="login"] [class*="logo"],
[class*="Login"] [class*="logo"] {
  visibility: hidden !important;
  position: relative !important;
}

/* Inject "ConnectCPA Lens 🔍" as the login page header using a pseudo-element */
[class*="login"] [class*="brand"]::before,
[class*="Login"] [class*="brand"]::before,
[class*="login"] [class*="logo"]::before,
[class*="Login"] [class*="logo"]::before {
  content: 'ConnectCPA Lens 🔍';
  visibility: visible !important;
  position: absolute !important;
  top: 0;
  left: 0;
  font-family: 'Inter', sans-serif !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  white-space: nowrap;
  letter-spacing: -0.4px;
}

/* Restyle the "Login to access the app" heading */
[class*="login"] h1,
[class*="Login"] h1,
[class*="login"] h2,
[class*="Login"] h2 {
  font-size: 20px !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  letter-spacing: -0.3px !important;
}

/* Restyle the "Continue with Google" button to use ConnectCPA teal */
[class*="login"] button,
[class*="Login"] button {
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
  border-radius: 10px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  transition: border-color 0.15s, background 0.15s !important;
}
[class*="login"] button:hover,
[class*="Login"] button:hover {
  background: rgba(26, 168, 192, 0.15) !important;
  border-color: #1AA8C0 !important;
}

/* ── Header bar ── */
header, [class*="MuiToolbar"] {
  background-color: #ffffff !important;
  border-bottom: 0.5px solid #e8e9eb !important;
  box-shadow: none !important;
}

/* App name in header */
header h6, header [class*="appName"] {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #222936 !important;
  letter-spacing: -0.3px !important;
}

/* ── Sidebar / thread list ── */
[class*="threadHistory"], nav[class*="sidebar"], aside {
  background-color: #222936 !important;
  border-right: none !important;
}

/* Sidebar text */
[class*="threadHistory"] *,
nav[class*="sidebar"] * {
  color: #ffffff !important;
}

/* Active / selected thread */
[class*="threadItem"][data-active="true"],
[class*="threadItem"].active {
  background: rgba(26, 168, 192, 0.12) !important;
  border-radius: 6px !important;
}

/* Thread item hover */
[class*="threadItem"]:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  border-radius: 6px !important;
}

/* New chat button */
button[class*="newChat"],
button[class*="new-chat"] {
  background: rgba(255, 255, 255, 0.07) !important;
  border: 0.5px solid rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
}
button[class*="newChat"]:hover {
  background: rgba(255, 255, 255, 0.12) !important;
}

/* ── Chat message bubbles ── */
[class*="Message-root"] {
  font-size: 14px !important;
  line-height: 1.65 !important;
  color: #222936 !important;
}

/* User message */
[class*="userMessage"], [data-author="user"] [class*="bubble"] {
  background: #f4f5f7 !important;
  border: 0.5px solid #e8e9eb !important;
  border-radius: 12px 12px 4px 12px !important;
}

/* Assistant message */
[data-author="Lens"] [class*="bubble"],
[class*="assistantMessage"] {
  background: #ffffff !important;
  border: 0.5px solid #e8e9eb !important;
  border-radius: 4px 12px 12px 12px !important;
}

/* ── Suggestion pills (backtick code spans in welcome message) ── */
[class*="Message"] code,
[class*="message"] code,
[class*="bubble"] code {
  background: rgba(26, 168, 192, 0.12) !important;
  color: #1AA8C0 !important;
  border: 0.5px solid rgba(26, 168, 192, 0.3) !important;
  border-radius: 6px !important;
  padding: 2px 8px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
}

/* ── Input box ── */
[class*="inputBox"], [class*="MuiInputBase-root"] {
  border: 0.5px solid #e8e9eb !important;
  border-radius: 10px !important;
  font-size: 14px !important;
  color: #222936 !important;
  background: #ffffff !important;
  box-shadow: none !important;
}
[class*="inputBox"]:focus-within,
[class*="MuiInputBase-root"]:focus-within {
  border-color: #1AA8C0 !important;
}

/* Send button */
button[class*="send"], button[type="submit"][class*="icon"] {
  background: #222936 !important;
  border-radius: 8px !important;
  color: #ffffff !important;
}
button[class*="send"]:hover {
  background: #1AA8C0 !important;
}

/* ── Plotly chart containers ── */
[class*="plotly"], .js-plotly-plot {
  border-radius: 10px;
  overflow: hidden;
  border: 0.5px solid #e8e9eb;
}

/* ── Markdown tables ── */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th {
  background: #f4f5f7;
  color: #222936;
  font-weight: 600;
  padding: 8px 12px;
  border: 0.5px solid #e8e9eb;
  text-align: left;
}
td {
  padding: 7px 12px;
  border: 0.5px solid #e8e9eb;
  color: #222936;
}
tr:nth-child(even) td { background: #fafafa; }
tr:hover td { background: rgba(26, 168, 192, 0.04); }

/* ── Code blocks (non-pill, inside pre) ── */
pre code {
  background: #f4f5f7 !important;
  color: #222936 !important;
  border: none !important;
  padding: 0 !important;
  font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
  font-size: 12.5px !important;
}
pre {
  background: #f4f5f7 !important;
  border: 0.5px solid #e8e9eb !important;
  border-radius: 6px !important;
  padding: 12px !important;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e8e9eb; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #1AA8C0; }

/* ── Table overrides (high specificity to beat Chainlit dark theme) ── */
.cl-markdown-container table,
[class*="message"] table,
[class*="Message"] table,
[class*="bubble"] table,
div table {
  border-collapse: collapse !important;
  width: 100% !important;
  font-size: 13px !important;
  background: #ffffff !important;
  border: 0.5px solid #e8e9eb !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}

.cl-markdown-container table th,
[class*="message"] table th,
[class*="Message"] table th,
[class*="bubble"] table th,
div table th {
  background: #f4f5f7 !important;
  color: #222936 !important;
  font-weight: 600 !important;
  padding: 10px 14px !important;
  border: 0.5px solid #e8e9eb !important;
  text-align: left !important;
  font-size: 12px !important;
  text-transform: none !important;
}

.cl-markdown-container table td,
[class*="message"] table td,
[class*="Message"] table td,
[class*="bubble"] table td,
div table td {
  padding: 9px 14px !important;
  border: 0.5px solid #e8e9eb !important;
  color: #222936 !important;
  background: #ffffff !important;
  font-size: 13px !important;
}

.cl-markdown-container table tr:nth-child(even) td,
[class*="message"] table tr:nth-child(even) td,
[class*="Message"] table tr:nth-child(even) td,
[class*="bubble"] table tr:nth-child(even) td,
div table tr:nth-child(even) td {
  background: #f9fafb !important;
}

.cl-markdown-container table tr:hover td,
[class*="message"] table tr:hover td,
[class*="Message"] table tr:hover td,
[class*="bubble"] table tr:hover td,
div table tr:hover td {
  background: rgba(26, 168, 192, 0.05) !important;
}