/* Planillas · Historial de periodos y firma del empleador. */

/* Historial: una línea de resumen, los periodos agrupados por año y una fila compacta por periodo */
.payroll-history-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.payroll-history-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; font-size: 13px; color: var(--ink-3); }
.payroll-history-summary strong { font-size: 15px; font-weight: 800; color: var(--ink); }
.payroll-history-summary > span { margin-inline: 4px; color: var(--ink-4); }
.payroll-history-year { display: grid; gap: 8px; }
.payroll-history-year h4 { display: flex; align-items: baseline; gap: 6px; padding-inline: 4px; font-size: 15px; font-weight: 800; }
.payroll-history-year h4 span { font-size: 12.5px; font-weight: 650; letter-spacing: 0; color: var(--ink-3); }
.payroll-history { margin: 0; padding: 4px 6px; list-style: none; container-type: inline-size; }

/* Fila: periodo, avance con su leyenda, enviadas, pago y acciones. Toda la fila abre el periodo. Cada fila es su
   propia grilla: enviadas, pago y acciones tienen un ancho mínimo común para que las columnas no bailen entre
   filas, y solo crecen si la cifra no cabe, con cinco dígitos o más. */
.payroll-history-row {
  --history-sent: minmax(96px, max-content);
  --history-pay: minmax(104px, max-content);
  --history-actions: 192px;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(200px, 1.3fr) minmax(200px, 2fr) var(--history-sent) var(--history-pay) var(--history-actions);
  grid-template-areas: "period meter sent pay actions" "period legend sent pay actions";
  align-items: center;
  gap: 8px 18px;
  padding: 12px;
}
.payroll-history-row + .payroll-history-row { border-top: 1px solid var(--line-soft); }
.payroll-history-row::before {
  content: "";
  position: absolute;
  inset: 3px -2px;
  z-index: -1;
  border-radius: var(--r-md);
  background: var(--surface-2);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.payroll-history-row:hover::before { opacity: 1; }
.payroll-history-row.is-current::before { opacity: 1; background: var(--blue-50); box-shadow: inset 0 0 0 2px var(--blue-200); }
/* La salida reemplaza la animación de entrada de .reveal, que si no mantendría la fila visible hasta el final. */
.payroll-history-row.is-leaving { animation: slide-out .25s var(--ease) forwards; pointer-events: none; }

.payroll-history-period { grid-area: period; display: flex; align-items: center; gap: 12px; min-width: 0; }
.payroll-history-period .icon-tile { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--tone-soft); color: var(--tone-ink); transition: transform .25s var(--spring); }
.payroll-history-period .icon-tile .i { width: 18px; height: 18px; }
.payroll-history-row:hover .payroll-history-period .icon-tile { transform: scale(1.08) rotate(-4deg); }
.payroll-history-period > div { display: grid; min-width: 0; }
.payroll-history-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.payroll-history-period h5 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; }
.payroll-history-period small { overflow: hidden; font-size: 12.5px; color: var(--ink-3); text-overflow: ellipsis; white-space: nowrap; }
.payroll-history-now { height: 20px; padding: 0 8px; font-size: 11px; font-weight: 750; }

