/* ============================================================================
   09 · CONTENT PAGES & MODALS

   Legal pages, empty state, social integrations, the modal system (shell,
   sizes, inline banner, dark form controls), sticky messages and the user
   lookup / analytics tab panel.

   Part of the dashboard stylesheet, split out of the former single style.css.
   LOAD ORDER IS LOAD-BEARING (later parts intentionally override earlier
   ones) — the canonical order is dashboard/views/partials/_app_styles.ejs.
   ========================================================================== */

/* ===== LEGAL PAGES ===== */
.legal-wrap {
  max-width: 50rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.legal-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.legal-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.legal-header .legal-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.legal-siblings {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.legal-siblings a {
  font-size: 0.8125rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}

.legal-siblings a:hover { color: var(--text); border-color: var(--text-muted); }
.legal-siblings a.active { color: var(--blurple); border-color: var(--blurple); background: rgba(220, 38, 38,0.08); }

.legal-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
}

.legal-toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.legal-toc ol {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.legal-toc li { font-size: 0.875rem; }
.legal-toc a { color: var(--blurple); }
.legal-toc a:hover { text-decoration: underline; }

.legal-prose h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 2.25rem 0 0.875rem;
  padding-top: 0.25rem;
  color: var(--text);
}

.legal-prose h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.legal-prose p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 0.875rem;
}

.legal-prose ul, .legal-prose ol {
  padding-left: 1.5rem;
  margin-bottom: 0.875rem;
}

.legal-prose li {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 0.25rem;
}

.legal-prose a { color: var(--blurple); }
.legal-prose a:hover { text-decoration: underline; }

.legal-prose strong { color: var(--text); font-weight: 600; }

.legal-prose .legal-table-wrap {
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 0.875rem;
}

.legal-prose .legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.legal-prose .legal-table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}

.legal-prose .legal-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
  line-height: 1.6;
}

.legal-prose .legal-table tr:last-child td { border-bottom: none; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 0.75rem;
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.4;
  line-height: 1;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.empty-state-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.6;
}

/* ===== SOCIAL INTEGRATIONS PAGE ===== */
.social-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: 0.625rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  transition: border-color 0.15s, background 0.15s;
}
.social-item:last-child { margin-bottom: 0; }
.social-item:hover { border-color: rgba(220, 38, 38,0.2); background: var(--surface-hover); }

.social-add-form {
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: 0.625rem;
  background: rgba(0,0,0,0.18);
  border: 1px dashed var(--border);
}

.social-live-badge {
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.1rem 0.3rem;
  border-radius: 0.2rem;
  letter-spacing: 0.06em;
  vertical-align: middle;
  animation: social-live-pulse 2s ease-in-out infinite;
}
@keyframes social-live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

/* An alert the free tier keeps but does not post. Deliberately quiet — it is a state
   label, not an alarm — and it sits beside LIVE, which is the badge that should still
   catch the eye. The row itself dims via the shared `.tk-card--locked`; that class
   is opacity-only for exactly this reason, so the Remove button (the whole way an
   owner acts on this) stays clickable. */
