/* ============================================================
 * app.css — Live UI styles for the ProAgri Leave Application
 * Single-page layout. All selectors are scoped under `.app`
 * so we don't leak into the PDF templates.
 * ============================================================ */

.app {
  /* tokens */
  --brand-red: #e21a23;
  --brand-red-tint: #fef2f2;
  --brand-red-dark: #b30f17;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --bg: #f6f7f9;
  --paper: #fffdf7;
  --card: #ffffff;
  --ok: #10b981;
  --ok-bg: #ecfdf5;
  --ok-line: #a7f3d0;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --err-line: #fecaca;
  --info-bg: #eff6ff;
  --info-line: #bfdbfe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.04);
  --shadow-2: 0 8px 24px rgba(15,23,42,.04);
  --shadow-3: 0 12px 32px rgba(15,23,42,.08);
  --t-fast: 120ms ease;
  --t-med: 200ms ease;

  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  color: var(--ink);
}

/* ----- header ----- */
.app .brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.app .logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}
.app .bullseye {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--brand-red) 0 4px, #ffffff 4px 8px,
                    var(--brand-red) 8px 12px, #ffffff 12px 16px,
                    var(--brand-red) 16px 28px);
  box-shadow: 0 0 0 2px var(--brand-red) inset;
}
.app .wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 22px;
  line-height: 1;
}
.app .wordmark .red { color: var(--brand-red); }
.app .wordmark .media { color: var(--ink); }
.app .tag {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ----- top banner (validation / errors) ----- */
.app .top-banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  background: var(--err-bg);
  border: 1px solid var(--err-line);
  color: var(--err);
  box-shadow: var(--shadow-1);
}
.app .top-banner.is-info {
  background: var(--info-bg);
  border-color: var(--info-line);
  color: #1d4ed8;
}

/* ----- card ----- */
.app .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-1), var(--shadow-2);
}
.app .card h2 {
  font-size: 18px;
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.app .card .sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 18px;
}

/* ----- form atoms ----- */
.app label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.app fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
.app fieldset legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}
.app input[type="text"],
.app input[type="email"],
.app input[type="date"],
.app textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.app input:focus,
.app textarea:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(226,26,35,0.12);
}
.app textarea {
  min-height: 80px;
  resize: vertical;
}
.app .grid { display: grid; gap: 14px; }
.app .grid.cols-2 { grid-template-columns: 1fr 1fr; }
.app .grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.app .gap-top { margin-top: 14px; }
.app .gap-top-sm { margin-top: 10px; }
.app .hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.app .row-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.app .inline-label {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ----- leave-type radio cards ----- */
.app .choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.app .choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  margin: 0;
}
.app .choice:hover { border-color: var(--muted-2); }
.app .choice input { accent-color: var(--brand-red); margin: 0; }
.app .choice:has(input:checked) {
  border-color: var(--brand-red);
  background: var(--brand-red-tint);
  color: var(--ink);
}
.app .choice.choice-sm { padding: 8px 14px; font-size: 13px; }

/* ----- doc ref pill ----- */
.app .doc-ref-row {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app .doc-ref-pill {
  display: inline-block;
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  background: #f1f5f9;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ============================================================
 * SIGNATURES
 * ============================================================ */
.app .sig-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.app .sig-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.app .sig-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.app .sig-panel-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-red);
  background: var(--brand-red-tint);
  border: 1px solid #fecaca;
  padding: 3px 10px;
  border-radius: 999px;
}
.app .sig-panel-status {
  font-size: 12px;
  color: var(--ok);
  font-weight: 600;
}
.app .sig-panel-status:empty { display: none; }

