/* ==========================================================================
   Control de Calidad - No Conforme — hoja Carta HORIZONTAL, 6 etiquetas
   (3 columnas x 2 filas) de ~3.45in x 2.9in (~8.76cm x 7.37cm) cada una —
   compactas, anchas y bajitas, como el papelito físico real. Reutiliza header/botones/
   tarjetas/modal de styles.css; aquí sólo vive el layout de 3 columnas, el
   formulario, la cola y el diseño de la etiqueta + su @page horizontal
   (independiente de los @page de index.html y reporte-paletizado.html).
   ========================================================================== */

/* ---------------------------------------------------------------------- */
/* Alerta general (errores de red, avisos)                                 */
/* ---------------------------------------------------------------------- */

.nc-alert {
  max-width: 1720px;
  margin: 14px auto 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #fdecec;
  border: 1px solid #f2b8b8;
  color: #a01313;
}

/* ---------------------------------------------------------------------- */
/* Layout de 3 columnas — aprovecha todo el ancho de pantalla. La columna   */
/* de vista previa (3ra) es la más ancha: es la que más protagonismo debe  */
/* tener, para que la hoja de impresión se vea grande y clara.             */
/* ---------------------------------------------------------------------- */

.nc-main { max-width: 1720px; padding: 20px 20px 40px; }

.nc-columns {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(300px, 0.85fr) minmax(420px, 1.55fr);
  gap: 20px;
  align-items: start;
}

.nc-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  padding: 20px 22px 22px;
}

.nc-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--brand-blue);
}

/* Título simple sin ícono ni badge — sólo el texto, para igualar la
   referencia (los 3 encabezados de columna son texto plano). */
.nc-card-title-plain { color: var(--brand-blue-dark); }

.nc-required { color: #c81e2b; font-weight: 700; }

.nc-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--brand-blue-dark);
  background: var(--brand-blue-tint);
  border: 1px solid #cfe3f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.nc-info-banner svg { flex-shrink: 0; margin-top: 1px; }

/* Botón blanco de encabezado (p.ej. "Historial de Reportes") — mismo
   tamaño/forma que .btn-header (azul) pero en blanco, para el botón
   secundario del header de este módulo. */
.btn-header-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  color: var(--black);
  border: 1.5px solid var(--black);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  min-height: 44px;
  font-family: var(--font);
}
.btn-header-ghost:hover { background: var(--gray-100); }

/* Botón azul corporativo (acción principal de este módulo: agregar a la
   cola, imprimir hoja, confirmar impresión). */
.nc-btn-blue {
  background: var(--brand-blue);
  color: var(--white);
  border-color: var(--brand-blue);
}
.nc-btn-blue:hover:not(:disabled) { background: var(--brand-blue-dark); border-color: var(--brand-blue-dark); }
.nc-btn-blue:disabled { opacity: 0.55; cursor: not-allowed; }

/* Botón rojo (confirmar una eliminación dentro del modal propio). */
.nc-btn-danger {
  background: #a01313;
  color: var(--white);
  border-color: #a01313;
}
.nc-btn-danger:hover:not(:disabled) { background: #7a0e0e; border-color: #7a0e0e; }
.nc-btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------------------------------------------------------------------- */
/* Formulario "Nuevo reporte"                                               */
/* ---------------------------------------------------------------------- */

.nc-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.nc-field-row { display: flex; gap: 12px; }
.nc-field-row .nc-field { flex: 1; min-width: 0; }

.nc-field label {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--gray-900);
}

.nc-field input[type="text"],
.nc-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.92rem;
  border: 1.5px solid var(--gray-500);
  border-radius: 6px;
  background: var(--white);
  color: var(--black);
  font-family: var(--font);
}
.nc-field input[disabled] { background: var(--gray-100); color: var(--gray-700); font-weight: 700; }
/* El ID Reporte es de sólo lectura (folio automático) pero se ve como un
   campo normal, no "apagado", para igualar la referencia. */
.nc-field-plain-disabled[disabled] { background: var(--white); color: var(--black); font-weight: 700; }
.nc-field input:focus-visible,
.nc-field select:focus-visible {
  outline: 3px solid var(--brand-blue-tint);
  border-color: var(--brand-blue);
}

