/*
 * The family's shared interface: the page, the header, buttons, forms,
 * cards, messages, tags, tables. The same on every site, so moving from
 * VA to Cere to Data feels like one place.
 *
 * Master copy: shared/family/ui.css. `php shared/family/sync.php` copies it
 * next to each site's style.css; every page loads it first, then the site's
 * own style.css, which keeps only what belongs to that site.
 *
 * Colours come from family.css (LOVUS, Night, Lună albastră); the values
 * below are only a fallback for a page drawn without a style.
 */

:root {
  --bg: #f4f5f6; --surface: #ffffff; --surface-2: #f6f7f8; --text: #172026; --muted: #5d6970; --border: #dfe4e7;
  --primary: #1d4ed8; --primary-hover: #1e40af; --primary-soft: #e6edfc; --primary-text: #ffffff;
  --accent: #b45309; --accent-soft: #fdf1e1; --ok: #15803d; --ok-soft: #e3f4e8; --danger: #b91c1c; --danger-soft: #fbe9e7;
  --info: #1d6fa5; --info-soft: #e1eef7; --warn: #b45309; --lovus: #7c3aed;
  --shadow: 0 1px 2px rgba(10, 30, 30, .05), 0 4px 14px rgba(10, 30, 30, .06);
  --radius: 14px;
  color-scheme: light;
}

/* ─── Page and text ─────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; overflow-wrap: anywhere; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; display: block; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); padding: 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; font: .85rem/1.5 ui-monospace, Consolas, monospace; margin: 10px 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; width: 100%; padding-top: 22px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.grow { flex: 1; min-width: 0; }
.inline { display: inline; }
.stack { display: grid; gap: 12px; }
.spaced { margin-top: 24px; }
h2.spaced { margin-top: 28px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 72ch; }
.ok-text { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.breakable { word-break: break-all; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ─── Header and footer ─────────────────────────────────────────────────── */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; flex-shrink: 0; }
.topbar-inner { display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 1.2rem; white-space: nowrap; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: var(--primary-text); font-size: .8rem; font-weight: 800; flex-shrink: 0; }
.brand-mark svg { width: 20px; height: 20px; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; min-width: 0; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
/* The unread counter on a menu link. */
.nav .badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 800; vertical-align: 1px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--border); }
.user-chip:hover, .user-chip.active { background: var(--surface-2); text-decoration: none; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; gap: 6px 10px; padding-top: 8px; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .user-name { display: none; }
}
.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 20px 0; flex-shrink: 0; }
/* Side by side when there is room (a description, the links), one under the other when not. */
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 6px 32px; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.3; text-align: center; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-text); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: .875rem; }
.btn-lg { padding: 12px 22px; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; margin-top: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ─── Forms ─────────────────────────────────────────────────────────────── */

input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
input[type="file"] { padding: 8px; background: var(--surface-2); }
textarea { resize: vertical; }
.field { display: grid; gap: 5px; align-content: start; }
.field > span:first-child, .field > legend { font-weight: 600; font-size: .9rem; }
.field-error { color: var(--danger); font-size: .875rem; }
.hint { color: var(--muted); font-size: .85rem; }
.input-suffix { position: relative; display: block; }
.input-suffix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .82rem; font-weight: 700; pointer-events: none; }
.input-suffix input { padding-right: 76px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.inline-form input { width: auto; flex: 1; min-width: 120px; }

/* ─── Cards and messages ────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 560px; margin: 20px auto; }
section.card { margin-bottom: 16px; }
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--warn); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.empty { text-align: center; padding: 32px 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin-bottom: 4px; }

/* ─── People, tags, lists ───────────────────────────────────────────────── */

.avatar { display: inline-grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; font-weight: 800; color: #fff; }
.avatar-sm { width: 28px; height: 28px; font-size: .85rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; }
.tone-0 { background: #0f766e; } .tone-1 { background: #c2410c; } .tone-2 { background: #7c3aed; } .tone-3 { background: #1d4ed8; }
.tone-4 { background: #0e7490; } .tone-5 { background: #be185d; } .tone-6 { background: #4d7c0f; } .tone-7 { background: #b45309; }
.trust { display: inline-block; margin-left: 5px; padding: 0 7px; border-radius: 999px; font-size: .74rem; font-weight: 800; line-height: 1.6; color: var(--ok); background: var(--ok-soft); white-space: nowrap; vertical-align: 1px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .76rem; font-weight: 700; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag-pending { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: transparent; }
.tag-rejected { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.page { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.page:hover { text-decoration: none; border-color: var(--primary); }
.page.current { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* ─── Numbers and tables ────────────────────────────────────────────────── */

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-stats .card { display: grid; gap: 2px; padding: 14px 16px; }
.admin-stats strong { font-size: 1.4rem; }
.admin-stats span { color: var(--muted); font-size: .85rem; }
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap .pad { padding: 16px 16px 0; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }

/* A bar; its width is a class (p-0 … p-100, steps of 5): the sites' CSP forbids inline styles. */
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.p-0 { width: 0; } .p-5 { width: 5%; } .p-10 { width: 10%; } .p-15 { width: 15%; } .p-20 { width: 20%; } .p-25 { width: 25%; } .p-30 { width: 30%; }
.p-35 { width: 35%; } .p-40 { width: 40%; } .p-45 { width: 45%; } .p-50 { width: 50%; } .p-55 { width: 55%; } .p-60 { width: 60%; } .p-65 { width: 65%; }
.p-70 { width: 70%; } .p-75 { width: 75%; } .p-80 { width: 80%; } .p-85 { width: 85%; } .p-90 { width: 90%; } .p-95 { width: 95%; } .p-100 { width: 100%; }
