/* L&T AI Hub — base styles.
   The L&T app look shared by Compliance (compliance.leeandthompson.com) and
   Contact Hub: dark left-hand panel, navy accent, Afacad text, Fraunces
   headings, light grey page with white cards. Light only, like those apps.
   Colours and shell sizes are taken from Contact Hub's src/styles.css; keep
   them in step with it rather than tuning them here. Fonts are bundled from
   src/main.jsx (@fontsource). Hub-only components are in hub.css. */
:root {
  /* Contact Hub tokens */
  --bg: #F3F4F6;          /* page */
  --bg-card: #fff;        /* cards, tables, panels */
  --bg-elev: #fff;
  --bg-sub: #F9FAFB;      /* table headers, side strips */
  --bg-hover: #F3F4F6;
  --bg-active: #E8EEF7;
  --line: #E5E7EB;
  --line-strong: #D1D5DB;
  --text: #111827;
  --text-muted: #6B7280;
  --text-subtle: #9CA3AF;
  --accent: #1a3a6b;      /* L&T navy */
  --accent-dark: #132c52;
  --accent-soft: #E8EEF7;
  --accent-text: #1a3a6b;
  --side: #111827;        /* left-hand panel */

  /* Status: green allowed, amber take care, red stop */
  --good: #15803D;  --good-bg: #F0FDF4;
  --warn: #B45309;  --warn-bg: #FFFBEB;
  --bad:  #B91C1C;  --bad-bg:  #FEF2F2;

  --radius: 8px;
  --radius-sm: 6px;
  --font: 'Afacad', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
/* The shell scrolls inside .page / .kb-list, never the body. */
html, body { overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--serif); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea { outline: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }

/* ---- Shell: left-hand panel + top bar ---- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  background: var(--bg);
}

.sidebar {
  background: var(--side);
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
}
.sb-brand {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}
.sb-brand img { display: block; max-height: 32px; max-width: 172px; width: auto; height: auto; }
.sb-brand-sub {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,.35); font-size: 11.5px; margin: 0;
}
.sb-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
}
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 6px;
  color: rgba(255,255,255,.75);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s;
}
.sb-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.sb-item .ico { width: 16px; height: 16px; flex: none; color: #fff; opacity: .6; }
.sb-item.active .ico { opacity: 1; }
.sb-item .count {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.8);
  font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* Main pane */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex: none;
}
.topbar .title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.topbar .crumb-sep { color: var(--text-subtle); }

/* Buttons (Contact Hub's button.b / button.p) */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}
.btn:hover { border-color: #9CA3AF; }
.btn.primary, .btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, .btn.accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }

/* ---- Two-column library layout (Prompt library) ---- */
.kb {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  /* Pin the single row to the available height so .kb-list scrolls. */
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}
.kb-side {
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  background: var(--bg-sub);
  overflow-y: auto;
}
.kb-cat {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}
.kb-cat:hover { background: var(--bg-hover); color: var(--text); }
.kb-cat.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.kb-cat .count { margin-left: auto; font-size: 12px; color: var(--text-subtle); }
.kb-main {
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: #fff;
}
.kb-tools {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}
.kb-search {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  max-width: 480px;
  color: var(--text-muted);
}
.kb-search:focus-within { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.kb-search input { border: 0; background: transparent; flex: 1; color: var(--text); }
.kb-tag-row {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.tag {
  font-size: 12.5px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  background: #fff;
}
.tag:hover { border-color: #9CA3AF; color: var(--text); }
.tag.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.kb-list {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}
.kb-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  color: inherit;
  text-decoration: none;
}
.kb-item:hover { background: var(--bg-sub); }
.kb-item h3 { font-family: var(--font); font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.kb-item p {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.kb-item .meta { font-size: 12px; color: var(--text-subtle); }

.kb-article {
  overflow-y: auto;
  padding: 28px 40px 64px;
  max-width: 860px;
}
.kb-article h1 { font-size: 26px; font-weight: 600; margin: 0 0 8px; line-height: 1.25; }
.kb-article .a-meta { font-size: 12px; color: var(--text-subtle); margin-bottom: 16px; }
.kb-article h2 { font-size: 18px; font-weight: 600; margin: 22px 0 6px; }
.kb-article p, .kb-article li { font-size: 15px; line-height: 1.6; color: var(--text); }
.kb-article ol, .kb-article ul { padding-left: 22px; }
.kb-article code {
  font-family: var(--mono); font-size: 13px;
  background: var(--bg-sub); padding: 1px 5px; border-radius: 3px;
}

/* ---- Mobile: the panel becomes a slide-in drawer ---- */
.tb-burger { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    /* 100dvh matches the visible area on iOS; 100vh is the fallback. */
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 0 0 24px rgba(0,0,0,.25);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }
  .app.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  .topbar { padding: 0 12px; gap: 10px; height: 56px; }
  .tb-burger {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 34px; height: 34px;
    background: none; border: 0;
    padding: 0 7px; cursor: pointer;
    flex-shrink: 0;
  }
  .tb-burger span { display: block; width: 20px; height: 2px; background: #374151; border-radius: 2px; }

  /* Library: categories become a short strip above the list. */
  .kb { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
  .kb-side {
    flex: 0 0 auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 16px 10px 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 138px;
  }
  .kb-main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .kb-tools { flex-wrap: wrap; gap: 8px; }
  .kb-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .kb-item { flex-direction: column; gap: 8px; }
  /* Reading a prompt: hide the category strip and toolbar. */
  .kb-reading .kb-side,
  .kb-reading .kb-tools { display: none; }
}