.nc-field-hint { font-size: 0.72rem; color: var(--gray-700); min-height: 1.1em; }

.nc-label-hint {
  text-transform: none;
  font-weight: 500;
  letter-spacing: normal;
  color: var(--gray-500);
}

/* Ícono decorativo dentro del campo (calendario, escáner, lupa…) — sólo
   visual, no interactivo; el campo sigue siendo un <input> de texto normal
   igual que en los otros módulos del sistema. */
.nc-field-icon-wrap { position: relative; }
.nc-field-icon-wrap input { padding-right: 36px; }
.nc-field-icon {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  pointer-events: none;
}

.nc-defect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 10px;
  margin-bottom: 8px;
}

.nc-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-900);
  cursor: pointer;
}
.nc-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand-blue);
  cursor: pointer;
  flex-shrink: 0;
}

/* "Otro" ocupa toda la fila (span 3) con su campo de texto inline, en vez
   de un input aparte debajo — igual que la referencia. */
.nc-check-otro {
  grid-column: 1 / -1;
}
.nc-check-otro .nc-defect-other {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 6px 10px;
  font-size: 0.85rem;
  height: 32px;
}

.nc-defect-other {
  border-radius: 6px;
}
.nc-defect-other[disabled] { background: var(--gray-100); color: var(--gray-500); }

.nc-form-actions { margin-top: 4px; }
.nc-form-actions .btn,
.nc-btn-print {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------------- */
/* Cola de impresión                                                    */
/* ---------------------------------------------------------------------- */

.nc-tray-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.nc-tray-row {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  background: var(--white);
}

.nc-tray-row-top { display: flex; align-items: center; gap: 8px; }
.nc-tray-row-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  background: var(--brand-blue);
  color: var(--white);
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 5px;
}
.nc-tray-row-id { font-weight: 700; color: var(--gray-900); }
.nc-tray-row-date { color: var(--gray-500); font-size: 0.78rem; margin-left: auto; }

.nc-tray-row-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  color: #a01313;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
}
.nc-tray-row-remove:hover { background: #fdecec; }

.nc-tray-row-line {
  display: flex;
  gap: 16px;
  color: var(--gray-700);
  margin-top: 6px;
  overflow: hidden;
}
.nc-tray-row-line span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-tray-row-line b { color: var(--gray-900); font-weight: 700; }

.nc-tray-row-status {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #1a6b1a;
  background: #eaf7ea;
  border-radius: 10px;
  padding: 2px 10px;
}

.nc-tray-empty { color: var(--gray-700); font-size: 0.85rem; padding: 14px 0; text-align: center; }

.nc-tray-stats { margin-bottom: 14px; }
.nc-tray-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-200);
}
.nc-tray-stat-row:last-child { border-bottom: none; }
.nc-stat-pill {
  font-weight: 700;
  color: var(--brand-blue-dark);
  background: var(--brand-blue-tint);
  border-radius: 12px;
  padding: 3px 12px;
  min-width: 28px;
  text-align: center;
}

.nc-btn-print {
  width: 100%;
  font-size: 1rem;
  padding: 13px 16px;
  background: var(--brand-blue);
  color: var(--white);
  border-color: var(--brand-blue);
}
.nc-btn-print:hover:not(:disabled) { background: var(--brand-blue-dark); border-color: var(--brand-blue-dark); }

/* ---------------------------------------------------------------------- */
/* Vista previa — hoja Carta HORIZONTAL con 6 etiquetas (3 x 2)             */
/* ---------------------------------------------------------------------- */

.nc-preview-card { padding: 20px 20px 22px; display: flex; flex-direction: column; }

.nc-sheet-wrap {
  container-type: size;
  width: 100%;
  max-width: 980px;
  aspect-ratio: 11 / 8.5;
  margin: 4px auto 0;
}