/* ----- font-style preview pills ----- */
.app .font-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.app .font-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  min-height: 64px;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.app .font-pill:hover { border-color: var(--muted-2); }
.app .font-pill .pill-sample {
  font-size: 24px;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.app .font-pill .pill-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
}
.app .font-pill.is-selected {
  border-color: var(--brand-red);
  background: var(--brand-red-tint);
}
.app .font-pill.is-selected::after {
  content: "\2713";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  color: var(--brand-red);
  font-weight: 700;
  font-family: 'Inter', sans-serif;
}
.app .font-pill.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ----- large signed preview ----- */
.app .sig-preview {
  margin-top: 14px;
  background:
    repeating-linear-gradient(
      0deg,
      var(--paper) 0px,
      var(--paper) 28px,
      #f4f1e6 28px,
      #f4f1e6 29px
    ),
    var(--paper);
  border: 1px solid #ede5cc;
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  min-height: 96px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}
.app .sig-preview::after {
  /* thin baseline rule the script font sits on */
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 22px;
  height: 1px;
  background: #d6cdb0;
}
.app .sig-preview-placeholder {
  color: var(--muted-2);
  font-style: italic;
  font-size: 13px;
  align-self: center;
  margin: 0 auto;
}
.app .sig-preview .sig-preview-text {
  font-size: 42px;
  line-height: 1;
  color: #0b3d91;
  position: relative;
  z-index: 1;
  padding-bottom: 6px;
}
.app .sig-preview.adopted { box-shadow: inset 0 0 0 1px #f1e3a6; }

/* ============================================================
 * SUBMIT ROW
 * ============================================================ */
.app .submit-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-1);
}
.app .submit-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app .submit-meta-signers {
  font-size: 12px;
  color: var(--ink-soft);
}
.app .submit-meta-signers strong { color: var(--ink); font-weight: 600; }

/* ----- buttons ----- */
.app .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
}
.app .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(226,26,35,0.18);
}
.app .btn-primary {
  background: var(--brand-red);
  color: #fff;
  border-color: var(--brand-red);
}
.app .btn-primary:hover { background: var(--brand-red-dark); border-color: var(--brand-red-dark); }
.app .btn-primary:disabled {
  background: #e5e7eb;
  border-color: #e5e7eb;
  color: #94a3b8;
  cursor: not-allowed;
}
.app .btn-ghost {
  background: #fff;
  border-color: var(--line-2);
  color: var(--ink-soft);
}
.app .btn-ghost:hover {
  background: #f8fafc;
  border-color: var(--muted-2);
  color: var(--ink);
}
.app .btn-lg { padding: 12px 22px; font-size: 15px; }
.app .btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.app .btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  animation: app-spin 0.7s linear infinite;
}
.app .btn-ghost.is-loading::after {
  border-color: rgba(15,23,42,0.2);
  border-top-color: var(--ink);
}
@keyframes app-spin { to { transform: rotate(360deg); } }

/* ============================================================
 * RESULT CARD
 * ============================================================ */
.app .result-card { border-color: var(--ok-line); }
.app .result-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 14px;
  color: #065f46;
}
.app .result-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.app .link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.app .link-row input {
  flex: 1;
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f8fafc;
}
.app .result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.app .result-foot {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.app .result-foot code {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ink-soft);
}

/* ============================================================
 * MOBILE
 * ============================================================ */
@media (max-width: 720px) {
  .app { padding: 18px 14px 40px; }
  .app .brand { flex-direction: column; align-items: flex-start; gap: 6px; }
  .app .grid.cols-2,
  .app .grid.cols-3 { grid-template-columns: 1fr; }
  .app .choices { grid-template-columns: 1fr 1fr; }
  .app .sig-grid { grid-template-columns: 1fr; }
  .app .font-pills { grid-template-columns: 1fr 1fr; }
  .app .submit-row { flex-direction: column; align-items: stretch; }
  .app .submit-row .btn { width: 100%; }
  .app .link-row { flex-direction: column; }
  .app .link-row .btn { width: 100%; }
}

/* ============================================================
 * Reduced motion
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .app .btn,
  .app .choice,
  .app .font-pill,
  .app input,
  .app textarea { transition: none; }
  .app .btn.is-loading::after { animation: none; }
}
