/* Secretariat of the Kolamaafushi Council — Collaborative PDF Signing */

:root {
  --lagoon: #0c6469;
  --lagoon-deep: #083f43;
  --lagoon-mid: #168087;
  --foam: #e6f3f3;
  --sand: #f4efe4;
  --paper: #fffdf8;
  --ink: #1b2a2c;
  --muted: #5b6b6d;
  --line: #d9d0bf;
  --gold: #c4a35a;
  --gold-soft: #e8d7a2;
  --coral: #b94d3c;
  --palm: #2d7a58;
  --ok: #1f7a57;
  --wait: #b8860b;
  --shadow: 0 14px 40px rgba(27, 42, 44, 0.12);
  --radius: 16px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --script: "Great Vibes", cursive;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand);
  line-height: 1.45;
}
img { max-width: 100%; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.paper-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  background-image: radial-gradient(rgba(12, 100, 105, 0.05) 0.6px, transparent 0.7px);
  background-size: 7px 7px;
}

.setup-banner {
  position: relative;
  z-index: 20;
  margin: 0;
  padding: 12px 18px;
  background: #f8e6d8;
  color: #7a341f;
  text-align: center;
  font-size: 14px;
}
.setup-banner a { color: inherit; font-weight: 600; }

/* ---------- Auth ---------- */
.screen-auth {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.auth-wrap { width: min(440px, 100%); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand img { display: block; margin: 0 auto 12px; }
.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--lagoon);
  font-weight: 600;
}
.auth-brand h1 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  margin: 8px 0 6px;
}
.auth-brand .sub, .auth-foot { color: var(--muted); font-size: 13.5px; }
.auth-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.auth-card-title {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 0 16px;
}
.auth-foot { text-align: center; margin-top: 18px; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--foam);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}
.seg-btn {
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
}
.seg-btn.is-on { background: #fff; color: var(--lagoon-deep); box-shadow: 0 2px 8px rgba(8, 63, 67, 0.08); }

.stack { display: grid; gap: 14px; }
label, .lbl { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--lagoon-deep); }
label small, .muted { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
}
input:focus {
  outline: 2px solid rgba(12, 100, 105, 0.28);
  border-color: var(--lagoon-mid);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  background: transparent;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--lagoon); color: #fff; }
