/* Jay Forms — same palette as the main Jay app (public/index.html). */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --header-bg: #0B1730;
  --header-text: #FFFFFF;
  --header-muted: #C7D2E4;
  --header-border: #8091B8;
  --header-raised: #12254A;
  --bg-page: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-viewer: #E9EDF3;
  --border: #C3CBD9;
  --border-strong: #5A6B8C;
  --text: #111827;
  --text-strong: #0B1730;
  --text-muted: #374151;
  --text-dim: #4B5563;
  --gold: #B8943C;
  --gold-bright: #D4AD4F;
  --blue: #2563EB;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warn: #B45309;
  --warn-bg: #FFFBEB;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
  --header-h: 60px;
  --side-w: 340px;
}

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #1D4ED8;
  outline-offset: 2px;
}

/* ── Header (matches public/index.html) ─────────────────────────────────── */

.topbar {
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  color: var(--header-text);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand .mark-jay {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  color: var(--gold-bright);
}
.brand .mark-firm {
  font-family: 'Adobe Devanagari', 'EB Garamond', Georgia, serif;
  font-variant-caps: small-caps;
  letter-spacing: 0.05em;
  font-weight: 500;
  font-size: 21px;
  line-height: 1;
  color: var(--header-text);
  white-space: nowrap;
}

.header-nav { display: flex; gap: 6px; margin-left: 12px; flex-shrink: 0; }
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border-radius: 7px;
  border: 1.5px solid var(--header-border);
  color: var(--header-text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
}
.nav-link:hover { background: rgba(255,255,255,0.1); }
.nav-link[aria-current="page"] {
  background: var(--header-text);
  border-color: var(--header-text);
  color: var(--header-bg);
}

.matter-search { position: relative; flex: 1; max-width: 520px; margin-left: 12px; }
.matter-search input {
  width: 100%;
  height: 38px;
  border-radius: 7px;
  border: 1.5px solid var(--header-border);
  background: var(--header-raised);
  color: var(--header-text);
  padding: 0 12px;
  font: inherit;
  font-weight: 500;
}
.matter-search input::placeholder { color: var(--header-muted); }
.matter-search input:focus { outline: 3px solid var(--gold-bright); outline-offset: -1px; }

.matter-results {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 60vh;
  overflow-y: auto;
}
.matter-results li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.matter-results li:hover, .matter-results li.active { background: #FFF7E0; }
.matter-results .num { font-weight: 600; color: var(--text-strong); }
.matter-results .desc { color: var(--text-dim); font-size: 12.5px; }
.matter-results .none { color: var(--text-dim); cursor: default; }

#formSelect {
  height: 38px;
  border-radius: 7px;
  border: 1.5px solid var(--header-border);
  background: var(--header-raised);
  color: var(--header-text);
  padding: 0 10px;
  font: inherit;
  font-weight: 600;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  height: calc(100% - var(--header-h));
}
.viewer {
  flex: 1;
  overflow: auto;
  background: var(--bg-viewer);
  padding: 20px 16px 60px;
  position: relative;
}
.side {
  width: var(--side-w);
  flex-shrink: 0;
  overflow-y: auto;
  border-left: 2px solid var(--border);
  background: var(--bg-page);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty { max-width: 560px; margin: 12vh auto 0; text-align: center; color: var(--text); }
.empty h1 { font-family: 'EB Garamond', Georgia, serif; font-size: 30px; color: var(--text-strong); font-weight: 600; margin-bottom: 10px; }
.empty p { line-height: 1.6; font-size: 16px; }

.mode-banner {
  max-width: 880px;
  margin: 0 auto 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #A7F3D0;
}

.pages { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.page {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-lg);
  /* PDF.js v6 sizes its annotation layer with these (set by its own viewer). */
  --user-unit: 1;
  --scale-round-x: 1px;
  --scale-round-y: 1px;
}
.page canvas { display: block; }
.page .annotationLayer { position: absolute; top: 0; left: 0; }
/* Let 9pt text sit in a 9pt box the way the PDF draws it. */
.page .annotationLayer .textWidgetAnnotation input { padding: 0 1px; line-height: 1; }
.page .annotationLayer .textWidgetAnnotation textarea { padding: 1px; line-height: 1.1; }
.proof .page { outline: 2px solid var(--success); }

/* ── Side panel ─────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-label { font-size: 12px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); }
.matter-title { font-weight: 700; color: var(--text-strong); font-size: 17px; }
.matter-meta { color: var(--text-muted); font-size: 14px; line-height: 1.45; }
.hint { margin: 0; color: var(--text); font-size: 14px; line-height: 1.5; }
.edit-count { margin: 0; font-size: 14px; color: var(--text-muted); }
.row-actions { display: flex; gap: 14px; }

.missing, .warnings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.missing li { font-size: 14px; color: var(--text); }
.missing li span { color: var(--text-muted); }
.warnings li { font-size: 14px; padding: 6px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); }
.warnings li.ok { background: var(--success-bg); color: #14532D; }

.save-folder { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.folder-name { font-size: 14px; color: var(--text-strong); word-break: break-all; }
.filename { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.filename input {
  height: 36px;
  border: 2px solid var(--border-strong);
  border-radius: 7px;
  padding: 0 8px;
  font: inherit;
  font-size: 14px;
  color: var(--text-strong);
}

.btn-primary, .btn-secondary {
  height: 42px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: 2px solid transparent;
}
.btn-primary { background: var(--text-strong); color: #FFFFFF; border-color: var(--text-strong); }
.btn-primary:hover:not(:disabled) { background: #1A3160; }
.btn-secondary { background: var(--bg-surface); color: var(--text-strong); border-color: var(--text-strong); }
.btn-secondary:hover:not(:disabled) { background: #F1F5FB; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.45; cursor: default; }
.btn-link { background: none; border: 0; padding: 0; color: #1E40AF; font-size: 14px; font-weight: 600; text-decoration: underline; cursor: pointer; }
.btn-link:disabled { color: var(--text-dim); cursor: default; text-decoration: none; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--header-bg);
  color: var(--header-text);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  z-index: 50;
  max-width: 90vw;
}
.toast.error { background: var(--error); color: #fff; }

.busy { cursor: progress; }

@media (max-width: 1100px) {
  .brand .mark-firm { display: none; }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; height: auto; }
  .side { width: auto; border-left: 0; border-top: 2px solid var(--border); }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .header-nav { margin-left: 0; }
  .matter-search { flex: 1 1 100%; max-width: none; margin-left: 0; }
}
