/* META MOTORS — solicitud de adhesión. The page is a paper form on a desk. */

/* ---------- Fonts (served locally from @fontsource) ---------- */
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/barlow/barlow-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/barlow/barlow-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/barlow/barlow-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/barlow-condensed/barlow-condensed-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/barlow-condensed/barlow-condensed-latin-700-normal.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  --ink: #171b20;
  --ink-soft: #4a525b;
  --paper: #ffffff;
  --steel: #eef0f2;
  --rule: #cfd4d9;
  --rule-strong: #9aa2aa;
  --accent: #d7263d;
  --accent-dark: #b01e31;
  --focus: #1f5fbf;

  --estado-pendiente-bg: #f6ecd2;
  --estado-pendiente-fg: #6b4e00;
  --estado-aprobada-bg: #dcebdd;
  --estado-aprobada-fg: #1d5a2c;
  --estado-rechazada-bg: #f3dcdf;
  --estado-rechazada-fg: #8a2230;

  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --radius: 2px;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--steel);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: var(--ink);
  text-underline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
  z-index: 10;
}
.skip-link:focus {
  top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Document sheet ---------- */
.sheet {
  width: min(100% - 2rem, 860px);
  margin: 2rem auto 3rem;
  background: var(--paper);
  border: 1px solid var(--rule);
}
.sheet--narrow {
  width: min(100% - 2rem, 520px);
}
.sheet--wide {
  width: min(100% - 2rem, 1180px);
}
.sheet__body {
  padding: 1.5rem 2rem 2rem;
}

@media (max-width: 640px) {
  .sheet {
    margin: 1rem auto 2rem;
  }
  .sheet__body {
    padding: 1.25rem 1rem 1.5rem;
  }
}

/* ---------- Masthead: the one bold element ---------- */
.masthead {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 4px solid var(--accent);
}
.masthead__brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 8vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
}
.masthead__title {
  margin: 0.4rem 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 3.4vw, 1.6rem);
  line-height: 1.2;
}
.masthead__note {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .masthead {
    padding: 1.25rem 1rem 1rem;
  }
}

/* ---------- Typography helpers ---------- */
.section-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.2;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: 600 1rem/1.2 var(--font-body);
  text-decoration: none;
  cursor: pointer;
}
.button:hover {
  background: var(--steel);
}
.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.button--primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.field label,
.field__label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.field__optional {
  color: var(--ink-soft);
  font-weight: 400;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="date"],
.field input:not([type]),
.field select,
.field textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.4 var(--font-body);
}
.field textarea {
  resize: vertical;
  min-height: 5rem;
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--ink);
}

