/* edit.legal — SEO Page Template
   Full webapp replica: left sidebar + chat center + right sidebar
   The user lands from Google and is inside the product. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: hsl(0 0% 100%);
  --page-bg: hsl(210 40% 98%);
  --fg: hsl(222.2 84% 4.9%);
  --primary: hsl(222.2 47.4% 11.2%);
  --brand: hsl(223 75% 55%);
  --muted: hsl(215 16% 47%);
  --faint: hsl(215 20% 65%);
  --border: hsl(214.3 31.8% 91.4%);
  --border-light: hsl(214 30% 94%);
  --accent: hsl(222 60% 95%);
  --accent-fg: hsl(224 60% 38%);
  --legal-navy: hsl(220 45% 25%);
  --legal-green: hsl(150 45% 40%);
  --legal-green-light: hsl(150 50% 94%);
  --radius: 0.75rem;
  --radius-sm: 0.375rem;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --font-heading: "Lora", Georgia, serif;
  --font-body: system-ui, -apple-system, sans-serif;
  --sidebar-w: 220px;
  --right-w: 280px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ══════════════════════════════════════
   APP HEADER (52px, same as product)
   ══════════════════════════════════════ */
.app-header {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: var(--bg);
  flex-shrink: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.logo {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  margin-right: 8px;
}

.logo .legal { font-weight: 400; color: var(--muted); }

.header-breadcrumb {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.header-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.header-breadcrumb a:hover { color: var(--fg); }
.header-breadcrumb .sep { color: var(--border); }
.header-breadcrumb .current { color: var(--fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header-spacer { flex: 1; }

.header-cta {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.header-cta-ghost { background: none; color: var(--fg); }
.header-cta-primary { background: var(--primary); color: #fff; }
.header-cta:hover { opacity: 0.8; }

/* ══════════════════════════════════════
   APP BODY (3 columns)
   ══════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── LEFT SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  flex-shrink: 0;
  overflow-y: auto;
}

.ws-switcher {
  margin: 12px 12px 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--fg);
}

.ws-switcher .ws-icon { color: var(--muted); font-size: 11px; }

.nav-section { padding: 8px 8px 4px; }

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 4px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover { background: var(--page-bg); }
.nav-item.active { background: var(--page-bg); font-weight: 500; }
.nav-item .nav-icon { color: var(--muted); width: 16px; height: 16px; flex-shrink: 0; }

.nav-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.sidebar-spacer { flex: 1; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════
   CENTER: CHAT AREA
   ══════════════════════════════════════ */
.chat-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

/* Allow chat-messages to grow naturally instead of being constrained */
.chat-center > * { flex-shrink: 0; }

/* Chat panel header */
.chat-panel-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg);
}

.expert-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--legal-green);
  flex-shrink: 0;
}

.expert-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.expert-area {
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}

.context-pill {
  font-size: 11px;
  background: var(--accent);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--accent-fg);
  margin-left: auto;
  white-space: nowrap;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* User message */
.msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  max-width: 80%;
  font-size: 14px;
  line-height: 1.55;
}

/* AI message */
.msg-ai {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 18px 20px;
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  max-width: 100%;
  font-size: 14px;
  line-height: 1.7;
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.msg-ai p { margin-bottom: 12px; }
.msg-ai p:last-of-type { margin-bottom: 0; }
.msg-ai strong { color: var(--primary); font-weight: 600; }

.msg-ai h2 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  margin: 16px 0 8px;
}
.msg-ai h2:first-child { margin-top: 0; }

/* Citations */
.citation-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  vertical-align: super;
  margin: 0 1px;
  transition: opacity 0.15s;
}
.citation-ref:hover { opacity: 0.7; }

/* Sources */
.msg-sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.msg-sources-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-bottom: 8px;
}

.source-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
}
.source-item + .source-item {
  border-top: 1px solid var(--border-light);
}