.payroll-history-row .meter { grid-area: meter; align-self: end; height: 8px; }
.payroll-history .meter-seg.is-sent { background: var(--state-taken); }
.payroll-history .meter-seg.is-approved { background: var(--state-earned); }
.payroll-history .meter-seg.is-failed { background: var(--coral-500); }
.payroll-history .meter-seg.is-pending { background: var(--state-hold); }
.payroll-history .meter-seg.is-unmatched { background: var(--red-500); }
.payroll-history-legend { grid-area: legend; align-self: start; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
/* Los chips y la papelera quedan por encima del área que abre el periodo. */
.payroll-history-legend .chip { position: relative; z-index: 1; height: 26px; padding: 0 10px; gap: 4px; font-size: 12px; transition: transform .2s var(--spring); }
.payroll-history-legend .chip:hover { box-shadow: inset 0 0 0 1px var(--tone); transform: translateY(-1px); }
.payroll-history-legend .chip:active { transform: scale(.96); }
.payroll-history-legend .chip.is-urgent { box-shadow: inset 0 0 0 1px var(--tone); font-weight: 750; }

.payroll-history-sent, .payroll-history-pay { grid-area: sent; margin: 0; display: grid; gap: 1px; min-width: 0; }
.payroll-history-pay { grid-area: pay; }
.payroll-history-sent small, .payroll-history-pay small { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.payroll-history-sent strong { font-size: 17px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.payroll-history-sent strong span { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.payroll-history-pay strong { font-size: 13px; font-weight: 700; white-space: nowrap; }

.payroll-history-actions { grid-area: actions; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
/* El botón se estira a toda la fila con ::after. Un transform o un filter lo volverían el bloque contenedor y
   el área se encogería al pasar el cursor o al pulsar, así que aquí el gesto lo hacen la flecha y el borde. */
.payroll-history-open, .payroll-history-open:hover:not(:disabled), .payroll-history-open:active:not(:disabled) { position: static; transform: none; filter: none; }
/* «Abrir periodo» y «Seguir revisando» ocupan lo mismo: el botón llena lo que deja la papelera. */
.payroll-history-open { flex: 1; justify-content: center; }
.payroll-history-open::after { content: ""; position: absolute; inset: 0; }
.payroll-history-row:hover .payroll-history-open { box-shadow: inset 0 0 0 1px var(--tone); }
.payroll-history-open .i { transition: transform .2s var(--ease); }
.payroll-history-row:hover .payroll-history-open .i { transform: translateX(3px); }
.payroll-delete { position: relative; z-index: 1; color: var(--ink-3); transition: transform .2s var(--spring); }
.payroll-delete:not(.is-locked):hover { color: var(--red-700); background: var(--red-50); transform: scale(1.06); }
.payroll-delete:not(.is-locked):active { transform: scale(.94); }
.payroll-delete:not(.is-locked):focus-visible { outline: 3px solid var(--red-500); outline-offset: 2px; color: var(--red-700); background: var(--red-50); }
.payroll-delete.is-locked { color: var(--ink-4); cursor: help; }
.payroll-delete.is-locked:hover { background: var(--canvas); color: var(--ink-3); }

@container (max-width: 860px) {
  .payroll-history-row {
    grid-template-columns: minmax(170px, 1fr) minmax(170px, 1.3fr) var(--history-sent) var(--history-actions);
    grid-template-areas: "period meter sent actions" "pay legend sent actions";
    gap: 6px 14px;
  }
  .payroll-history-pay { display: flex; align-items: baseline; gap: 6px; padding-left: 48px; }
  .payroll-history-pay strong { font-size: 12.5px; color: var(--ink-2); }
}
/* Teléfono: periodo y enviadas arriba, la barra en todo el ancho y los chips junto a las acciones. */
@container (max-width: 600px) {
  .payroll-history { padding-inline: 4px; }
  .payroll-history-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "period sent" "pay sent" "meter meter" "legend actions";
    gap: 4px 12px;
    padding: 12px 10px;
  }
  .payroll-history-row .meter { margin-top: 6px; }
  .payroll-history-legend { align-self: center; }
  .payroll-history-sent { text-align: right; }
  .payroll-history-open { flex: none; width: 36px; padding: 0; }
  .payroll-history-open > span { display: none; }
}

/* Firma: estado y acciones a la izquierda; a la derecha, la línea de firma de la boleta como vista previa */
.payroll-signature-wrap { container-type: inline-size; }
.payroll-signature { display: grid; gap: 20px 28px; max-width: 1040px; padding: 22px; border-top: 4px solid var(--tone); }
.payroll-signature-main { display: grid; gap: 16px; align-content: start; min-width: 0; }
.payroll-signature-head { display: flex; align-items: flex-start; gap: 14px; }
.payroll-signature-head > div { flex: 1; min-width: 0; }
.payroll-signature-head h3 { font-size: 17px; font-weight: 800; }
.payroll-signature-head p { margin-top: 3px; font-size: 13px; color: var(--ink-3); }
.payroll-signature .icon-tile { flex: none; background: var(--tone-soft); color: var(--tone-ink); }
.payroll-signature-status { display: grid; justify-items: start; gap: 12px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--r-md); background: var(--surface-2); }
.payroll-signature-status.is-fresh { animation: pop .4s var(--spring) both; }
.payroll-signature-facts { margin: 0; display: flex; flex-wrap: wrap; gap: 10px 28px; }
.payroll-signature-facts dt { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.payroll-signature-facts dd { margin: 0; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payroll-signature-missing { align-items: center; flex-wrap: wrap; }
.payroll-signature-missing > div { flex: 1 1 220px; }
.payroll-signature-missing .btn { flex: none; }
.payroll-signature-link { justify-self: start; }
.payroll-signature-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.payroll-signature-steps li { display: flex; align-items: flex-start; gap: 12px; }
.payroll-signature-steps li > span { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--tone-soft); color: var(--tone-ink); font-size: 12.5px; font-weight: 800; }
.payroll-signature-steps div { display: grid; min-width: 0; }
.payroll-signature-steps strong { font-size: 13.5px; font-weight: 750; }
.payroll-signature-steps small { font-size: 12.5px; color: var(--ink-3); }
/* Solo el paso en curso se resalta; los anteriores quedan hechos, en verde y con un check. */
.payroll-signature-steps li > span { transition: transform .25s var(--spring); }
.payroll-signature-steps li > span .i { width: 14px; height: 14px; }
.payroll-signature-steps li.is-done > span { background: var(--green-100); color: var(--green-700); }
.payroll-signature-steps li[aria-current="step"] > span { transform: scale(1.12); box-shadow: inset 0 0 0 2px var(--tone); }
.payroll-signature-hint { font-size: 12.5px; color: var(--ink-3); }

.payroll-signature-side { display: grid; align-content: start; gap: 10px; min-width: 0; padding: 16px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line-soft); }
.payroll-signature-drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 16px;
  border: 2px dashed var(--blue-200);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: center;
  transition: transform .25s var(--ease);
}
.payroll-signature-drop:hover { border-color: var(--blue-500); transform: translateY(-2px); }
/* Una imagen arrastrada sobre la tarjeta: se marca dónde va a caer, esté vacía la línea o con vista previa. */
.payroll-signature-side.is-drag .payroll-signature-drop { border-color: var(--blue-600); background: var(--blue-50); transform: scale(1.01); }
.payroll-signature-side.is-drag .payroll-signature-proof .payroll-signature-paper { box-shadow: var(--shadow-xs), inset 0 0 0 2px var(--blue-500); }
.payroll-signature-drop .payroll-signature-paper { box-shadow: none; }
.payroll-signature-drop .payroll-signature-slot .i { width: 26px; height: 26px; transition: transform .25s var(--spring); }
.payroll-signature-drop:hover .payroll-signature-slot .i { transform: translateY(-3px); }
.payroll-signature-drop strong { margin-top: 4px; font-size: 13.5px; font-weight: 750; color: var(--ink); }
.payroll-signature-drop small { font-size: 12px; color: var(--ink-3); }

/* Maqueta del pie de la boleta: la imagen sobre la línea, con cuadros para ver lo transparente */
.payroll-signature-paper { display: grid; justify-items: center; gap: 4px; width: 100%; padding: 14px 18px 12px; border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--line-soft); }
.payroll-signature-slot { display: grid; place-items: center; width: min(220px, 100%); height: 96px; color: var(--ink-4); }
.payroll-signature-slot.is-image { border-radius: var(--r-sm); background: repeating-conic-gradient(var(--line-soft) 0 25%, var(--surface) 0 50%) 0 0 / 14px 14px; }
.payroll-signature-slot img { max-width: 100%; max-height: 100%; object-fit: contain; }
.payroll-signature-line { width: min(220px, 100%); padding-top: 6px; border-top: 1.5px solid var(--ink); font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-align: center; color: var(--ink-2); }

.payroll-signature-proof { display: grid; gap: 12px; animation: pop .32s var(--spring) both; }
.payroll-signature-proof figure { margin: 0; display: grid; gap: 8px; }
.payroll-signature-proof figcaption { display: grid; min-width: 0; }
.payroll-signature-proof figcaption strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.payroll-signature-proof figcaption small { font-size: 12px; color: var(--ink-3); }
.payroll-signature-tip { font-size: 12px; color: var(--ink-3); }
.payroll-signature-scope { display: grid; gap: 6px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
.payroll-signature-scope .payroll-warn { align-items: flex-start; font-size: 12.5px; }
.payroll-signature-scope .payroll-warn .i { width: 16px; height: 16px; margin-top: 1px; }
.payroll-signature-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.payroll-signature .form-error:not(:empty) .i { width: 16px; height: 16px; }

.payroll-signature-sk { display: block; height: 14px; }
.payroll-signature-sk.is-tile { width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); }
.payroll-signature-sk.is-title { width: 55%; height: 18px; margin-bottom: 8px; }
.payroll-signature-sk.is-block { height: 92px; border-radius: var(--r-md); }
.payroll-signature-sk.is-paper { height: 240px; border-radius: var(--r-md); }

@container (min-width: 860px) {
  .payroll-signature.has-side { grid-template-columns: minmax(0, 1fr) 340px; }
}
@container (max-width: 560px) {
  .payroll-signature { padding: 18px 16px; }
  .payroll-signature-head { flex-wrap: wrap; }
  .payroll-signature-head > .btn, .payroll-signature-missing .btn { width: 100%; }
  .payroll-signature-side { padding: 12px; }
  .payroll-signature-steps { display: none; }
  /* En el teléfono la zona vacía repetiría el botón de carga: la vista previa aparece al elegir la imagen. */
  .payroll-signature-side:has(.payroll-signature-drop) { display: none; }
  .payroll-signature-actions .btn { flex: 1 1 0; }
}