.btn-primary:hover { background: var(--lagoon-deep); }
.btn-secondary { background: var(--foam); color: var(--lagoon-deep); border-color: #c5e0e1; }
.btn-ghost { border-color: var(--line); background: #fff; }
.btn-ghost.danger, .danger { color: var(--coral); }
.danger-fill { background: var(--coral); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- App chrome ---------- */
.screen-app { position: relative; z-index: 1; min-height: 100vh; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
  background: var(--lagoon-deep);
  color: #eef7f7;
  border-bottom: 3px solid var(--gold);
}
.topbar-brand { display: flex; gap: 12px; align-items: center; }
.topbar-brand strong { display: block; font-size: 15px; }
.topbar-brand span { display: block; font-size: 12px; opacity: 0.78; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.who { text-align: right; }
.who strong { display: block; font-size: 13.5px; }
.who span { display: block; font-size: 12px; opacity: 0.75; }
.topbar .btn-ghost { color: #eef7f7; border-color: rgba(255,255,255,0.2); background: transparent; }

.dash { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 64px; }
.dash-intro {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 22px;
}
.dash-intro h2 {
  font-family: var(--serif);
  margin: 6px 0 8px;
  font-size: 32px;
  font-weight: 600;
}
.lede { margin: 0; color: var(--muted); max-width: 560px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat span { display: block; font-family: var(--serif); font-size: 28px; color: var(--lagoon-deep); }
.stat label { color: var(--muted); font-size: 12.5px; }

.tabs, .sig-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  border: 0;
  background: transparent;
  padding: 8px 4px 10px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab.is-on { color: var(--lagoon-deep); border-bottom-color: var(--gold); }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.doc-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(27, 42, 44, 0.05);
  display: grid;
  gap: 8px;
  text-align: left;
  width: 100%;
}
.doc-card:hover { border-color: var(--lagoon-mid); }
.doc-card h3 { margin: 0; font-size: 16.5px; font-family: var(--serif); }
.doc-card p { margin: 0; color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-pending { background: #f8ecd0; color: #8a6508; }
.badge-partial { background: #dceef0; color: #0c6469; }
.badge-completed { background: #d7efe4; color: #1f7a57; }
.badge-need { background: #f8ddd8; color: var(--coral); }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.progress {
  height: 6px;
  background: var(--foam);
  border-radius: 99px;
  overflow: hidden;
}
.progress > i { display: block; height: 100%; background: var(--lagoon-mid); }
.empty { color: var(--muted); text-align: center; padding: 40px 12px; }

/* ---------- Viewer ---------- */
.overlay, .modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 32, 34, 0.42);
  display: grid;
}
.overlay { z-index: 25; padding: 0; }
.viewer {
  background: var(--sand);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
}
.viewer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--lagoon-deep);
  color: #eef7f7;
  border-bottom: 3px solid var(--gold);
}
.viewer-title { flex: 1; min-width: 0; }
.viewer-title strong, .viewer-title span { display: block; }
.viewer-title span { font-size: 12px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-head .btn-ghost { color: #eef7f7; border-color: rgba(255,255,255,0.18); background: transparent; }
.viewer-actions { display: flex; gap: 8px; }
.viewer-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 0;
}
.pdf-pane {
  overflow: auto;
  padding: 18px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(12,100,105,0.05), transparent 80px),
    #dfe8e4;
}
.pdf-pages { display: grid; gap: 16px; justify-items: center; }
.pdf-page {
  position: relative;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,0.16);
  line-height: 0;
}
.pdf-page canvas { display: block; width: 100%; height: auto; max-width: min(820px, 100%); }
.pdf-page.is-place { cursor: crosshair; }
.sig-ghost {
  position: absolute;
  pointer-events: none;
  border: 1px dashed var(--lagoon);
  background: rgba(255,255,255,0.15);
  box-sizing: border-box;
  z-index: 3;
}
.sig-ghost.is-placed {
  pointer-events: auto;
  cursor: move;
  border-style: solid;
  box-shadow: 0 0 0 1px rgba(12, 100, 105, 0.35);
}
.sig-follow { pointer-events: none; opacity: 0.72; }
.sig-remove, .sig-accept {
  position: absolute;
  top: -12px;
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  line-height: 18px;
  padding: 0;
  cursor: pointer;
  z-index: 6;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.sig-remove { right: -12px; background: var(--coral); }
.sig-accept { left: -12px; background: var(--ok); font-size: 15px; }
.sig-ghost.is-confirmed .sig-accept { display: none; }
.sig-colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lagoon-deep);
}
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
}
.swatch.is-on { box-shadow: 0 0 0 2px var(--lagoon); }
.sig-ghost img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.sig-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--lagoon);
  border: 2px solid #fff;
  border-radius: 2px;
  z-index: 4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.sig-handle.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.sig-handle.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.sig-handle.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.sig-handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.place-hint {
  position: sticky;
  top: 8px;
  z-index: 2;
  margin: 0 auto 12px;
  width: fit-content;
  background: var(--lagoon-deep);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
}
.side-pane {
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}
.side-pane h3 { margin: 0 0 8px; font-family: var(--serif); }
.status-line { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.people strong { font-size: 13.5px; }
.people em { font-style: normal; font-size: 12px; color: var(--muted); }
.side-actions { display: grid; gap: 8px; margin-top: 16px; }
.expiry { margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.place-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--lagoon-deep);
  color: #eef7f7;
  border-top: 3px solid var(--gold);
}
.place-bar #place-bar-label { flex: 1; font-size: 13.5px; font-weight: 600; }
.place-bar .btn-ghost { color: #eef7f7; border-color: rgba(255,255,255,0.25); background: transparent; }
.place-bar .size-ctl { color: #eef7f7; }
.btn-apply {
  background: var(--gold);
  color: #1b2a2c;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 15px;
  min-width: 200px;
}
.btn-apply:disabled { opacity: 0.45; cursor: not-allowed; animation: none; }
.btn-apply.is-pulse {
  animation: pulse-apply 1.15s ease-in-out infinite;
}
@keyframes pulse-apply {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(196, 163, 90, 0.65); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(196, 163, 90, 0); }
}
.size-ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lagoon-deep);
  margin: 0;
}
.size-ctl input[type="range"] { width: 140px; }

/* ---------- Modals ---------- */
.modal { place-items: center; padding: 18px; z-index: 40; }
.modal-card {
  width: min(520px, 100%);
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}
.modal-wide { width: min(760px, 100%); }
.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}
.modal-card h3 { margin: 0; font-family: var(--serif); }
.icon-x {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
}
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.file-drop {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--foam);
}
.file-drop em { font-style: normal; color: var(--muted); font-weight: 400; }

.picker { position: relative; }
.user-results {
  position: absolute;
  z-index: 3;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 4px;
  max-height: 220px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.user-results button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 8px 10px;
}
.user-results button:hover { background: var(--foam); }
.user-results small { display: block; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--foam);
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
  font-size: 12.5px;
}
.chip button { border: 0; background: transparent; color: var(--coral); font-size: 16px; }

#sig-canvas, #type-canvas {
  width: 100%;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(#e8e0d0 1px, transparent 1px);
  background-size: 100% 36px;
  background-color: #fff;
  touch-action: none;
}
.sig-preview {
  min-height: 100px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 10px;
}
.sig-preview img { max-height: 140px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 12px 0; }
.check input { width: 16px; height: 16px; }

.toasts {
  position: fixed;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 6px;
  pointer-events: none;
}
.toast {
  min-width: 0;
  max-width: 280px;
  background: rgba(8, 63, 67, 0.88);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  text-align: center;
  box-shadow: none;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--coral); }

.busy {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(255,253,248,0.55);
  display: grid;
  place-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--lagoon-deep);
}
.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--foam);
  border-top-color: var(--lagoon);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 880px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .dash-intro, .topbar, .viewer-head { flex-wrap: wrap; }
  .viewer-body { grid-template-columns: 1fr; }
  .side-pane { border-left: 0; border-top: 1px solid var(--line); }
  .who { display: none; }
  .dash-intro h2 { font-size: 26px; }
}
