/* ============================================================================
 * Terms.Law, Contextual Legal Ask Bar (CLAB)
 * File: /shared/contextual-legal-ask-bar.css
 *
 * Inline, page-embedded "Ask about this issue" input bar styled like the
 * Google AI Overview prompt box. Three placements per page:
 *   1. Hero card  (below H1)
 *   2. Mid-page card  (after legal analysis, before FAQ)
 *   3. Mobile sticky bar  (< 768px, after 20% scroll)
 *
 * Mobile-first. Uses CLAUDE.md S6 CSS variables with literal fallbacks.
 * 44px minimum tap targets. No horizontal scroll.
 * ========================================================================== */

.clab-card,
.clab-card * {
  box-sizing: border-box;
}

/* ---------- Hero / mid-page card ---------- */
.clab-card {
  margin: 24px 0;
  padding: 20px;
  background: var(--color-card, #ffffff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  font-family: var(--font-family, 'Inter', -apple-system, sans-serif);
  color: var(--color-text, #1a1a2e);
  position: relative;
}

.clab-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text, #1a1a2e);
  margin-bottom: 12px;
  letter-spacing: 0.01em;
}

.clab-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-primary, #2563eb);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Input row ---------- */
.clab-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 2px solid var(--color-border, #e5e7eb);
  border-radius: 28px;
  padding: 6px 6px 6px 18px;
  min-height: 56px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.clab-input-wrap:focus-within {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.clab-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-text, #1a1a2e);
  padding: 8px 0;
  font-style: italic;
}

.clab-input::placeholder {
  color: var(--color-text-secondary, #6b7280);
  font-style: italic;
  opacity: 1;
}

.clab-input:not(:placeholder-shown) {
  font-style: normal;
}

/* iOS zoom prevention */
@media (max-width: 768px) {
  .clab-input {
    font-size: 16px;
  }
}

.clab-submit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 22px;
  background: var(--color-primary, #2563eb);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.clab-submit:hover {
  background: var(--color-primary-dark, #1d4ed8);
}

.clab-submit:active {
  transform: scale(0.96);
}

.clab-submit:focus-visible {
  outline: 2px solid var(--color-primary-dark, #1d4ed8);
  outline-offset: 2px;
}

.clab-submit svg {
  width: 20px;
  height: 20px;
}

/* ---------- Chip row ---------- */
.clab-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.clab-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 999px;
  background: #ffffff;
  color: var(--color-text, #1a1a2e);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.clab-chip:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: var(--color-primary, #2563eb);
  color: var(--color-primary-dark, #1d4ed8);
}

.clab-chip:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
}

/* Mobile: horizontal scroll instead of wrap */
@media (max-width: 600px) {
  .clab-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: -20px;
    margin-right: -20px;
    padding: 0 20px 4px;
  }
  .clab-chips::-webkit-scrollbar {
    display: none;
  }
  .clab-chip {
    flex-shrink: 0;
  }
}

/* ---------- Disclaimer ---------- */
.clab-disclaimer {
  margin-top: 12px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--color-text-secondary, #6b7280);
}

/* ---------- Mobile sticky bar (< 768px, after 20% scroll) ---------- */
.clab-mobile-sticky {
  display: none;
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 12px;
  z-index: 9997; /* under uchat-fab at 9998 */
  background: #ffffff;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 28px;
  padding: 6px 6px 6px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  align-items: center;
  gap: 8px;
  min-height: 52px;
  transform: translateY(120%);
  transition: transform 0.28s cubic-bezier(.2,.7,.2,1);
  font-family: var(--font-family, 'Inter', -apple-system, sans-serif);
}

.clab-mobile-sticky.is-visible {
  transform: translateY(0);
}

@media (max-width: 767px) {
  .clab-mobile-sticky {
    display: flex;
  }
  /* Lift floating chatbox FAB so it does not overlap the sticky bar */
  body.clab-sticky-active #uchat-fab {
    bottom: 78px !important;
  }
}

.clab-mobile-sticky .clab-input {
  font-size: 16px;
  padding: 6px 0;
}

.clab-mobile-sticky .clab-submit {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 20px;
}

.clab-mobile-sticky-close {
  position: absolute;
  top: -10px;
  right: -2px;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--color-text, #1a1a2e);
  color: #ffffff;
  border: 2px solid #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Expanded panel (placeholder; the real chat panel is loaded
     from /Templates/shared/universal-ai-chat.js) ---------- */
.clab-loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: clab-spin 0.8s linear infinite;
}

@keyframes clab-spin {
  to { transform: rotate(360deg); }
}

/* ---------- CTA card (rendered after 2-3 useful exchanges) ---------- */
.clab-cta-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(99, 102, 241, 0.06));
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.clab-cta-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text, #1a1a2e);
  margin: 0 0 6px 0;
}

.clab-cta-body {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text, #1a1a2e);
  margin: 0 0 12px 0;
}

.clab-cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  background: var(--color-primary, #2563eb);
  color: #ffffff;
  text-decoration: none;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease;
}

