/* ==========================================================================
   Pawgenda shared styles. Built ONLY from tokens.css variables.
   Scoped .razor.css owns a component's own layout; this file owns the shared
   vocabulary (buttons, fields, cards, pills, tables, alerts, shells).
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--pg-font);
  font-size: var(--pg-body-size);
  line-height: var(--pg-body-leading);
  color: var(--pg-ink);
  background: var(--pg-mist);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-weight: var(--pg-heading-weight);
  letter-spacing: var(--pg-heading-tracking);
  line-height: 1.15;
  margin: 0 0 var(--pg-1);
  color: var(--pg-ink);
}
h1 { font-size: var(--pg-h1); }
h2 { font-size: var(--pg-h2); }
h3 { font-size: var(--pg-h3); }
p { margin: 0 0 var(--pg-2); }

a { color: var(--pg-brand); text-underline-offset: 2px; }
a:hover { color: var(--pg-brand-strong); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--pg-brand) 45%, transparent); outline-offset: 2px; }

.muted, .text-muted { color: var(--pg-slate); }
.small { font-size: var(--pg-small); }
.tiny { font-size: var(--pg-tiny); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.kicker {
  font-size: var(--pg-tiny); font-weight: 700; color: var(--pg-slate);
  text-transform: none; letter-spacing: 0;
}
.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;
}

/* ---- Logo ---------------------------------------------------------------- */
.pg-logo { font-weight: 800; letter-spacing: -0.03em; color: var(--pg-ink); text-decoration: none; line-height: 1; }
.pg-logo .dot { color: var(--pg-buoy); }

/* ---- Buttons ------------------------------------------------------------- */
/* .btn-main  = Buoy: the ONE main action on a screen.
   .btn-brand = the brand colour (Sea, or the business's colour).
   .btn-quiet = outline, for everything else. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--pg-1);
  min-height: var(--pg-tap); padding: 0 var(--pg-3);
  font: inherit; font-weight: 700; font-size: var(--pg-body-size); line-height: 1;
  border: 1.5px solid transparent; border-radius: var(--pg-radius-control);
  background: var(--pg-white); color: var(--pg-ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-main { background: var(--pg-buoy); color: var(--pg-on-buoy); }
.btn-main:hover { background: var(--pg-buoy-strong); color: var(--pg-on-buoy); }
.btn-brand, .btn-primary { background: var(--pg-brand); color: var(--pg-on-brand); }
.btn-brand:hover, .btn-primary:hover { background: var(--pg-brand-strong); color: var(--pg-on-brand); }
.btn-quiet, .btn-secondary { background: var(--pg-white); border-color: var(--pg-line); color: var(--pg-ink); }
.btn-quiet:hover, .btn-secondary:hover { border-color: var(--pg-slate); color: var(--pg-ink); }
.btn-danger { background: var(--pg-white); border-color: var(--pg-buoy); color: var(--pg-buoy); }
.btn-danger:hover { background: var(--pg-danger-tint); color: var(--pg-buoy); }
.btn-link { background: none; border: 0; padding: 0; min-height: var(--pg-tap); color: var(--pg-brand); font-weight: 600; }
.btn-sm { min-height: 36px; padding: 0 var(--pg-2); font-size: var(--pg-small); }
.btn-lg { min-height: 52px; }
.btn-block, .w-100 { width: 100%; }

/* ---- Fields -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--pg-2); }
.field label, .form-label, .control-label { font-weight: 600; font-size: var(--pg-small); color: var(--pg-ink); }
.field .hint { font-size: var(--pg-tiny); color: var(--pg-slate); }
.input, .form-control, select, textarea {
  width: 100%; min-height: var(--pg-tap); padding: 10px 14px;
  font: inherit; color: var(--pg-ink); background: var(--pg-white);
  border: 1.5px solid var(--pg-line); border-radius: var(--pg-radius-control);
}
textarea { min-height: 96px; resize: vertical; }
.input:focus, .form-control:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--pg-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pg-brand) 18%, transparent);
}
.input::placeholder, .form-control::placeholder { color: color-mix(in srgb, var(--pg-slate) 70%, white); }
.input[aria-invalid="true"], .form-control.invalid { border-color: var(--pg-buoy); }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: var(--pg-tap); padding-top: 10px; cursor: pointer; }
.check input, .form-check-input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--pg-brand); flex: none; }
.form-check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: var(--pg-2); }
.form-check-label { font-size: var(--pg-small); }

/* Identity template compatibility: floating labels become stacked labels. */
.form-floating { display: flex; flex-direction: column-reverse; gap: 6px; margin-bottom: var(--pg-2); }
.form-floating > .text-danger { order: -1; }
.text-danger, .validation-message { color: var(--pg-buoy); font-size: var(--pg-tiny); font-weight: 600; }
.text-success { color: var(--pg-success); }
.validation-summary-errors ul, ul.validation-errors { margin: 0 0 var(--pg-2); padding-left: 18px; color: var(--pg-buoy); font-size: var(--pg-small); }

