/* Eraikuntza Firma — hoja de estilos
   Mesa de dibujo técnico: papel de calco frío, tinta pizarra, azul de plano para acciones
   y amarillo de obra reservado para lo que requiere atención o firma. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/AtkinsonHyperlegible-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/AtkinsonHyperlegible-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --paper: #F3F5F2;
  --surface: #FFFFFF;
  --ink: #1F2A33;
  --ink-soft: #33414D;
  --muted: #5B6670;
  --line: #D5D9D4;
  --line-soft: #E6E9E4;
  --blue: #1E4E79;
  --blue-deep: #163B5C;
  --blue-wash: #E3EBF2;
  --yellow: #F2B705;
  --yellow-wash: #FFF5CF;
  --green: #2E7D4F;
  --green-wash: #E2F1E7;
  --red: #B3261E;
  --red-wash: #FBE6E4;
  --grid: rgba(30, 78, 121, 0.055);
  --radius: 6px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  /* cuadrícula de papel milimetrado, muy tenue */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
a { color: var(--blue); }
a:hover { color: var(--blue-deep); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .88em; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 3px; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font: inherit; font-weight: 700; font-size: .95rem;
  padding: .6em 1.05em; min-height: 42px;
  border-radius: var(--radius); border: 1px solid transparent;
  background: var(--blue); color: #fff; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--blue-deep); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { background: var(--blue-wash); color: var(--blue-deep); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #E7B9B5; }
.btn-danger:hover { background: var(--red-wash); color: var(--red); }
.btn-sign { background: var(--ink); color: #fff; font-size: 1.05rem; min-height: 52px; padding: .7em 1.4em; }
.btn-sign:hover { background: #000; }
.btn-sm { min-height: 34px; padding: .35em .75em; font-size: .86rem; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 0; min-height: 0; font-weight: 700; text-decoration: underline; }
.btn-link:hover { background: none; color: var(--blue-deep); }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* ------------------------------------------------------------ formularios */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: .6em .75em; min-height: 44px;
  border: 1px solid #BFC5BE; border-radius: var(--radius); background: #fff;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--yellow); outline-offset: 0; border-color: var(--ink); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--blue); vertical-align: middle; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: .95rem; }
.check input { margin-top: .15rem; flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ avisos */
.notice { padding: .8rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 1rem; }
.notice-ok { border-color: #B7D8C3; background: var(--green-wash); }
.notice-error { border-color: #E7B9B5; background: var(--red-wash); }
.notice-warn { border-color: #EBD178; background: var(--yellow-wash); }
.notice p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------ chips de estado */
.status { display: inline-flex; align-items: center; gap: .4em; font-size: .82rem; font-weight: 700; padding: .15em .6em; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; }
.status::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: currentColor; }
.st-borrador { color: var(--muted); background: #EEF0ED; }
.st-enviado { color: #7A5A00; background: var(--yellow-wash); border-color: #EBD178; }
.st-firmado { color: var(--green); background: var(--green-wash); }
.st-rechazado { color: var(--red); background: var(--red-wash); }
.st-anulado, .st-vencido { color: var(--muted); background: #EEF0ED; text-decoration: line-through; }
.st-vencido { text-decoration: none; }

/* ============================================================ panel del empleador */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.rail {
  background: var(--ink); color: #DCE3E8; padding: 1.2rem 1rem;
  display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh;
}
.brand { color: #fff; text-decoration: none; display: block; }
.brand strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.brand span { font-size: .8rem; color: #9FB0BD; }
.brand-bar { height: 4px; width: 56px; background: var(--yellow); margin-top: .6rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #DCE3E8; text-decoration: none; padding: .55rem .7rem; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--yellow); }
.nav .count { background: var(--yellow); color: var(--ink); border-radius: 99px; font-size: .75rem; padding: 0 .5em; min-width: 1.6em; text-align: center; }
.nav-sub { border-top: 1px solid rgba(255,255,255,.1); padding-top: .8rem; }
.nav-sub a { font-weight: 400; font-size: .9rem; color: #B9C6D0; }
.rail-foot { margin-top: auto; font-size: .82rem; color: #9FB0BD; }
.meter { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; margin: .35rem 0; }
.meter i { display: block; height: 100%; background: var(--yellow); }
.rail-foot a { color: #DCE3E8; }

.main { padding: 1.6rem 2rem 4rem; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.4rem; }
.topbar h1 { margin: 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: .3rem; }
.crumbs a { color: var(--muted); }
.mobile-bar { display: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1.2rem; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }

/* --- carpetas de trabajadores (estilo Drive, en clave de archivo técnico) --- */
.toolbar { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }
.toolbar input[type=search] { max-width: 340px; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.6rem 1.1rem; padding-top: 10px; }
.folder {
  position: relative; display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: .9rem 1rem 1rem; min-height: 132px;
}
.folder::before { /* pestaña */
  content: ""; position: absolute; left: -1px; top: -11px; width: 44%; height: 11px;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
}
.folder::after { /* cinta de la pestaña: amarilla si hay algo por firmar */
  content: ""; position: absolute; left: 10px; top: -6px; width: 26%; height: 3px; border-radius: 2px; background: var(--line);
}
.folder.has-pending::after { background: var(--yellow); }
.folder.has-rejected::after { background: var(--red); }
.folder:hover { border-color: var(--blue); }
.folder:hover::before { border-color: var(--blue); }
.folder-name { font-weight: 700; font-size: 1.02rem; line-height: 1.25; margin-bottom: .15rem; }
.folder-meta { font-size: .85rem; color: var(--muted); }
.folder-counts { margin-top: .7rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.folder.is-inactive { opacity: .7; }
.empty { text-align: center; padding: 3rem 1rem; border: 2px dashed var(--line); border-radius: var(--radius); background: rgba(255,255,255,.6); }
.empty h2 { margin-bottom: .3rem; }

/* --- ficha del trabajador --- */
.worker-head { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem 1.4rem; margin: .6rem 0 0; }
.facts div { min-width: 0; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
details.edit > summary { cursor: pointer; font-weight: 700; color: var(--blue); list-style: none; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] > summary { margin-bottom: 1rem; }

/* --- zona de carga --- */
.drop {
  border: 2px dashed #AEB8C0; border-radius: var(--radius); background: #FAFBF9;
  padding: 1.4rem; text-align: center; cursor: pointer;
}
.drop.is-over { border-color: var(--blue); background: var(--blue-wash); }
.drop strong { display: block; font-size: 1.05rem; }
.queue { margin-top: 1rem; display: none; }
.queue.has-items { display: block; }
.qrow { display: grid; grid-template-columns: 1fr 210px 32px; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line-soft); }
.qrow .qname { font-size: .82rem; color: var(--muted); margin-top: .2rem; overflow-wrap: anywhere; }
.qrow .bar { height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: .35rem; overflow: hidden; }
.qrow .bar i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.qrow.done .bar i { background: var(--green); }
.qrow.fail .bar i { background: var(--red); width: 100% !important; }
.qrow .qerr { color: var(--red); font-size: .85rem; margin-top: .2rem; }
@media (max-width: 700px) { .qrow { grid-template-columns: 1fr 32px; } .qrow select { grid-column: 1 / -1; } }

/* --- lista de documentos --- */
.files { width: 100%; border-collapse: collapse; }
.files th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 700; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
.files td { padding: .7rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.files tr:hover td { background: #FAFBF9; }
.files .ftitle { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; gap: .55rem; align-items: center; }
.files .ftitle:hover { color: var(--blue); }
.pdf-ico { flex: none; width: 26px; height: 32px; position: relative; background: #fff; border: 1.5px solid var(--ink-soft); border-radius: 2px; }
.pdf-ico::after { content: "PDF"; position: absolute; left: -3px; bottom: 4px; font-size: 7.5px; font-weight: 700; color: #fff; background: var(--blue); padding: 0 2px; border-radius: 1px; }
.pdf-ico.signed::after { background: var(--green); }
.files .sub { font-size: .82rem; color: var(--muted); font-weight: 400; }
.bulkbar { position: sticky; bottom: 0; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--radius); display: none; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.bulkbar.show { display: flex; }
@media (max-width: 760px) {
  .files thead { display: none; }
  .files, .files tbody, .files tr, .files td { display: block; width: 100%; }
  .files tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .files td { border: 0; padding: .2rem .25rem; }
}

/* --- documento --- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.4rem; align-items: start; }
.doc-side { position: sticky; top: 1rem; }
@media (max-width: 1100px) { .doc-layout { grid-template-columns: 1fr; } .doc-side { position: static; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: .35rem .8rem; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .6rem; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -1.38rem; top: .35rem; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--blue); }
.timeline time { display: block; color: var(--muted); font-size: .8rem; }
.copybox { display: flex; gap: .4rem; }
.copybox input { font-family: var(--mono); font-size: .8rem; }

/* --- visor PDF --- */
.viewer { background: #5D6B76; border-radius: var(--radius); padding: 14px; min-height: 320px; max-height: 80vh; overflow: auto; }
.viewer canvas { display: block; margin: 0 auto 14px; max-width: 100%; height: auto !important; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.viewer .vmsg { color: #fff; text-align: center; padding: 2rem 1rem; }
.viewer-tall { max-height: none; }

/* --- tablas simples --- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table th { color: var(--muted); font-size: .8rem; border-bottom-color: var(--line); }
.overdue { color: var(--red); font-weight: 700; }

/* --- firma del representante en ajustes --- */
.settings-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.2rem; }
.settings-nav a { text-decoration: none; padding: .35rem .7rem; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .88rem; }
.settings-nav a:hover { border-color: var(--blue); color: var(--blue); }
.secret { font-family: var(--mono); font-size: 1.2rem; letter-spacing: .08em; background: var(--yellow-wash); border: 1px dashed #D4A300; padding: .6rem .9rem; border-radius: var(--radius); display: inline-block; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: column; padding: .8rem 1rem; gap: .6rem; display: none; }
  .rail.open { display: flex; }
  .mobile-bar { display: flex; justify-content: space-between; align-items: center; background: var(--ink); color: #fff; padding: .6rem 1rem; }
  .mobile-bar strong { font-size: 1rem; }
  .mobile-bar button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: var(--radius); padding: .35rem .7rem; font: inherit; }
  .main { padding: 1.1rem 1rem 3rem; }
}

/* ============================================================ páginas públicas (trabajador, fiscalizador, verificación) */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-top { background: var(--ink); color: #fff; }
.public-top .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-top: .8rem; padding-bottom: .8rem; }
.public-top strong { font-size: 1rem; }
.public-top span { color: #9FB0BD; font-size: .82rem; }
.public-top + .tape { height: 5px; background: var(--yellow); }
.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.wrap-wide { max-width: 1080px; }
.public main { flex: 1; padding: 1.6rem 0 3rem; }
.public-foot { font-size: .8rem; color: var(--muted); padding: 1.2rem 0 2rem; }
.public .card { padding: 1.3rem 1.25rem; }
.public h1 { font-size: 1.45rem; }
.public { font-size: 16.5px; }

/* pasos del proceso de firma: son una secuencia real */
.steps { display: flex; gap: 0; list-style: none; margin: 0 0 1.2rem; padding: 0; counter-reset: s; }
.steps li { flex: 1; font-size: .78rem; color: var(--muted); padding-top: .55rem; border-top: 4px solid var(--line); counter-increment: s; }
.steps li + li { margin-left: 4px; }
.steps li::before { content: counter(s) ". "; font-weight: 700; }
.steps li.done { border-top-color: var(--blue); color: var(--ink); }
.steps li.now { border-top-color: var(--yellow); color: var(--ink); font-weight: 700; }

.doc-title-block { border-left: 4px solid var(--blue); padding-left: .8rem; margin-bottom: 1rem; }
.doc-title-block .t { font-weight: 700; font-size: 1.1rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-family: var(--mono); max-width: 260px; }
.big-check { font-size: 1rem; padding: .8rem; background: var(--paper); border-radius: var(--radius); border: 1px solid var(--line); }

/* almohadilla de firma: la línea de firma es cinta de obra */
.sigpad-wrap { margin: .4rem 0 1rem; }
.sigpad { position: relative; background: #fff; border: 1px solid #BFC5BE; border-radius: var(--radius) var(--radius) 0 0; touch-action: none; height: 210px; }
.sigpad canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.sigpad .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9AA4AC; pointer-events: none; font-size: 1.05rem; }
.sigpad.has-ink .ph { display: none; }
.tape-line {
  height: 14px; border-radius: 0 0 var(--radius) var(--radius);
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 14px, var(--ink) 14px 28px);
}
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: .45rem; font-size: .85rem; color: var(--muted); }
.sig-done { text-align: center; }
.sig-done .seal { width: 76px; height: 76px; margin: .4rem auto 1rem; border-radius: 50%; border: 4px solid var(--green); display: grid; place-items: center; }
.sig-done .seal svg { width: 40px; height: 40px; }
.consent-text { white-space: pre-line; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; font-size: .98rem; }
.reject-box { margin-top: 1.4rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.reject-box summary { cursor: pointer; color: var(--red); font-weight: 700; }

.verify-result { border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1rem 0; border: 1px solid var(--line); }
.verify-result.match { background: var(--green-wash); border-color: #B7D8C3; }
.verify-result.nomatch { background: var(--red-wash); border-color: #E7B9B5; }

.login-box { max-width: 400px; margin: 8vh auto 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .rail, .mobile-bar, .btn, .toolbar, .bulkbar { display: none !important; }
  body { background: #fff; }
}
