/* E-Certificate Pentarex — design system (see docs/DESIGN.md). No build step. */

:root {
  --ink: #111418;
  --ink-soft: #3a3f47;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --bg: #f6f7f9;
  --accent: #0070bc;
  --accent-600: #005e9e;
  --ok: #1f9d55;
  --ok-bg: #e6f4ec;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --info-bg: #eef1f5;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent-600); }

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  overflow: visible;           /* let the logo plate overhang the bar */
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; justify-content: space-between;
  overflow: visible;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.brand-name { font-size: 15px; }
/* White plate behind the logo so it reads on the dark bar; taller than the bar (overhangs). */
.brand-plate {
  background: #fff; border-radius: 8px; padding: 8px 12px;
  display: inline-flex; align-items: center; box-shadow: var(--shadow);
}
.brand-plate img { height: 50px; width: auto; display: block; }
/* Logo on white backgrounds (login / public cards) */
.brand-logo { height: 64px; width: auto; display: block; margin: 0 auto 12px; }

.navlinks { display: flex; align-items: center; gap: 18px; }
.navlinks a { color: #d7dae0; font-size: 14px; }
.navlinks a:hover, .navlinks a.active { color: #fff; }
.navuser { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #c7cbd2; }
/* User account link — icon + name, divided from the nav links */
.usermenu {
  display: inline-flex; align-items: center; gap: 7px; color: #c7cbd2;
  padding-left: 14px; border-left: 1px solid rgba(255,255,255,.18);
}
.usermenu:hover, .usermenu.active { color: #fff; }
.usericon { display: block; flex: none; }

/* ── Layout container ────────────────────────────────── */
.container { max-width: 1080px; margin: 28px auto; padding: 0 20px; }
.narrow { max-width: 560px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.page-title { font-size: 1.5rem; font-weight: 600; margin: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; font-size: .92rem; }

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 14px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 9px 16px; font: inherit; font-weight: 600; font-size: .92rem;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; color: #fff; box-shadow: 0 0 0 3px rgba(0, 112, 188, .35); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-600); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .82rem; }

/* ── Forms ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.label { display: block; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.input, .select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 112, 188, .25); }
/* Multi-line fields (certificate description) reuse .input; only the box shape differs. */
textarea.input { resize: vertical; min-height: 76px; line-height: 1.5; }

/* Markdown-lite toolbar sitting on top of a textarea. Hidden without JS — the buttons only
   insert markers, which staff can type by hand (help text below the field says how). */
.rt-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
html:not(.js) .rt-toolbar { display: none; }
.rt-btn {
  min-width: 30px; padding: 4px 8px; font: inherit; font-size: .85rem; line-height: 1.2;
  color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
}
.rt-btn:hover { border-color: var(--accent); color: var(--accent); }
.rt-hint { font-size: .78rem; }

/* Rendered description (public card + dashboard summary). Tight margins so a one-paragraph
   description sits on the same baseline as the plain-text rows around it. */
.richtext > :first-child { margin-top: 0; }
.richtext > :last-child { margin-bottom: 0; }
.richtext p { margin: 0 0 8px; }
.richtext ul { margin: 0 0 8px; padding-left: 20px; }
.richtext li { margin: 2px 0; }
.help { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ── Tables ──────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-size: .88em; letter-spacing: .02em; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--info-bg); color: var(--ink-soft); }

/* ── Flash banners ───────────────────────────────────── */
.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cd; }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: #f3c9c4; }
.flash-info { background: var(--info-bg); color: var(--ink-soft); border-color: var(--line); }

/* ── Auth screen ─────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-mark { width: 40px; height: 40px; background: var(--accent); border-radius: 10px; margin: 0 auto 12px; }

/* ── Verification (public) ───────────────────────────── */
.verify-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.verify-card { width: 100%; max-width: 520px; border-top: 4px solid var(--accent); }
.verify-head { text-align: center; margin-bottom: 8px; }
.verify-org { font-weight: 700; letter-spacing: .3px; }
.verify-status { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 14px; border-radius: var(--radius); margin: 18px 0; }
.verify-status.ok { background: var(--ok-bg); color: var(--ok); }
.verify-status.bad { background: var(--danger-bg); color: var(--danger); }
.verify-field { padding: 14px 0; border-bottom: 1px solid var(--line); }
.verify-field:last-of-type { border-bottom: none; }
.verify-field .label { margin-bottom: 4px; }
.verify-field .value { font-size: 1.02rem; }
.verify-foot { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 18px; }

/* ── Seal preview ────────────────────────────────────── */
.seal-preview { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.seal-preview img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* ── Filter bar ──────────────────────────────────────── */
.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filterbar .field { margin-bottom: 0; }
.filterbar .field.grow { flex: 1; min-width: 200px; }
.filterbar .input, .filterbar .select { padding: 8px 10px; }
.filterbar .label { margin-bottom: 4px; }
/* Dashboard filter: keep everything on one row by capping control widths so a long
   signer/category name can't stretch a select and force a wrap. */
.docfilter .field.grow { min-width: 160px; }
.docfilter select.select { width: 150px; }
.docfilter input[type="date"] { width: 150px; }

/* ── Table scroll wrapper (prevents wide tables breaking the card) ───── */
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap .table { min-width: 720px; }

/* ── Chips (category/signer tags in lists) ───────────── */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; background: var(--info-bg); color: var(--ink-soft);
  border: 1px solid var(--line);
  /* keep the pill on one line; long names truncate instead of breaking the shape */
  max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  vertical-align: top;
}
.chip-accent { background: #eff4fe; color: var(--accent-600); border-color: #c9dcfb; }

/* ── Checkbox list (pick existing signers/categories) ── */
.checklist {
  max-height: 180px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; background: #fff;
}
.checklist label {
  display: flex; align-items: center; gap: 8px; padding: 4px 2px;
  font-size: .92rem; cursor: pointer;
}
.checklist label:hover { color: var(--ink); }
.checklist .empty-mini { color: var(--muted); font-size: .85rem; padding: 6px 2px; }
.picker .checklist-search { margin-bottom: 8px; padding: 8px 10px; }
/* A checklist row: checkbox+name label, plus an optional jabatan control on the right. */
.checkitem { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 0; }
.checkitem > label { flex: 1; min-width: 140px; padding: 2px; }
.jabatan-select { width: auto; min-width: 150px; max-width: 220px; padding: 5px 8px; font-size: .85rem; }
.jabatan-hint { font-size: .82rem; font-style: italic; }

/* Signer list (public verify + edit summary): name with jabatan below, spaced. */
.signer-item + .signer-item { margin-top: 10px; }
.signer-name { font-weight: 600; }
.signer-jabatan { font-size: .85em; margin-top: 1px; }

/* Edit-block (manage rows + document edit) — static view first, form on demand.
   When JS is present the form is hidden until "Edit/Ubah"; without JS it stays
   visible as a usable fallback (app.js also calls setEditing(false) on load). */
.js [data-editform] { display: none; }
.rowname { display: inline-block; padding: 7px 0; }
[data-editform] { margin: 0; }
.summary .verify-field:first-child { padding-top: 0; }

.muted { color: var(--muted); }
.stack-sm > * + * { margin-top: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.inline-form { display: inline; }

/* ── Public language switcher ─────────────────────────
   Sits at the foot of the verification card. The visitor chooses the language; the
   install has no locale setting (ADR-012). */
.lang-switch {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--muted);
}
.lang-label { font-weight: 600; }
.lang-opt {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: #fff;
}
a.lang-opt:hover { border-color: var(--accent); color: var(--accent-600); }
.lang-opt.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── Logo setting (admin) ─────────────────────────────── */
.logo-setting { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.logo-preview {
  width: 72px; height: 72px; object-fit: contain; flex: none;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px;
}

/* ── Language menu (dashboard topbar) ─────────────────
   A plain <select> that submits its GET form on change, so the choice survives without
   JavaScript (there's a <noscript> submit button beside it). Sits left of the user menu. */
.langmenu { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.langselect {
  width: auto; padding: 5px 26px 5px 9px; font-size: .82rem;
  color: #d7dae0; background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18); border-radius: var(--radius-sm);
}
.langselect:hover { color: #fff; border-color: rgba(255, 255, 255, .35); }
.langselect:focus { outline: none; border-color: #fff; box-shadow: none; }
/* The dark bar can't style the native dropdown list, so keep its options readable. */
.langselect option { color: var(--ink); background: #fff; }

/* Visually hidden but still announced by screen readers. */
.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;
}