.clab-cta-button:hover {
  background: var(--color-primary-dark, #1d4ed8);
}

/* ---------- Layout polish for hero / mid card on wide screens ---------- */
@media (min-width: 768px) {
  .clab-card {
    padding: 24px;
  }
  .clab-input-wrap {
    min-height: 60px;
  }
}

/* ============================================================================
 * Hero banner (PayPal-style)
 * Replaces the hero input-bar card with a lighter, click-through suggestion.
 * Single sentence + "Chat with AI Legal Analyst" subtext. The mid-page card
 * still uses the full input + chips layout.
 * ========================================================================== */
.clab-hero-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 880px;
  margin: 20px auto 24px;
  padding: 18px 22px;
  background: var(--color-card, #ffffff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  cursor: pointer;
  font-family: var(--font-family, 'Inter', -apple-system, sans-serif);
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.06s ease;
}
.clab-hero-banner:hover {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08), 0 8px 20px rgba(37, 99, 235, 0.10);
}
.clab-hero-banner:active {
  transform: translateY(1px);
}
.clab-hero-banner:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
}
.clab-hero-banner__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-primary, #2563eb);
}
.clab-hero-banner__icon svg {
  width: 28px;
  height: 28px;
}
.clab-hero-banner__copy {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.clab-hero-banner__action {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text, #1a1a2e);
  line-height: 1.4;
}
.clab-hero-banner__subtext {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
  line-height: 1.3;
}
.clab-hero-banner__arrow {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--color-text-secondary, #6b7280);
  opacity: 0.6;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.clab-hero-banner:hover .clab-hero-banner__arrow {
  opacity: 1;
  transform: translateX(2px);
  color: var(--color-primary, #2563eb);
}
.clab-hero-banner__arrow svg {
  width: 20px;
  height: 20px;
}
@media (max-width: 600px) {
  .clab-hero-banner {
    padding: 14px 16px;
    gap: 12px;
    margin: 16px 12px 20px;
  }
  .clab-hero-banner__icon {
    width: 32px;
    height: 32px;
  }
  .clab-hero-banner__icon svg {
    width: 24px;
    height: 24px;
  }
  .clab-hero-banner__action {
    font-size: 0.95rem;
  }
  .clab-hero-banner__subtext {
    font-size: 0.8125rem;
  }
}

/* ============================================================================
 * CLAB5 (2026-05-25) — design-system primitives ported from the Claude Design
 * prototype. Adds accent themes, paperclip-attach button, primary chip variant,
 * cite-pill style, and the inline conversation panel.
 * ========================================================================== */

/* Accent CSS variables — default indigo; override per page via .clab--{theme} */
.clab-card,
.clab-hero-banner {
  --c-accent: var(--color-primary, #4f46e5);
  --c-accent-soft: rgba(79, 70, 229, 0.08);
}

.clab--teal {
  --c-accent: #0d9488;
  --c-accent-soft: rgba(13, 148, 136, 0.10);
}
.clab--gold {
  --c-accent: #b8862d;
  --c-accent-soft: rgba(184, 134, 45, 0.12);
}
.clab--amber {
  --c-accent: #d97706;
  --c-accent-soft: rgba(217, 119, 6, 0.10);
}
.clab--blue {
  --c-accent: #1d4ed8;
  --c-accent-soft: rgba(29, 78, 216, 0.08);
}

/* Paperclip attach button (sits inside the input wrap, right of the input,
 * before the submit arrow). Opens the upload modal. */
.clab-attach {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.clab-attach:hover,
.clab-attach:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  outline: none;
}
.clab-attach svg {
  width: 20px;
  height: 20px;
}

/* Primary chip variant — the first "Upload..." chip gets visual priority. */
.clab-chip--primary {
  background: var(--c-accent);
  color: #ffffff;
  border-color: transparent;
}
.clab-chip--primary:hover,
.clab-chip--primary:focus-visible {
  background: var(--c-accent);
  color: #ffffff;
  filter: brightness(1.05);
}

/* Citation pill (used by post-engagement issue-map renders and AI replies). */
.cite,
.clab-cite {
  display: inline-block;
  background: var(--c-accent-soft);
  color: var(--c-accent);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Inline conversation panel (kept lean — full impl by post-upload module). */
.clab-conv {
  margin-top: 16px;
  border-top: 1px solid var(--color-border, #e5e7eb);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* CTA card gets the accent treatment so it visually matches the page theme. */
.clab-cta-card {
  border-color: color-mix(in oklab, var(--c-accent) 30%, transparent);
  background: linear-gradient(
    135deg,
    color-mix(in oklab, var(--c-accent) 6%, var(--color-card, #ffffff)),
    color-mix(in oklab, var(--c-accent) 2%, var(--color-card, #ffffff))
  );
}
@supports not (color: color-mix(in oklab, red 50%, blue)) {
  /* Fallback for older browsers without color-mix: keep the existing card look. */
  .clab-cta-card {
    background: var(--color-card, #ffffff);
  }
}

.clab-cta-button {
  background: var(--c-accent);
  color: #ffffff;
}
.clab-cta-button:hover,
.clab-cta-button:focus-visible {
  background: var(--c-accent);
  filter: brightness(1.06);
  outline: none;
}

/* CLAB5.2 — mobile optimization for the new design primitives. */
@media (max-width: 767px) {
  /* Bump attach button up to the 44px minimum tap target on mobile. */
  .clab-attach {
    width: 44px;
    height: 44px;
  }
  .clab-attach svg {
    width: 22px;
    height: 22px;
  }
  /* Primary upload chip — make it visually distinct on mobile too. */
  .clab-chip--primary {
    font-size: 0.875rem;
    min-height: 44px;
    padding: 10px 16px;
  }
  /* Citation pills stay readable on mobile but don't dominate. */
  .cite,
  .clab-cite {
    font-size: 0.75rem;
  }
}

/* Above 768: keep attach button 40px (matches design prototype). */
@media (min-width: 768px) {
  .clab-attach {
    width: 40px;
    height: 40px;
  }
}