.social-lock-chip {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  color: var(--text-muted);
  background: var(--bg-hover, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
  vertical-align: middle;
  white-space: nowrap;
}

.social-code {
  font-size: 0.75rem;
  background: rgba(0,0,0,0.25);
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  font-family: monospace;
}

/* ── Panel rows (reaction roles compact list) ───────────────────────────────── */
.panel-row:last-child { border-bottom: none !important; }
.panel-row:hover { background: var(--surface-hover); }

/* ── Modals ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 20, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; animation: modal-fade 0.18s ease-in-out; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: rgba(22, 27, 34, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.55), 0 0 0 1px rgba(var(--blue-rgb),0.06);
  overflow: hidden;
  animation: modal-scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-scale-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-body { overflow-y: auto; }
.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

/* Opt-in for a modal whose body hosts a custom-select (`.cs-menu`) dropdown.
   The menu is absolutely positioned, so `.modal`'s `overflow:hidden` and the body's
   `overflow-y:auto` clip it away entirely — and it cannot escape via `position:fixed`
   because `.modal`'s backdrop-filter makes it the containing block for fixed children.
   So the modal must not clip at all; scroll an inner list instead of the body. Header
   and footer re-round their own corners, which the modal no longer clips for them. */
.modal.modal-nocrop { overflow: visible; }
.modal.modal-nocrop > .modal-body { overflow: visible; }
.modal.modal-nocrop > .modal-header { border-radius: 14px 14px 0 0; }
.modal.modal-nocrop > .modal-footer { border-radius: 0 0 14px 14px; }
/* Scroll region for a list inside a `.modal-nocrop` body (keeps a long list bounded
   without reintroducing a clip around the add-row's dropdown below it). */
.modal-scroll-list { max-height: 15rem; overflow-y: auto; }

/* ── Modal sizes ───────────────────────────────────────────────────────────────
   `.modal` itself sets NO width and NO height: every modal picks its own, the way
   `.rr-modal` and `.gp-feature-modal` do. A size class that does not exist is
   therefore not a cosmetic miss — the modal shrink-wraps its content, grows past
   the viewport and, with nothing to scroll, puts its own header and footer
   off-screen. That is what `.modal-lg` (the tickets platform's only shell) was
   doing: a 1,118px-tall form in a 900px window, Save and Cancel both unreachable.
   Height is capped and the BODY is the scroller, so the header and footer stay
   pinned — the `.gp-feature-modal` arrangement. */
.modal-lg,
.modal-xl {
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}
.modal-lg { width: min(920px, 96vw); }
/* The form designer and the workflow builder are two-pane editors — they need the
   room, but never more than the window has. */
.modal-xl { width: min(1180px, 96vw); }
.modal-lg > .modal-header, .modal-lg > .modal-footer,
.modal-xl > .modal-header, .modal-xl > .modal-footer { flex: 0 0 auto; }
.modal-lg > .modal-body,
.modal-xl > .modal-body { flex: 1 1 auto; min-height: 0; padding: 1.25rem; }
/* `.modal-nocrop` unclips the body so a dropdown inside it is not cut off. The
   body still has to scroll, or capping the height above would just clip the form
   instead of scrolling it — the same override `.gp-panel-body--scroll` makes, and
   it needs the same specificity to beat `.modal.modal-nocrop > .modal-body`. */
.modal.modal-nocrop.modal-lg > .modal-body,
.modal.modal-nocrop.modal-xl > .modal-body { overflow-y: auto; overflow-x: hidden; }
/* A modal whose body manages its OWN inner scroll regions (the form designer's two
   panes) must not also scroll as a whole, or the two nest and the inner pane can
   never be reached. */
.modal-lg > .modal-body.modal-body--own-scroll,
.modal-xl > .modal-body.modal-body--own-scroll,
.modal.modal-nocrop.modal-lg > .modal-body.modal-body--own-scroll,
.modal.modal-nocrop.modal-xl > .modal-body.modal-body--own-scroll { overflow: hidden; }

.modal-sub { margin: 0.2rem 0 0; font-size: 0.8125rem; color: var(--text-muted); line-height: 1.45; }
.modal-close {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 8px; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 16px;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.modal-close:focus-visible { outline: none; box-shadow: var(--ring-blue); }

/* ── Inline banner ─────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.75rem 1rem; border-radius: 10px;
  font-size: 0.8125rem; color: var(--text-secondary);
  background: var(--bg-hover); border: 1px solid var(--border);
}
.alert ion-icon { font-size: 18px; flex: 0 0 auto; }
.alert-warn { background: rgba(250, 166, 26, 0.10); border-color: rgba(250, 166, 26, 0.30); color: #f6c177; }
.alert-error { background: rgba(237, 66, 69, 0.10); border-color: rgba(237, 66, 69, 0.32); color: #f3a1a2; }
.alert-info { background: rgba(88, 101, 242, 0.10); border-color: rgba(88, 101, 242, 0.30); color: #c9cdfb; }

/* Force dark theme on all form controls inside modals */
.modal select,
.modal input[type="text"],
.modal input[type="number"],
.modal input[type="url"],
.modal input[type="email"],
.modal textarea {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text);
  color-scheme: dark;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.modal select:focus,
.modal input[type="text"]:focus,
.modal input[type="number"]:focus,
.modal input[type="url"]:focus,
.modal input[type="email"]:focus,
.modal textarea:focus {
  border-color: var(--blurple);
  box-shadow: 0 0 0 2px rgba(220, 38, 38,0.2);
}
.modal select {
  -webkit-appearance: none;
  appearance: none;
  background-image: none;
}

/* Style the native option list to match dark theme */
.modal select option {
  background: var(--bg-sidebar);
  color: var(--text);
}
.modal select option:checked {
  background: var(--blurple);
  color: #fff;
}
.modal select option:hover,
.modal select option:focus {
  background: var(--surface-hover);
  color: var(--text);
}

/* Also apply globally for any select outside modals that uses inline bg */
select option {
  background: var(--bg-sidebar);
  color: var(--text);
}
select option:checked {
  background: var(--blurple);
  color: #fff;
}

/* ===== STICKY MESSAGES PAGE ===== */
.sticky-msg-card {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  margin-bottom: 0.625rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.sticky-msg-card:hover {
  border-color: rgba(240,177,50,0.3);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}
.sticky-msg-accent {
  width: 4px;
  flex-shrink: 0;
  background: var(--yellow);
  border-radius: 0.75rem 0 0 0.75rem;
}
.sticky-msg-body {
  flex: 1;
  padding: 0.875rem 1rem;
  min-width: 0;
}
.sticky-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.sticky-msg-channel {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--yellow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sticky-msg-preview {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: pre-line;
  line-height: 1.55;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  word-break: break-word;
}
.sticky-msg-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.sticky-msg-dot { opacity: 0.5; }

/* ===== USER LOOKUP DATE FILTER ===== */
/* ===== USER ANALYTICS LOOKUP — search + date-range controls ===== */

/* Row 1: Discord ID input + Look Up button */
.lookup-id-row {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
.lookup-id-input {
  flex: 1;
  min-width: 240px;
  max-width: 480px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  letter-spacing: 0.02em;
}
.lookup-id-input::placeholder {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  letter-spacing: 0.02em;
}
.lookup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.lookup-btn ion-icon { font-size: 1.05rem; }

/* Row 2: date range */
.lookup-date-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}
.lookup-date-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-right: 0.125rem;
}
.lookup-date-sep { color: var(--text-muted); font-size: 0.9rem; }

/* date inputs — themed to read as one of the app's glass fields */
.lookup-date-input {
  width: 150px;
  flex: 0 0 auto;
  color-scheme: dark;
  font-size: 0.8125rem;
  padding: 0.45rem 0.7rem;
}
/* recolour the native calendar picker glyph so it's visible on the dark field */
.lookup-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.lookup-date-input::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* preset chips */
.lookup-preset-group {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-left: 0.25rem;
}
.lookup-preset {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  min-width: 2.4rem;
}
/* active preset button highlight */
.lookup-preset.active {
  background: rgba(220, 38, 38,0.15);
  color: var(--blurple);
  border-color: rgba(220, 38, 38,0.4);
}

@media (max-width: 560px) {
  .lookup-id-input { max-width: none; }
  .lookup-btn { width: 100%; justify-content: center; }
  .lookup-date-input { flex: 1; width: auto; min-width: 130px; }
}

/* ===== USER CHIP (avatar + name, resolved lazily from Discord CDN) ===== */
.user-chip { line-height: 1; }
.user-chip-av { display: block; }
.action-log-users .user-chip { gap: 4px; }
.action-log-users .user-chip + .user-chip,
.action-log-users .user-chip + span { margin-top: 2px; }

/* ===== ANALYTICS TAB PANEL ===== */
/* Remove top gap when a section header is the first thing inside a tab */
.tab-panel > .analytics-section-header:first-child { margin-top: 0; }

/* User-lookup action breakdown pill layout */
.user-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 700;
}

/* Lookup button loading icon spin */
#user-lookup-btn ion-icon[name="sync-outline"] {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

/* Surface-2 utility used in user lookup "no data" message */
:root { --surface-2: rgba(255,255,255,0.06); }
