/* WellHealth — Admin UI
 *
 * Plain CSS, no build step. Mirrors the muted neutral tokens used elsewhere
 * in the repo so the admin surface is visually a sibling of B2B/B2C.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --hair: #e3e6ea;
  --hair-2: #eef0f3;
  --ink: #1a2230;
  --ink-2: #43505f;
  --ink-3: #6b7785;
  --ink-4: #9aa3b0;
  --accent: #2f6f6f;
  --accent-soft: #e7f1f1;
  --accent-ink: #0f4f4f;
  --warn: #b15c1d;
  --warn-soft: #fbecdb;
  --good: #1e7a4d;
  --good-soft: #e0f2e8;
  --bad: #b1373d;
  --bad-soft: #f8dcde;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter Tight", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}

/* ---- top bar ----------------------------------------------------------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
  box-shadow: var(--shadow-sm);
}
.topbar__left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.topbar__center {
  justify-self: center;
}
.topbar__right {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
}
.brand {
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand__sub {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.me {
  color: var(--ink-3);
  font-size: 12px;
}

/* ---- panels ------------------------------------------------------------ */

main {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 24px 80px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 24px;
}

.panel__title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel__hint {
  margin: 0 0 14px;
  color: var(--ink-3);
}

/* ---- form primitives --------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field__label {
  font-size: 12px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
input[type="text"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="number"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color 120ms ease;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  min-height: 70px;
  resize: vertical;
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
}

.btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn--primary {
  background: var(--accent);
  color: white;
}
.btn--primary:hover {
  background: var(--accent-ink);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--hair);
}
.btn--ghost:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- list view --------------------------------------------------------- */

.list-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair-2);
  vertical-align: middle;
}
.table thead th {
  background: var(--surface-2);
  color: var(--ink-3);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table tr.row {
  cursor: pointer;
}
.table tr.row:hover td {
  background: var(--surface-2);
}
.table .row-actions {
  text-align: right;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pagination__nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pagination__label {
  color: var(--ink-2);
  min-width: 110px;
  text-align: center;
}
.pagination__total {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12px;
}

/* ---- badges & chips ---------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  color: var(--ink-2);
  background: var(--surface-2);
  font-weight: 500;
}
.badge--published {
  background: var(--good-soft);
  border-color: transparent;
  color: var(--good);
}
.badge--reviewed {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}
.badge--candidate,
.badge--draft {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}
.badge--deprecated,
.badge--archived {
  background: var(--bad-soft);
  border-color: transparent;
  color: var(--bad);
}
.badge--inactive {
  background: var(--surface-2);
  color: var(--ink-3);
}

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--ink-2);
}
.chip__remove {
  margin-left: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1;
}
.chip__remove:hover {
  color: var(--bad);
}
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
}
.chip-input input {
  flex: 1;
  min-width: 160px;
  border: none;
  outline: none;
  padding: 2px 4px;
}

/* ---- editor ------------------------------------------------------------ */

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.editor-header .panel__title {
  margin-right: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

#editor-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 14px 16px;
  background: var(--surface);
}
.card legend {
  padding: 0 6px;
  font-weight: 600;
  color: var(--ink-2);
}

.locale-text {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair-2);
}
.locale-text:last-child {
  border-bottom: 0;
}
.locale-text__locale {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-size: 12px;
  padding-top: 6px;
}
.locale-text__fields {
  display: grid;
  gap: 8px;
}

/* ---- relations editor -------------------------------------------------- */

.relation-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.relation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.relation-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) auto minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
}
.relation-row__label {
  min-width: 0;
}
.relation-row__primary {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: 12px;
}
.relation-row__notes {
  min-width: 0;
}
.relation-row__remove {
  justify-self: end;
}

.relation-adder {
  display: flex;
  gap: 8px;
}
.relation-adder select {
  flex: 1;
}

.editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 14px;
  border-top: 1px solid var(--hair-2);
}
.editor-footer .panel__hint {
  margin: 0;
  margin-right: auto;
}

/* ---- responsive -------------------------------------------------------- */

@media (max-width: 800px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }
  .topbar__center,
  .topbar__right {
    justify-self: center;
  }
}
