/* AutenTIC Firma (POC) — mobile first. Paleta y tipografía del manual de marca. */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("fonts/Poppins-Regular.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("fonts/Poppins-Medium.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("fonts/Poppins-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("fonts/Poppins-Bold.ttf") format("truetype"); }

:root {
  --navy: #1D3157;
  --blue: #1757AE;
  --blue-dark: #124a96;
  --yellow: #FAB72B;
  --red: #F23307;
  --green: #34B668;
  --bg: #EFEFEF;
  --card: #FFFFFF;
  --muted: #5A6B85;
  --line: #D9DEE6;
  --radius: 16px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--navy);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--blue); }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 700; margin: 0 0 8px; text-wrap: balance; }
h2 { font-size: 1.0625rem; font-weight: 600; margin: 0; }
p { margin: 0 0 16px; }
strong { font-weight: 600; }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.75rem; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.franja { height: 5px; background: url("img/franja-multicolor.png") center / 100% 100% no-repeat; }

.topbar, .page, .actionbar { width: 100%; max-width: 560px; margin-inline: auto; padding-inline: var(--gutter); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding-block: 14px 6px; }
.brand { display: inline-flex; padding: 6px 0; }
.brand img { height: 28px; width: auto; display: block; }
.session { display: flex; align-items: center; gap: 4px; }
.session form { margin: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy); color: #fff; font-size: 0.8125rem; font-weight: 600;
}
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent;
  color: var(--navy); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--line); }

.page { padding-block: 12px 32px; }
.has-actionbar .page { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
.lead { color: var(--muted); }
.note { color: var(--muted); font-size: 0.8125rem; display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; text-align: center; }
.done ~ .note { display: block; }

.back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  color: var(--blue); font-weight: 500; font-size: 0.9375rem; text-decoration: none;
}

/* Botones */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 12px 20px; margin-bottom: 12px;
  border: 2px solid transparent; border-radius: 14px;
  font: inherit; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer;
  transition: background-color .15s, transform .05s;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--card); color: var(--blue); border-color: var(--blue); }
.btn-ghost { background: transparent; color: var(--blue); min-height: 44px; }
.btn[disabled], .btn[aria-disabled="true"] { background: #B9C2D0; color: #fff; cursor: not-allowed; transform: none; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  background: #FDE9E4; color: #8F1D03; border-radius: 12px; padding: 12px 14px;
  font-size: 0.9375rem;
}
.alert .icon { margin-top: 2px; }

/* Ingreso */
.centered .page { min-height: calc(100dvh - 5px); display: grid; align-content: center; }
.login { text-align: center; padding-block: 24px; }
.login-logo { height: 48px; width: auto; margin: 0 auto 36px; display: block; }
.login .lead { margin-bottom: 28px; }
.login .alert { text-align: left; }

/* Inicio */
.greeting { font-size: 1.75rem; margin-top: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); color: var(--navy); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none;
}
.stat-number { font-size: 2.5rem; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.stat-primary { background: var(--navy); color: #fff; }
.stat-primary .stat-number { color: var(--yellow); }
.stat-primary .stat-label { color: #D5DCE8; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 0 10px; }
.section-head a { font-size: 0.875rem; font-weight: 500; padding: 10px 0 10px 12px; }

/* Lista de documentos */
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.doc {
  display: flex; align-items: center; gap: 12px; min-height: 72px;
  background: var(--card); border-radius: var(--radius); padding: 12px 10px 12px 14px;
  color: inherit; text-decoration: none;
}
.doc:active { background: #F7F9FC; }
.doc-icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; background: #E6EEF9; color: var(--blue);
}
.doc-icon.is-signed { background: #E2F5EA; color: #1E8449; }
.doc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 0.8125rem; color: var(--muted); }
.doc-chevron { color: #9AA6B8; display: grid; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #E1E4EA; border-radius: 12px; padding: 4px; margin: 12px 0 16px; }
.tabs a {
  min-height: 44px; display: grid; place-items: center; border-radius: 9px;
  font-size: 0.875rem; font-weight: 500; color: var(--navy); text-decoration: none; text-align: center;
}
.tabs a[aria-current="page"] { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(29, 49, 87, .12); }
.empty { text-align: center; padding: 40px 8px; color: var(--muted); }

/* Subir documento */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: 2px dashed #9DB4D6; border-radius: var(--radius);
  padding: 32px 16px; margin-bottom: 16px; color: var(--blue); text-align: center; cursor: pointer;
}
input:focus-visible + .btn, .dropzone:has(+ input:focus-visible) { outline: 3px solid var(--yellow); outline-offset: 2px; }
.dropzone-title { font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.dropzone-hint { font-size: 0.8125rem; color: var(--muted); }

/* Visor */
.doc-title { font-size: 1.25rem; overflow-wrap: anywhere; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  background: #FFF1D1; color: #7A5200; font-weight: 500;
}
.badge-ok { background: #E2F5EA; color: #1E6B3C; }
.visor { display: grid; gap: 10px; margin-top: 14px; }
.visor-page {
  background: #fff; border-radius: 6px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(29, 49, 87, .18);
  aspect-ratio: 612 / 792;
}
.visor-page canvas { display: block; width: 100%; height: 100%; }
.visor-status { text-align: center; color: var(--muted); padding: 40px 0; margin: 0; }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding-top: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(239, 239, 239, 0));
}
.actionbar .btn { margin: 0; box-shadow: 0 6px 16px rgba(23, 87, 174, .28); }

/* Ubicar la firma */
.visor-page { position: relative; }
.visor.is-placing .visor-page { cursor: pointer; }
.stamp {
  position: absolute; z-index: 2; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--blue); border-radius: 4px;
  background: rgba(255, 255, 255, .88); color: var(--blue);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden;
  box-shadow: 0 2px 10px rgba(23, 87, 174, .35);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.stamp::before { content: ""; position: absolute; inset: -12px; } /* zona táctil más amplia */
.stamp.is-dragging { cursor: grabbing; background: rgba(230, 238, 249, .95); }
.actionbar.is-placing { background: var(--bg); box-shadow: 0 -1px 0 var(--line), 0 -8px 20px rgba(29, 49, 87, .10); }
.place-hint { font-size: 0.875rem; color: var(--navy); margin: 0 0 10px; }
.place-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.actionbar.is-placing .btn { box-shadow: none; }
.is-placing-body .page { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }

/* Selfie */
.selfie-frame {
  position: relative; width: min(100%, 340px); aspect-ratio: 3 / 4; margin: 8px auto 16px;
  background: var(--navy); border-radius: 24px; overflow: hidden;
}
.selfie-frame video, .selfie-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.selfie-frame video { transform: scaleX(-1); }
.selfie-guide {
  position: absolute; inset: 12% 16% 18%; border: 3px dashed rgba(255, 255, 255, .85); border-radius: 50%;
  pointer-events: none;
}
.selfie-placeholder {
  position: absolute; inset: 0; margin: 0; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: #D5DCE8; text-align: center; font-size: 0.9375rem;
}
.selfie-actions { max-width: 340px; margin-inline: auto; }

/* Firmado */
.done { text-align: center; padding-top: 12px; }
.done-icon {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; background: var(--green); color: #fff;
}
.facts { background: var(--card); border-radius: var(--radius); margin: 8px 0 20px; padding: 4px 16px; }
.facts > div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd .muted { font-weight: 400; font-size: 0.875rem; }

@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:active { transform: none; } }
