/* ============================================================================
 * components/consent.css — shared consent primitives
 * ============================================================================
 * Depends on: core/tokens.css
 *
 * Used by:
 *   /signup/   — checkbox rows for ToS + Privacy + Beta Terms
 *   /consent/  — checkbox rows for OAuth consent interstitial
 *   /account/  — legal status display rows in Account Details
 *
 * No blocking banners — stale consent enforcement is via redirect to
 * /consent/ interstitial, triggered by fx.auth.requireAuth().
 * ========================================================================== */

/* ── Consent checkbox row ──────────────────────────────────────────────── */
/* Used in /signup/ and /consent/ for "I accept..." checkboxes */
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}
.consent-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.consent-row label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--muted2);
  line-height: 1.45;
  cursor: pointer;
}
.consent-row label a {
  color: var(--accent-lt);
  text-decoration: underline;
  font-weight: var(--weight-medium);
}
.consent-row label a:hover {
  color: var(--text);
}

/* Container for consent checkboxes — sits above the submit button */
.consent-group {
  margin-top: var(--space-5);
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  /* Theme-aware nested surface: pale step below --surface in both themes. */
  background: var(--surface2);
}

/* ── Legal status display row ──────────────────────────────────────────── */
/* Used in /account/ Account Details panel to show consent status */
.legal-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.legal-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.legal-row-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: var(--muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  min-width: 140px;
  flex-shrink: 0;
}
.legal-row-value {
  flex: 1;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--muted2);
}
.legal-row-action {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--accent-lt);
  text-decoration: none;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.legal-row-action:hover {
  color: var(--text);
}

/* Badge for update-required state */
/* ── Legal document viewer (native panel) ──────────────────────────────── */
/* Reusable component for inline legal document viewing.
 * Used by /consent/, /signup/, /account/ via fx.legal.openViewer().
 * Content is fetched same-origin and extracted from .legal-doc container.
 * No iframes — native ForceX panel with scrollable document content. */
.legal-viewer {
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
  overflow: hidden;
  background: var(--surface);
  animation: legalViewerExpand 500ms var(--easing-base) both;
}
.legal-viewer.closing {
  animation: legalViewerCollapse 400ms var(--easing-base) both;
}
@keyframes legalViewerExpand {
  from {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
  to {
    opacity: 1;
    max-height: 600px;
    margin-top: var(--space-4);
    margin-bottom: var(--space-4);
  }
}
@keyframes legalViewerCollapse {
  from {
    opacity: 1;
    max-height: 600px;
    margin-top: var(--space-4);
    margin-bottom: var(--space-4);
  }
  to {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
}
.legal-viewer-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.legal-viewer-title {
  display: none; /* Title is redundant — document has its own h1 */
}
.legal-viewer-version {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  margin-right: auto;
}
.legal-viewer-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-shrink: 0;
}
.legal-viewer-link,
.legal-viewer-close {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  text-decoration: none;
}
.legal-viewer-link { color: var(--accent-lt); }
.legal-viewer-link:hover { color: var(--text); }
.legal-viewer-close { color: var(--muted2); }
.legal-viewer-close:hover { color: var(--text); }

.legal-viewer-body {
  padding: var(--space-6) var(--space-6) var(--space-8);
  max-height: 480px;
  overflow-y: auto;
  /* Scrollbar styling for dark theme */
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.legal-viewer-body::-webkit-scrollbar { width: 6px; }
.legal-viewer-body::-webkit-scrollbar-track { background: transparent; }
.legal-viewer-body::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 8px;
}

/* Legal doc content inherits its own styles from the source page.
 * Re-declare key typographic rules here so extracted content renders
 * correctly within the viewer panel context. */
.legal-viewer-body h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
}
.legal-viewer-body .legal-meta { display: none; } /* Version shown in viewer header bar */
.legal-viewer-body h2 {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  letter-spacing: var(--tracking-tight);
}
.legal-viewer-body h3 {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}
.legal-viewer-body p {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}
.legal-viewer-body ul {
  list-style: disc;
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}
.legal-viewer-body li {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-2);
}
.legal-viewer-body strong { color: var(--text); font-weight: var(--weight-semibold); }
.legal-viewer-body a { color: var(--accent-lt); text-decoration: underline; }
.legal-viewer-body a:hover { color: var(--text); }

/* Error state — shown when fetch or extraction fails */
.legal-viewer-error {
  padding: var(--space-6);
  text-align: center;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
}
.legal-viewer-error a {
  color: var(--accent-lt);
  text-decoration: underline;
  font-weight: var(--weight-semibold);
}

/* ── Mobile: full-width stacked panel ──────────────────────────────────── */
@media (max-width: 768px) {
  .legal-viewer-body { max-height: 60vh; }
  .legal-viewer-header { flex-wrap: wrap; }
  .legal-viewer-version { order: 3; width: 100%; margin-top: var(--space-1); }
  .legal-row { flex-direction: column; gap: var(--space-1); }
  .legal-row-label { min-width: 0; }
}

.legal-badge-stale {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--yellow);
  background: var(--yellow-bg);
  border: 1px solid rgba(250, 204, 21, 0.4);
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: var(--space-2);
  vertical-align: middle;
  line-height: 1.2;
}
