/* ===========================================================
   eG Sign — eG-ID brand system (navy + electric cyan)
   Mirrors eginsightdesign: Inter body / Orbitron display.
   =========================================================== */
:root {
  --dark-bg: #0A1628;
  --darker-bg: #050D1A;
  --card-bg: #0F1F33;
  --card-bg-2: #13263d;
  --primary-cyan: #00E5CC;
  --primary-blue: #00D4FF;
  --accent-green: #00FF88;
  --danger: #ff5470;
  --text-primary: #FFFFFF;
  --text-secondary: #A0AEC0;
  --text-muted: #718096;
  --border: rgba(0, 229, 204, 0.16);
  --border-soft: rgba(160, 174, 192, 0.14);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(0, 229, 204, 0.25), 0 8px 30px rgba(0, 229, 204, 0.12);
  --radius: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Orbitron', var(--font);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  color: var(--text-primary);
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(0, 229, 204, 0.10), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(0, 212, 255, 0.08), transparent 55%),
    var(--dark-bg);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-cyan); text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(5, 13, 26, 0.7);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img { height: 30px; width: auto; display: block; }
.brand .wordmark {
  font-family: var(--font-display); font-weight: 800; letter-spacing: 0.5px;
  font-size: 1.05rem;
}
.brand .wordmark .accent { color: var(--primary-cyan); }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.who { color: var(--text-secondary); font-size: 0.85rem; }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.page-head { margin-bottom: 1.75rem; }
.page-head h1 {
  font-family: var(--font-display); font-weight: 800; font-size: 1.9rem;
  letter-spacing: -0.5px;
}
.page-head .sub { color: var(--text-secondary); margin-top: 0.35rem; }

.card {
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--card-bg-2) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.card + .card { margin-top: 1.25rem; }
.card h2 {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
  margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font); font-weight: 700; font-size: 0.95rem;
  border: none; border-radius: 11px; padding: 0.8rem 1.4rem; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
  color: #052; color: var(--darker-bg);
  box-shadow: 0 8px 24px rgba(0, 229, 204, 0.25);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(0, 229, 204, 0.40); transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(0, 229, 204, 0.08); border-color: var(--primary-cyan); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255,84,112,0.4); }
.btn-danger:hover { background: rgba(255,84,112,0.12); }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.82rem; border-radius: 9px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
label.field-label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.4rem; color: var(--text-secondary); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  width: 100%; padding: 0.8rem 0.95rem; font-family: var(--font); font-size: 0.95rem;
  background: var(--darker-bg); color: var(--text-primary);
  border: 1px solid var(--border-soft); border-radius: 11px; transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary-cyan);
  box-shadow: 0 0 0 4px rgba(0, 229, 204, 0.12);
}
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--darker-bg); }

/* ---------- Stepper ---------- */
.steps { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.step-pill {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.95rem;
  border-radius: 999px; border: 1px solid var(--border-soft);
  color: var(--text-muted); font-size: 0.85rem; font-weight: 600;
}
.step-pill .num {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(160,174,192,0.15); font-size: 0.78rem;
}
.step-pill.active { color: var(--darker-bg); background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue)); border-color: transparent; }
.step-pill.active .num { background: rgba(5,13,26,0.25); color: var(--darker-bg); }
.step-pill.done { color: var(--accent-green); border-color: rgba(0,255,136,0.35); }

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 3rem 1.5rem; text-align: center; cursor: pointer;
  transition: all 0.25s ease; background: rgba(0,229,204,0.03);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary-cyan); background: rgba(0,229,204,0.08); transform: scale(1.01); }