/* Hoja Carta HORIZONTAL (11in x 8.5in), 6 etiquetas en 3 columnas x 2 filas.
   Cada etiqueta física mide ~3.45in x 2.9in (~8.76cm x 7.37cm) — compacta,
   ancha y bajita (como el papelito físico real), no alta ni estirada. Ver
   el bloque @media print para las medidas exactas en pulgadas; estos
   porcentajes (cqw/cqh, relativos al ancho/alto de ESTA hoja) reproducen
   la misma proporción — y por lo tanto el mismo tamaño relativo — en
   pantalla que en la hoja impresa (WYSIWYG real, no aproximado). */
.nc-sheet {
  width: 100%;
  height: 100%;
  background: var(--white);
  border: 1px solid var(--gray-300);
  padding: 15cqh 1.59cqw;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  column-gap: 1.364cqw;
  row-gap: 1.765cqh;
}

.nc-label {
  border: 1.5px dashed var(--gray-500);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.1cqh 1.4cqw;
  overflow: hidden;
  font-family: var(--font);
  color: var(--black);
}
/* flex-shrink:0 en TODOS los hijos: por defecto flexbox comprimiría el
   contenido que no entra en vez de mostrar overflow real (invisible, sin
   que scrollHeight lo delate). Con flex-shrink:0 cualquier déficit de
   espacio se ve como overflow real y detectable. */
.nc-label > * { flex-shrink: 0; }

/* Sólo el logo (ya trae "MI Technologies" integrado en azul) — centrado
   arriba de la etiqueta, sin texto negro adicional al lado. */
.nc-label-head {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nc-label-logo { height: 3.4cqh; width: auto; flex-shrink: 0; }

.nc-label-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.nc-label-title-left,
.nc-label-title-right {
  font-size: 1.4cqh;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nc-label-title-left { min-width: 0; }
.nc-label-title-right { min-width: 0; flex-shrink: 0; }

.nc-label-field-row {
  display: flex;
  gap: 8px;
  font-size: 1.42cqh;
}
.nc-label-field-row-full .nc-label-field { flex: 1 1 100%; }

.nc-label-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  color: var(--gray-700);
  font-weight: 600;
}

/* "Línea para llenar": subrayado que representa el espacio del dato — si
   viene vacío se ve como una línea en blanco (igual que el papelito
   físico); si trae valor, el texto se apoya sobre la línea. */
.nc-label-blank {
  flex: 1 1 auto;
  min-width: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1.1px solid var(--gray-700);
  padding: 0 2px 0.1em;
  font-weight: 700;
  color: var(--black);
}

.nc-label-defects-title {
  font-size: 1.42cqh;
  font-weight: 700;
  color: var(--gray-700);
  margin-top: 0.35cqh;
}

/* 6 defectos principales en cuadrícula de 3 columnas; "Otro" va en su
   propia fila completa con el campo de texto inline — igual que el
   formulario de captura. Los 7 SIEMPRE se listan (marcados o no), para
   que las 6 etiquetas de la hoja sean idénticas en estructura. */
.nc-label-defect-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 6px;
  row-gap: 0.3cqh;
  margin-top: 0.2cqh;
}

.nc-label-defect-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.98cqh;
  line-height: 1.15;
  color: var(--gray-900);
  min-width: 0;
}
.nc-label-defect-item span:not(.nc-label-defect-box) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nc-label-defect-item.checked { font-weight: 800; color: var(--black); }

.nc-label-defect-box {
  flex-shrink: 0;
  width: 1.05cqh;
  height: 1.05cqh;
  border: 1.1px solid var(--gray-700);
  border-radius: 2px;
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95cqh;
  font-weight: 900;
  line-height: 1;
  color: var(--black);
}
.nc-label-defect-item.checked .nc-label-defect-box { background: var(--gray-100); }

.nc-label-defect-otro { margin-top: 0.3cqh; }

/* ---------------------------------------------------------------------- */
/* Modal: confirmación de impresión                                        */
/* ---------------------------------------------------------------------- */

.nc-confirm-modal { width: min(420px, 92vw); }
.nc-confirm-modal .modal-body p { font-size: 0.9rem; color: var(--gray-900); margin: 0 0 16px; }
.nc-confirm-modal .actions { justify-content: flex-end; }