.source-num {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.source-body { flex: 1; min-width: 0; }

.source-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.source-quote {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}

.source-quote em {
  font-style: normal;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0 2px;
  border-radius: 2px;
}

/* Source link (clickable, opens modal on click) */
.source-link {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  cursor: pointer;
  transition: color 0.15s;
}
.source-link:hover { color: var(--fg); }
.source-link svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* ── Source paywall modal ── */
.source-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.source-modal-overlay.open { display: flex; }

.source-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 32px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  text-align: center;
  position: relative;
}

.source-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.source-modal-close:hover { background: var(--accent); color: var(--fg); }

.source-modal-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
}
.source-modal-icon svg { width: 24px; height: 24px; }

.source-modal h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
}

.source-modal p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.source-modal-ref {
  font-size: 12px;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 20px;
  font-style: italic;
}

.source-modal-cta {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s;
}
.source-modal-cta:hover { opacity: 0.85; }

.source-modal-note {
  font-size: 12px;
  color: var(--faint);
  margin-top: 10px;
}

/* AI actions */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.msg-action-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  transition: all 0.15s;
}
.msg-action-btn:hover { border-color: var(--brand); color: var(--accent-fg); background: var(--accent); }

/* System */
.msg-system {
  text-align: center;
  font-size: 12px;
  color: var(--faint);
  padding: 4px 0;
}

/* ── CTA INPUT (prominent, sticky) ── */
.chat-cta-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.cta-prompt {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 10px;
}

.cta-input-box {
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.cta-input-box:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px hsla(223, 75%, 55%, 0.1);
}

.cta-input-placeholder {
  flex: 1;
  font-size: 14px;
  color: var(--faint);
  line-height: 1.4;
  padding: 2px 0;
}

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cta-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--faint);
}

.cta-note a {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
}

.cta-note a:hover { opacity: 0.85; }

/* Disclaimer inside chat center */
.disclaimer {
  padding: 10px 24px;
  font-size: 11px;
  color: var(--faint);
  line-height: 1.5;
  border-top: 1px solid var(--border-light);
}

/* ══════════════════════════════════════
   RIGHT SIDEBAR (related threads)
   ══════════════════════════════════════ */
.right-sidebar {
  width: var(--right-w);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.right-sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex-shrink: 0;
}

.thread-list {
  flex: 1;
  overflow-y: auto;
}

.thread-item {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--fg);
  transition: background 0.15s;
  cursor: pointer;
}

.thread-item:hover { background: var(--page-bg); }
.thread-item.active { background: var(--accent); border-left: 2px solid var(--brand); }

.thread-item-area {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-bottom: 3px;
}

.thread-item-title {
  font-size: 13px;
  line-height: 1.4;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread-item-meta {
  font-size: 11px;
  color: var(--faint);
  margin-top: 4px;
}

/* Pillar page links (bottom of right sidebar) */
.pillar-section {
  padding: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pillar-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.pillar-link {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--fg);
  text-decoration: none;
  transition: background 0.15s;
}

.pillar-link:hover { background: var(--page-bg); }

.pillar-link .pillar-count {
  font-size: 11px;
  color: var(--faint);
  margin-left: 4px;
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */

/* Tablet: hide left sidebar, keep right */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  :root { --sidebar-w: 0px; }
}

/* Mobile: single column, right sidebar below */
@media (max-width: 768px) {
  body { overflow: auto; }
  .app-body {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 52px);
  }
  .right-sidebar {
    width: 100%;
    border-top: 1px solid var(--border);
    max-height: none;
    overflow: visible;
  }
  .chat-center {
    border-right: none;
    min-height: auto;
  }
  .chat-messages { padding: 16px; }
  .chat-cta-area { padding: 14px 16px 16px; }
  .header-breadcrumb { display: none; }
}

@media (max-width: 480px) {
  .app-header { padding: 0 12px; }
  .msg-ai { padding: 14px; }
  .cta-input-box { padding: 8px 10px; }
}

/* ══════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