.dropzone .ico { font-size: 3rem; margin-bottom: 0.6rem; }
.dropzone h3 { font-family: var(--font-display); font-weight: 700; margin-bottom: 0.3rem; }
.dropzone p { color: var(--text-secondary); }
.dropzone .types { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.5rem; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 250px 1fr; gap: 1.25rem; }
.palette { display: flex; flex-direction: column; gap: 0.6rem; }
.palette .hint { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.field-chip {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.85rem;
  background: var(--darker-bg); border: 1px solid var(--border-soft); border-radius: 11px;
  cursor: grab; font-weight: 600; font-size: 0.9rem; transition: all 0.15s ease;
}
.field-chip:hover { border-color: var(--primary-cyan); transform: translateX(3px); }
.field-chip .ico { font-size: 1.2rem; }
.field-chip[disabled], .field-chip.locked { opacity: 0.4; cursor: not-allowed; }

.doc-stage {
  background: var(--darker-bg); border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: auto; max-height: 72vh; padding: 1.25rem; position: relative;
}
.doc-stage .page-wrap { position: relative; margin: 0 auto 1.25rem; width: fit-content; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.doc-stage canvas.page-canvas { display: block; border-radius: 4px; }

.drop-field {
  position: absolute; border: 2px solid var(--primary-cyan);
  background: rgba(0,229,204,0.14); border-radius: 7px; cursor: move;
  display: flex; align-items: center; justify-content: center; gap: 0.25rem;
  font-size: 0.75rem; font-weight: 700; color: var(--primary-cyan);
  text-align: center; overflow: hidden; user-select: none;
}
.drop-field .who-tag { position: absolute; bottom: 2px; right: 4px; font-size: 0.6rem; opacity: 0.8; font-weight: 600; }
.drop-field .del {
  position: absolute; top: -10px; right: -10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none; cursor: pointer; font-size: 0.75rem; display: none;
}
.drop-field:hover .del { display: block; }
.drop-field.s1 { border-color: #00E5CC; color: #00E5CC; background: rgba(0,229,204,0.14); }
.drop-field.s2 { border-color: #00D4FF; color: #00D4FF; background: rgba(0,212,255,0.14); }
.drop-field.s3 { border-color: #00FF88; color: #00FF88; background: rgba(0,255,136,0.14); }
.drop-field.s4 { border-color: #ffb020; color: #ffb020; background: rgba(255,176,32,0.14); }
.drop-field.s5 { border-color: #c084fc; color: #c084fc; background: rgba(192,132,252,0.14); }
.drop-field.s6 { border-color: #ff5470; color: #ff5470; background: rgba(255,84,112,0.14); }

/* ---------- Signers ---------- */
.signer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1rem; background: var(--darker-bg); border: 1px solid var(--border-soft);
  border-radius: 11px; margin-bottom: 0.6rem;
}
.signer-row .meta { min-width: 0; }
.signer-row .nm { font-weight: 700; }
.signer-row .em { color: var(--text-secondary); font-size: 0.85rem; }
.signer-row .right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.badge { font-size: 0.72rem; font-weight: 700; padding: 0.25rem 0.6rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.4px; }
.badge.role { background: rgba(0,229,204,0.14); color: var(--primary-cyan); }
.badge.cnt { background: rgba(160,174,192,0.14); color: var(--text-secondary); }
.add-signer { display: grid; grid-template-columns: 1.3fr 1.5fr 0.9fr auto; gap: 0.6rem; margin-top: 0.9rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 0.4rem; vertical-align: middle; }

/* ---------- Dashboard table ---------- */
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-soft); }
.doc-table td { padding: 0.85rem 0.75rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.doc-table tr:hover td { background: rgba(0,229,204,0.03); }
.status-pill { font-size: 0.74rem; font-weight: 700; padding: 0.28rem 0.65rem; border-radius: 999px; }
.status-sent, .status-in_progress { background: rgba(0,212,255,0.14); color: var(--primary-blue); }
.status-completed { background: rgba(0,255,136,0.16); color: var(--accent-green); }
.status-draft { background: rgba(160,174,192,0.14); color: var(--text-secondary); }
.status-deleted { background: rgba(255,84,112,0.14); color: var(--danger); }

/* document status tabs */
.doc-tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.doc-tab {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1rem; border-radius: 11px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-soft);
  color: var(--text-secondary); font-family: var(--font); font-weight: 600; font-size: 0.9rem;
  transition: all 0.15s ease;
}
.doc-tab:hover { border-color: var(--primary-cyan); color: var(--text-primary); }
.doc-tab.active {
  background: rgba(0,229,204,0.10); border-color: var(--primary-cyan); color: var(--primary-cyan);
}
.doc-tab .tab-count {
  font-size: 0.72rem; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 999px;
  background: rgba(160,174,192,0.16); color: var(--text-secondary); min-width: 20px; text-align: center;
}
.doc-tab.active .tab-count { background: var(--primary-cyan); color: var(--darker-bg); }
@media (max-width: 560px) { .doc-tab { flex: 1 1 45%; justify-content: center; } }
.sg-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.15rem 0; }
.sg-name { font-weight: 600; font-size: 0.88rem; }
.trail-row { display: inline-flex; gap: 0.25rem; }
.trail {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
  padding: 0.12rem 0.4rem; border-radius: 999px; cursor: default;
  background: rgba(160,174,192,0.10); color: var(--text-muted); border: 1px solid transparent;
}
.trail.on { background: rgba(0,255,136,0.14); color: var(--accent-green); border-color: rgba(0,255,136,0.3); }

/* ---------- Signature modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,13,26,0.78); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--card-bg-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 560px; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-family: var(--font-display); font-size: 1.1rem; }
.modal-body { padding: 1.4rem; }
.modal-foot { padding: 1.1rem 1.4rem; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 0.75rem; }
.sig-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.sig-tab { flex: 1; padding: 0.6rem; border-radius: 9px; border: 1px solid var(--border-soft); background: var(--darker-bg); color: var(--text-secondary); font-weight: 700; cursor: pointer; }
.sig-tab.active { background: var(--primary-cyan); color: var(--darker-bg); border-color: transparent; }
#sigPad, .sig-pad { width: 100%; height: 200px; background: #fff; border-radius: 10px; cursor: crosshair; touch-action: none; display: block; }
.sig-typed-preview { min-height: 90px; display: flex; align-items: center; justify-content: center; background: #fff; color: #111; border-radius: 10px; margin-top: 0.8rem; font-family: 'Brush Script MT', cursive; font-size: 2.4rem; }

/* ---------- Misc ---------- */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--card-bg-2); border: 1px solid var(--border); color: var(--text-primary);
  padding: 0.9rem 1.4rem; border-radius: 12px; box-shadow: var(--shadow); z-index: 200;
  transition: transform 0.3s ease; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255,84,112,0.5); }
.toast.ok { border-color: rgba(0,255,136,0.5); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty .ico { font-size: 2.5rem; margin-bottom: 0.5rem; }
.spinner { width: 38px; height: 38px; border: 4px solid var(--border-soft); border-top-color: var(--primary-cyan); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card img { height: 44px; margin-bottom: 1.25rem; }
.foot-note { text-align: center; color: var(--text-muted); font-size: 0.8rem; margin-top: 2.5rem; }
.foot-note a { color: var(--text-secondary); }
.hidden { display: none !important; }
.row { display: flex; gap: 0.75rem; align-items: center; }
.spread { justify-content: space-between; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.5rem; }

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
  .palette { flex-direction: row; flex-wrap: wrap; }
  .field-chip { flex: 1 1 28%; justify-content: center; }
  .add-signer { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .wrap { padding: 1.25rem 0.85rem 3rem; }
  .topbar { padding: 0.8rem 0.95rem; }
  .brand img { height: 26px; }
  .brand .wordmark { font-size: 0.95rem; }
  .who { display: none; }              /* free up the topbar on phones */
  .card { padding: 1.1rem; border-radius: 13px; }
  .page-head h1 { font-size: 1.45rem; }
  .page-head.row.spread, .row.spread { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .btn { width: 100%; justify-content: center; }   /* full-width tappable buttons */
  .btn-sm { width: auto; }
  .steps { gap: 0.35rem; }
  .step-pill { flex: 1; justify-content: center; padding: 0.5rem 0.4rem; font-size: 0.78rem; }
  .step-pill .num { width: 20px; height: 20px; }
  .add-signer { grid-template-columns: 1fr; }
  .field-chip { flex: 1 1 45%; }
  .doc-stage { padding: 0.6rem; }
  .signer-row { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .signer-row .right { justify-content: space-between; }
  /* signature modal */
  .modal { max-width: 100%; border-radius: 14px; }
  .modal-body { padding: 1rem; }
  #sigPad, .sig-pad { height: 170px; }
  .sig-typed-preview { font-size: 2rem; }
  .doc-table thead { display: none; }                /* stack the dashboard table */
  .doc-table, .doc-table tbody, .doc-table tr, .doc-table td { display: block; width: 100%; }
  .doc-table tr { border: 1px solid var(--border-soft); border-radius: 12px; margin-bottom: 0.7rem; padding: 0.5rem; }
  .doc-table td { border: none; padding: 0.3rem 0.5rem; }
  .doc-table td[style*="right"] { text-align: left !important; }
}