/* ---------------------------------------------------------------------- */
/* Modal: historial (filtros extra + tabla)                                */
/* ---------------------------------------------------------------------- */

.nc-history-modal { width: min(1180px, 96vw); }

.nc-history-toolbar select,
.nc-history-toolbar input[type="text"] {
  padding: 9px 10px;
  border: 1.5px solid var(--gray-500);
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: var(--font);
}
.nc-history-toolbar input#nc-search-input { flex: 1.4; min-width: 180px; }
.nc-history-toolbar input#nc-filter-date { flex: 0 0 130px; }

.nc-defects-cell { max-width: 220px; white-space: normal !important; }
.nc-status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.nc-status-pill.pendiente { background: var(--brand-blue-tint); color: var(--brand-blue-dark); }
.nc-status-pill.impreso { background: var(--gray-200); color: var(--gray-900); }

/* ---------------------------------------------------------------------- */
/* Modal: detalle                                                          */
/* ---------------------------------------------------------------------- */

.nc-detail-modal { width: min(560px, 94vw); }
.nc-detail-list { margin: 0; }
.nc-detail-list dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-700);
  font-weight: 700;
  margin-top: 10px;
}
.nc-detail-list dt:first-child { margin-top: 0; }
.nc-detail-list dd { margin: 2px 0 0; font-size: 0.92rem; color: var(--black); }

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .nc-columns { grid-template-columns: 1fr 1fr; }
  #nc-col-preview { grid-column: 1 / -1; }
  .nc-sheet-wrap { max-width: 640px; }
}

@media (max-width: 780px) {
  .nc-columns { grid-template-columns: 1fr; }
  #nc-col-preview { grid-column: auto; }
  .nc-field-row { flex-direction: column; gap: 14px; }
  .nc-history-toolbar { flex-direction: column; align-items: stretch; }
  .nc-history-toolbar input, .nc-history-toolbar select { width: 100%; }
}

/* ==========================================================================
   IMPRESIÓN — hoja Carta HORIZONTAL (11in x 8.5in), 6 etiquetas de
   EXACTAMENTE 3.4in x 3.925in (~8.64cm x 9.97cm), 3 columnas x 2 filas.
   Las etiquetas ocupan casi toda la hoja (márgenes de sólo 0.25in a los
   lados y arriba/abajo, separación de 0.15in entre etiquetas) para que el
   contenido salga grande y legible en vez de diminuto en una esquina.
   ========================================================================== */

@page { size: letter landscape; margin: 0; }

@media print {
  html, body {
    width: 11in;
    height: 8.5in;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
  }

  .no-print { display: none !important; }

  body * { visibility: hidden; }

  #nc-sheet-wrap,
  #nc-sheet-wrap *,
  #nc-print-area,
  #nc-print-area * {
    visibility: visible !important;
  }

  #nc-sheet-wrap {
    container-type: normal;
    position: fixed;
    inset: 0;
    width: 11in;
    height: 8.5in;
    aspect-ratio: auto;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  #nc-print-area {
    position: fixed;
    inset: 0;
    width: 11in;
    height: 8.5in;
    margin: 0;
    padding: 1.275in 0.175in;
    border: none;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(3, 3.45in);
    grid-template-rows: repeat(2, 2.9in);
    column-gap: 0.15in;
    row-gap: 0.15in;
    overflow: hidden;
    page-break-before: avoid;
    page-break-after: avoid;
    page-break-inside: avoid;
    break-before: avoid-page;
    break-after: avoid-page;
    break-inside: avoid-page;
  }

  .nc-label {
    border: 1px dashed #8a8a8a;
    border-radius: 0;
    padding: 0.094in 0.154in;
    page-break-inside: avoid;
    break-inside: avoid-page;
  }

  .nc-label-logo { height: 0.289in; }
  .nc-label-title-left,
  .nc-label-title-right { font-size: 8.6pt; }
  .nc-label-field-row { font-size: 8.7pt; }
  .nc-label-defects-title { font-size: 8.7pt; }
  .nc-label-defect-item { font-size: 6pt; }
  .nc-label-defect-box { width: 6.4pt; height: 6.4pt; font-size: 5.8pt; }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