/* ---- Cards & panels ------------------------------------------------------ */
.card {
  background: var(--pg-white); border: 1px solid var(--pg-line);
  border-radius: var(--pg-radius-card); padding: var(--pg-3);
}
.card + .card { margin-top: var(--pg-2); }
.card-tight { padding: var(--pg-2); }
.panel-sand { background: var(--pg-sand); border-radius: var(--pg-radius-card); padding: var(--pg-3); }
.stack > * + * { margin-top: var(--pg-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--pg-2); flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pg-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--pg-2); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--pg-2); }

/* ---- Stat tile ----------------------------------------------------------- */
.stat { background: var(--pg-white); border: 1px solid var(--pg-line); border-radius: var(--pg-radius-card); padding: var(--pg-2) var(--pg-3); }
.stat .label { font-size: var(--pg-tiny); color: var(--pg-slate); font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; letter-spacing: var(--pg-heading-tracking); line-height: 1.2; }
.stat .sub { font-size: var(--pg-tiny); color: var(--pg-slate); }

/* ---- Pills --------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: var(--pg-radius-pill); font-size: var(--pg-tiny); font-weight: 700;
  background: var(--pg-mist); color: var(--pg-slate); border: 1px solid var(--pg-line); white-space: nowrap;
}
.pill-brand { background: var(--pg-brand-tint); color: var(--pg-brand-strong); border-color: var(--pg-brand-line); }
.pill-good { background: var(--pg-success-tint); color: var(--pg-success); border-color: transparent; }
.pill-warn { background: var(--pg-sand); color: var(--pg-ink); border-color: transparent; }
.pill-bad { background: var(--pg-danger-tint); color: var(--pg-buoy); border-color: transparent; }

/* ---- Alerts -------------------------------------------------------------- */
.alert {
  padding: 12px var(--pg-2); border-radius: var(--pg-radius-control); margin-bottom: var(--pg-2);
  border: 1px solid var(--pg-line); background: var(--pg-white); font-size: var(--pg-small);
}
.alert-info { background: var(--pg-brand-tint); border-color: var(--pg-brand-line); }
.alert-warning { background: var(--pg-sand); border-color: transparent; }
.alert-danger { background: var(--pg-danger-tint); border-color: color-mix(in srgb, var(--pg-buoy) 30%, white); color: var(--pg-ink); }
.alert-success { background: var(--pg-success-tint); border-color: transparent; }

/* ---- Tables (become cards under 700px, as in Certra) -------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--pg-line); border-radius: var(--pg-radius-card); background: var(--pg-white); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--pg-small); }
table.table th { text-align: left; font-size: var(--pg-tiny); color: var(--pg-slate); font-weight: 700; padding: 12px var(--pg-2); border-bottom: 1px solid var(--pg-line); background: var(--pg-mist); }
table.table td { padding: 12px var(--pg-2); border-bottom: 1px solid var(--pg-line); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
table.table a { font-weight: 600; }

/* ---- Tabs ---------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--pg-line); margin-bottom: var(--pg-3); overflow-x: auto; }
.tabs a, .tabs button {
  min-height: var(--pg-tap); padding: 0 var(--pg-2); display: inline-flex; align-items: center;
  font: inherit; font-weight: 600; color: var(--pg-slate); text-decoration: none; background: none;
  border: 0; border-bottom: 2.5px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs .active { color: var(--pg-ink); border-bottom-color: var(--pg-brand); }

/* ---- Modal (CSS-only, from Certra) -------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16, 38, 58, .45); display: grid; place-items: center; padding: var(--pg-2); z-index: 50; }
.modal { background: var(--pg-white); border-radius: var(--pg-radius-card); padding: var(--pg-3); width: 100%; max-width: 520px; box-shadow: var(--pg-shadow-2); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { margin-bottom: var(--pg-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--pg-1); margin-top: var(--pg-3); flex-wrap: wrap; }

/* ---- Toasts -------------------------------------------------------------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--pg-2) + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: var(--pg-1); z-index: 60; pointer-events: none; padding: 0 var(--pg-gutter); }
.toast { pointer-events: auto; background: var(--pg-ink); color: var(--pg-white); border-radius: var(--pg-radius-control); padding: 12px var(--pg-2); font-size: var(--pg-small); font-weight: 600; box-shadow: var(--pg-shadow-2); max-width: 420px; }
.toast.bad { background: var(--pg-buoy); }

/* ---- Empty state --------------------------------------------------------- */
.empty { text-align: center; padding: var(--pg-5) var(--pg-2); color: var(--pg-slate); }
.empty h3 { color: var(--pg-ink); }

