/* RFP Blitz shared component styles. Framework-free, reused verbatim across
   all 5 systems (rfphub/mail/crm/docs/govdesk) -- only the data-system accent
   token changes per app. */

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.shell__nav {
  width: 240px;
  flex-shrink: 0;
  background: var(--nav-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  gap: var(--space-4);
}
.shell__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
  text-decoration: none;
}
.shell__brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  flex-shrink: 0;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--nav-heading); padding: var(--space-2) var(--space-2) var(--space-1);
}
.nav-link {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--nav-fg);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.nav-link:hover { background: var(--color-surface-2); }
.nav-link.is-active {
  background: var(--nav-active-bg);
  border-left-color: var(--nav-active-border);
  color: var(--color-text);
  font-weight: 600;
}
.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-primary); }

.shell__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.topbar__title { font-size: 17px; font-weight: 700; }
.topbar__subtitle { font-size: 12.5px; color: var(--color-muted); margin-top: 2px; }
.topbar__user { display: flex; align-items: center; gap: var(--space-3); font-size: 13px; color: var(--color-muted); }

.page { padding: var(--space-5); max-width: 1200px; margin: 0 auto; width: 100%; }
.page-head { margin-bottom: var(--space-5); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
}
.btn:hover { background: var(--color-surface-2); }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-ink); }
.btn--primary:hover { background: var(--color-primary); box-shadow: var(--shadow-2); filter: brightness(1.05); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--danger { color: var(--color-danger); border-color: var(--color-danger-weak); background: var(--color-danger-weak); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Card / table ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-4);
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.card__title { font-size: 14.5px; font-weight: 700; }

/* Tables scroll inside their own box rather than pushing the page sideways. */
.dt-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.dt th { text-align: left; color: var(--color-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; padding: 8px 10px; border-bottom: 1px solid var(--color-border); }
table.dt td { padding: 10px 10px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.dt tbody tr { transition: background var(--dur-1) var(--ease-out); }
table.dt tbody tr:hover { background: var(--color-surface-2); }
table.dt .num { text-align: right; font-family: var(--font-mono); }
/* A column holding one badge should take the badge's width and no more. width:1%
   under auto layout means "as narrow as the content allows", which hands the rest
   of the row to the column that actually carries a sentence. Deliberately NOT
   nowrap: pinning the badges open pushed the table past its own scroller on a
   narrow window and clipped the Origin column off the right-hand edge, which is
   the same defect as burying the Remove button behind a horizontal scrollbar. */
table.dt .tight { width: 1%; }
.row--danger td:first-child { border-left: 3px solid var(--color-danger); }
.row--warn td:first-child { border-left: 3px solid var(--color-warn); }
.row--info td:first-child { border-left: 3px solid var(--color-info); }
.dt-empty { padding: var(--space-6); text-align: center; color: var(--color-muted); font-size: 13px; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--space-4); }
.stat__label { font-size: 12px; color: var(--color-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.stat__value { font-size: 28px; font-weight: 700; margin-top: 4px; font-family: var(--font-mono); }
.stat__sub { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.stat--danger .stat__value { color: var(--color-danger); }
.stat--warn .stat__value { color: var(--color-warn); }
.stat--ok .stat__value { color: var(--color-ok); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 999px;
}
.badge--ok { background: var(--color-ok-weak); color: var(--color-ok); }
.badge--warn { background: var(--color-warn-weak); color: var(--color-warn); }
.badge--danger { background: var(--color-danger-weak); color: var(--color-danger); }
.badge--info { background: var(--color-info-weak); color: var(--color-info); }
.badge--neutral { background: var(--color-surface-2); color: var(--color-muted); }
.badge--accent { background: var(--color-primary-weak); color: var(--color-primary); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-3); }
.field label { font-size: 12.5px; font-weight: 600; color: var(--color-text); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 13.5px; padding: 8px 10px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--color-primary); outline-offset: 1px;
}
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--color-danger); }
.field .err { font-size: 12px; color: var(--color-danger); }
.field .hint { font-size: 12px; color: var(--color-muted); }

/* ---------- Banner ---------- */
.banner { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius); font-size: 13px; margin-bottom: var(--space-3); }
.banner--info { background: var(--color-info-weak); color: var(--color-info); }
.banner--warn { background: var(--color-warn-weak); color: var(--color-warn); }
.banner--danger { background: var(--color-danger-weak); color: var(--color-danger); }
.banner--ok { background: var(--color-ok-weak); color: var(--color-ok); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; top: var(--space-4); right: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); z-index: 1000; }
.toast {
  background: var(--toast-bg); color: var(--toast-fg);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in var(--dur-2) var(--ease-out);
}
.toast--ok::before { content: "\2713"; color: #4fd18a; font-weight: 700; }
.toast--danger::before { content: "\2715"; color: #ff8a82; font-weight: 700; }
@keyframes toast-in { from { transform: translate(16px, -6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.auth-card { position: relative; z-index: 1; width: 380px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: var(--space-6); }
.auth-brand { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); font-weight: 700; font-size: 16px; }

/* ---------- Launcher tile grid (the 5-system app switcher) ---------- */
.launcher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.launcher-tile {
  position: relative; display: block; text-decoration: none; color: inherit;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: var(--space-5); overflow: hidden;
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.launcher-tile::after {
  content: ""; position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(circle at 30% 20%, var(--tile-accent, var(--color-primary)) 0%, transparent 60%);
  transition: opacity var(--dur-2) var(--ease-out);
}
.launcher-tile:hover { transform: perspective(600px) rotateX(1deg) translateY(-3px); box-shadow: var(--shadow-2); }
.launcher-tile:hover::after { opacity: .10; }
.launcher-tile__icon {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: var(--space-3);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700;
  background: var(--tile-accent-weak, var(--color-primary-weak)); color: var(--tile-accent, var(--color-primary));
  animation: tile-float 4.5s ease-in-out infinite;
}
.launcher-tile__name { font-weight: 700; font-size: 15px; }
.launcher-tile__tag { font-size: 12.5px; color: var(--color-muted); margin-top: 2px; }
@keyframes tile-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---------- Skeleton loading ---------- */
.skeleton { background: linear-gradient(90deg, var(--color-surface-2) 25%, #e7eaf0 37%, var(--color-surface-2) 63%); background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Progress ring ---------- */
.ring { display: inline-flex; align-items: center; justify-content: center; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .ring-track { stroke: var(--color-surface-2); }
.ring .ring-fill { stroke: var(--color-primary); stroke-linecap: round; transition: stroke-dashoffset 900ms var(--ease-out); }
.ring__label { position: absolute; font-weight: 700; font-size: 15px; }

/* ---------- Doc viewer (markdown) ---------- */
.doc { max-width: 74ch; }
.doc h2 { font-size: 18px; margin: var(--space-5) 0 var(--space-2); }
.doc h3 { font-size: 15px; margin: var(--space-4) 0 var(--space-2); }
.doc code { font-family: var(--font-mono); background: var(--color-surface-2); padding: 2px 5px; border-radius: 4px; font-size: 12.5px; }
.doc pre { background: var(--color-surface-2); padding: var(--space-3); border-radius: var(--radius-sm); overflow-x: auto; }
.doc p { margin: 0 0 var(--space-3); }
.doc ul, .doc ol { margin: 0 0 var(--space-3); padding-left: 22px; }
.doc li { margin: 2px 0; }
/* Pipe tables from mdToHtml: the policy documents' header tables and the
   restricted client register. Same weights as table.dt, without the row hover
   that a document does not want. */
.doc table.md-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 0 0 var(--space-4); }
.doc table.md-table th { text-align: left; color: var(--color-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; padding: 8px 10px; border-bottom: 1px solid var(--color-border); vertical-align: bottom; }
.doc table.md-table td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); vertical-align: top; }

/* ---------- Motion primitives shared by motion.js ---------- */
.will-reveal { opacity: 0; transform: translateY(6px); }
.is-revealed { opacity: 1; transform: none; transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--color-ok); animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

@media (prefers-reduced-motion: reduce) {
  .will-reveal, .is-revealed { opacity: 1 !important; transform: none !important; transition: none !important; }
  .launcher-tile, .launcher-tile__icon, .toast, .live-dot, .skeleton, .ring-fill { animation: none !important; transition: none !important; }
}