.field__hint {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.field__error {
  margin: 0.25rem 0 0;
  color: var(--accent-dark);
  font-size: 0.875rem;
  font-weight: 500;
}
.field__error:empty {
  display: none;
}
.field--invalid input,
.field--invalid select,
.field--invalid textarea,
.field--invalid .signature__canvas {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.form-summary {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-left-width: 4px;
  background: #fbeef0;
  font-weight: 500;
}

.form-actions {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

/* ---------- Confirmation ---------- */
.reference-label {
  margin: 1.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.reference {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.25rem;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Internal records (quiet, denser) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 4px solid var(--accent);
}
.toolbar__brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
}
.toolbar__title {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.1;
}
.toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.toolbar__count {
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.button--small {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.status {
  min-height: 1.5rem;
  margin: 0;
  padding: 0.5rem 1.5rem 0;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 500;
}
.empty {
  margin: 0;
  padding: 2rem 1.5rem;
  color: var(--ink-soft);
}

.table-wrap {
  overflow-x: auto;
  padding: 0.5rem 1.5rem 1.5rem;
}
.records {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.records th,
.records td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.records th {
  border-bottom-color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.records tbody tr:hover {
  background: #f7f8f9;
}
.records__ref {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.records__trace {
  min-width: 11rem;
}
.records__last {
  display: block;
  color: var(--ink-soft);
  font-size: 0.8rem;
}
.records__actions {
  min-width: 15rem;
}
.records__detail td {
  background: var(--steel);
  font-size: 0.85rem;
}
.records__detail ul {
  margin: 0;
  padding-left: 1.1rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge--pendiente {
  background: var(--estado-pendiente-bg);
  color: var(--estado-pendiente-fg);
}
.badge--aprobada {
  background: var(--estado-aprobada-bg);
  color: var(--estado-aprobada-fg);
}
.badge--rechazada {
  background: var(--estado-rechazada-bg);
  color: var(--estado-rechazada-fg);
}

.link-button {
  display: inline;
  margin: 0 0.6rem 0.2rem 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 0.875rem/1.4 var(--font-body);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.link-button:hover {
  color: var(--accent-dark);
}
.link-button[disabled] {
  color: var(--rule-strong);
  text-decoration: none;
  cursor: not-allowed;
}
.link-button--danger {
  color: var(--estado-rechazada-fg);
}

@media (max-width: 640px) {
  .toolbar {
    padding: 1rem;
  }
  .table-wrap {
    padding: 0.5rem 1rem 1rem;
  }
}

/* ---------- Contract replica form (/solicitud) ---------- */
/* Chrome (top bar, submit bar, dialog) uses the app tokens; the sheets are the contract itself. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  border-bottom: 4px solid var(--accent);
}
.topbar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  width: min(100% - 2rem, 900px);
  margin: 0 auto;
  padding: 0.6rem 0;
}
.topbar__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.1;
}
.topbar__help {
  margin: 0.2rem 0 0;
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.35;
}
.topbar__signature {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.topbar__status {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
}
.topbar__status--ok {
  color: var(--estado-aprobada-fg);
}
.topbar__status--error {
  color: var(--accent-dark);
}

.page-solicitud .form-summary {
  width: min(100% - 2rem, 900px);
  margin: 1rem auto 0;
}
.form-summary__headline {
  margin: 0;
}
.form-summary__list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-weight: 400;
  font-size: 0.9rem;
}
.form-summary__link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.contract-scroller {
  width: min(100% - 2rem, 900px);
  margin: 1.25rem auto 0;
  overflow-x: auto;
}
.contract-sheet {
  position: relative;
  min-width: 720px; /* below this the page scrolls sideways instead of shrinking the blanks */
  aspect-ratio: 1191 / 1684;
  background: #ffffff;
  border: 1px solid var(--rule);
  container-type: inline-size;
}
.contract-sheet__image {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
}
.contract-sheet__fields {
  position: absolute;
  inset: 0;
}
.contract-page-number {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-align: right;
}

/* Positioned fields: left/top/width/height are inline percentages from fieldmap.json. */
.cf {
  position: absolute;
  margin: 0;
  padding: 0 0.3%;
  border: 0;
  border-bottom: 1px solid rgba(31, 95, 191, 0.35);
  border-radius: 0;
  background: rgba(214, 232, 255, 0.35);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-size: 1.45cqw;
  line-height: 1.1;
}
.cf--required {
  background: rgba(255, 232, 178, 0.55);
}
.cf--segment {
  padding: 0;
  text-align: center;
}
.cf--multiline,
.cf--area {
  padding-top: 0.2%;
  resize: none;
  line-height: 1.2;
  overflow: auto;
}
.cf:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  background: rgba(214, 232, 255, 0.6);
}
.cf::placeholder {
  color: rgba(23, 27, 32, 0.35);
}
.cf--invalid {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  background: rgba(215, 38, 61, 0.12);
}

.cf-error {
  position: absolute;
  z-index: 2;
  max-width: 60%;
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 11px;
  font-size: max(11px, 1.3cqw);
  font-weight: 600;
  line-height: 1.2;
}
.cf-error:empty {
  display: none;
}

.cf--signature-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px dashed rgba(31, 95, 191, 0.7);
  cursor: pointer;
}
.cf--signature-slot.cf--signed {
  border-style: solid;
  border-color: transparent;
  background: transparent;
}
.cf__slot-hint {
  color: var(--focus);
  font-weight: 600;
}
.cf__slot-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.submit-bar {
  width: min(100% - 2rem, 900px);
  margin: 1.5rem auto 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule-strong);
}

/* ---------- Signature dialog ---------- */
.signature-dialog {
  width: min(100% - 2rem, 640px);
  padding: 1.25rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
.signature-dialog::backdrop {
  background: rgba(23, 27, 32, 0.55);
}
.signature-dialog__title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
}
.signature-dialog__canvas {
  display: block;
  width: 100%;
  height: 200px;
  margin-top: 0.75rem;
  border: 1px dashed var(--rule-strong);
  background: var(--paper);
  cursor: crosshair;
  touch-action: none;
}
.signature-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.signature-dialog__spacer {
  flex: 1 1 0;
}

@media print {
  .topbar,
  .submit-bar,
  .signature-dialog,
  .contract-page-number {
    display: none;
  }
  body {
    background: #ffffff;
  }
  .contract-scroller {
    margin: 0;
    overflow: visible;
    break-after: page;
  }
  .contract-sheet {
    border: 0;
  }
}