/* ---- Icons --------------------------------------------------------------- */
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: var(--pg-icon-stroke); stroke-linecap: round; stroke-linejoin: round; }

/* ---- Small utility set (Identity pages use these) ----------------------- */
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: var(--pg-1); } .mb-3 { margin-bottom: var(--pg-2); } .mb-4 { margin-bottom: var(--pg-3); }
.mt-2 { margin-top: var(--pg-1); } .mt-3 { margin-top: var(--pg-2); } .mt-4 { margin-top: var(--pg-3); } .ms-1 { margin-left: 4px; }
.py-2 { padding-top: var(--pg-1); padding-bottom: var(--pg-1); }
.text-center { text-align: center; }
.fw-semibold, .font-weight-bold { font-weight: 700; }
.row { display: flex; flex-wrap: wrap; gap: var(--pg-3); }
.row > [class^="col"] { flex: 1 1 280px; min-width: 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }

/* ---- Blazor error + reconnect ------------------------------------------- */
#blazor-error-ui {
  display: none; position: fixed; left: var(--pg-2); right: var(--pg-2); bottom: var(--pg-2); z-index: 70;
  background: var(--pg-ink); color: var(--pg-white); padding: 12px var(--pg-2); border-radius: var(--pg-radius-control);
  box-shadow: var(--pg-shadow-2); font-size: var(--pg-small);
}
#blazor-error-ui a { color: var(--pg-white); font-weight: 700; margin-left: var(--pg-1); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

.reconnect-overlay { display: none; }
.reconnect-overlay.components-reconnect-show,
.reconnect-overlay.components-reconnect-failed,
.reconnect-overlay.components-reconnect-rejected {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 80; padding: var(--pg-2);
  background: rgba(16, 38, 58, .45);
}
html.pg-reloading .reconnect-overlay { display: none !important; }
.reconnect-card { background: var(--pg-white); border-radius: var(--pg-radius-card); padding: var(--pg-4); max-width: 420px; text-align: center; box-shadow: var(--pg-shadow-2); }
.reconnect-card h2 { font-size: var(--pg-h3); }
.reconnect-card p { color: var(--pg-slate); }
.reconnect-failed-text { display: none; }
.components-reconnect-failed .reconnect-failed-text, .components-reconnect-rejected .reconnect-failed-text { display: block; }
.components-reconnect-failed .reconnect-reconnecting, .components-reconnect-rejected .reconnect-reconnecting { display: none; }
.reconnect-actions { display: flex; gap: var(--pg-1); justify-content: center; flex-wrap: wrap; }

/* ---- Phone ---------------------------------------------------------------- */
@media (max-width: 700px) {
  :root { --pg-h1: 28px; --pg-h2: 22px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--pg-2); }
  .table-wrap table.table thead { display: none; }
  .table-wrap table.table, .table-wrap table.table tbody, .table-wrap table.table tr, .table-wrap table.table td { display: block; width: 100%; }
  .table-wrap table.table tr { padding: 12px var(--pg-2); border-bottom: 1px solid var(--pg-line); }
  .table-wrap table.table td { border: 0; padding: 2px 0; }
  .table-wrap table.table td[data-label]::before { content: attr(data-label) ": "; color: var(--pg-slate); font-size: var(--pg-tiny); }
}

/* ---- Avatar / coming soon ----------------------------------------------- */
.pg-avatar { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; flex: none; }
.soon-hero { text-align: center; padding: var(--pg-6) var(--pg-2); background: var(--pg-white); border: 1px dashed var(--pg-line); border-radius: var(--pg-radius-card); }
.soon-hero-ic { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--pg-brand-tint); color: var(--pg-brand); margin-bottom: var(--pg-2); }
.soon-pill { display: inline-block; margin-bottom: var(--pg-1); padding: 2px 10px; border-radius: var(--pg-radius-pill); background: var(--pg-sand); font-size: var(--pg-tiny); font-weight: 700; }
.soon-hero-title { font-size: var(--pg-h3); font-weight: 800; letter-spacing: var(--pg-heading-tracking); margin-bottom: var(--pg-1); }
.soon-hero-body { color: var(--pg-slate); max-width: 46ch; margin: 0 auto; }

/* ---- Powered by (client portals) ---------------------------------------- */
.powered-by { text-align: center; font-size: var(--pg-tiny); color: var(--pg-slate); margin: 0; }
.powered-by .pg-logo { font-size: var(--pg-tiny); color: var(--pg-slate); }

.confirm-armed { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
