/* =============================================================================
   Remisión de Documentos — CSS propio y acotado, prefijo .rdc-
   =============================================================================
   Base: crudStyles.css + menu.css (variables --primary-color/--success-color/
   --danger-color/--border-color, clases .facturas-*, .filter-sidebar,
   .sidebar-header/.sidebar-body, .nav-tabs/.nav-link, .registro-wrapper,
   .form-grid.dos-columnas) — mismo patrón que primaXAplicar.css y
   reaplicacionCobros.css. No se redefine ningún nombre de clase genérico
   (evita el problema ya documentado en reaplicacionCobros.css sobre
   selectores de etiqueta desnuda de crudStyles.css que alcanzan toda la
   app) — todo lo nuevo va prefijado con .rdc-.
   ============================================================================= */

.rdc-nav-disabled {
  opacity: .46;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* Sustituye al <select> de Cliente del panel de filtros — abre el modal
   #modalSelCliente (compartido con Pólizas). Se estira a todo el ancho para
   verse igual que los demás controles del panel (.form-control ya son
   width:100% por la regla global del panel de filtros). */
.rdc-btn-buscar-cliente {
  width: 100%;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
.rdc-btn-buscar-cliente span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Layout de pestañas: cada una debe caber y scrollear POR SÍ SOLA dentro
   del alto disponible (#main-content ya es height:100vh + overflow:hidden
   vía .facturas-body, ver crudStyles.css), sin depender del zoom del
   navegador. Mismo patrón ya probado en producción por Cotizaciones y
   Emisiones (crudStyles.css, bloques ".cotizaciones-page #tab-lista..." /
   "#tab-registro...") — no se inventa un mecanismo nuevo.
   - Lista y Bitácora: la pestaña es flex-column: el toolbar y la barra
     flotante de abajo NUNCA se encogen (flex:0 0 auto); solo la grilla del
     medio (facturas-table-wrap) scrollea internamente.
   - Configurar Remisión: es un formulario largo de una sola columna, no una
     grilla — la pestaña ENTERA scrollea verticalmente en su lugar.
   --------------------------------------------------------------------- */
.rdc-page #tab-rdc-lista.tab-content.active,
.rdc-page #tab-rdc-bitacora.tab-content.active {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.rdc-page #tab-rdc-lista .facturas-toolbar,
.rdc-page #tab-rdc-bitacora .facturas-toolbar {
  flex: 0 0 auto;
}

.rdc-page .rdc-workspace,
.rdc-page #rdcBitWorkspace {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.rdc-page .facturas-results-card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rdc-page .facturas-table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

.rdc-page .facturas-filter-host,
.rdc-page .kre-filter-panel.filter-sidebar {
  max-height: 100%;
  overflow: hidden;
}
.rdc-page .kre-filter-panel .sidebar-body {
  overflow-y: auto;
  min-height: 0;
}

/* La barra con "Configurar Remisión Consolidada" es un hermano del
   workspace (no vive dentro de él), así que ocultar/mostrar el panel de
   filtros (que solo afecta a .rdc-workspace) nunca la toca — se mantiene
   siempre a la vista, con tamaño fijo (flex:0 0 auto), nunca recortada. */
.rdc-floating-bar {
  display: flex;
  justify-content: flex-end;
  padding: 10px 4px 0;
  flex: 0 0 auto;
}

.rdc-page #tab-rdc-registro.tab-content.active {
  display: block !important;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  height: calc(100vh - 150px);
  height: calc(100dvh - 150px);
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  overflow-x: visible;
  margin: 0;
}
/* La regla global de .registro-wrapper (crudStyles.css) ya trae su propio
   overflow-y:auto — se anula aquí para que el ÚNICO scroll de esta pestaña
   sea el de arriba (#tab-rdc-registro), evitando una barra de scroll
   duplicada/anidada. */
.rdc-page #tab-rdc-registro .registro-wrapper {
  overflow: visible;
  box-sizing: border-box;
  width: 100%;
}

/* ---------------------------------------------------------------------
   Pestaña 1 — Documentos Pendientes
   --------------------------------------------------------------------- */
.rdc-grid-table {
  min-width: 1100px;
  table-layout: fixed;
}
.rdc-grid-table th, .rdc-grid-table td { white-space: normal; overflow: visible; text-overflow: clip; max-width: none; }
.rdc-grid-table tbody td { vertical-align: middle; }
.rdc-grid-table tbody tr.rdc-fila-seleccionada { background: #eef6ff; }
/* Columnas cortas (tipo, no. documento, las 4 fechas) centradas para que se
   vean parejas; No. Póliza y Ramo se dejan a la izquierda (texto/código de
   longitud variable, se lee mejor arrancando siempre en el mismo borde), y
   Monto ya viene alineado a la derecha (convención financiera del resto de
   la app) desde el propio HTML. */
.rdc-grid-table th:nth-child(n+4):not(:last-child),
.rdc-grid-table td:nth-child(n+4):not(:last-child) {
  text-align: center;
}
.rdc-grid-table th:nth-child(2), .rdc-grid-table td:nth-child(2),
.rdc-grid-table th:nth-child(3), .rdc-grid-table td:nth-child(3) {
  text-align: left;
}

/* Todos los checkboxes de esta tabla (el de "seleccionar todos" en el
   encabezado y cada fila) con el MISMO tamaño explícito — sin esto, el
   tamaño nativo del checkbox depende del font-size heredado de cada celda,
   que puede variar ligeramente entre el <th> y los <td>, dando cuadritos
   de tamaños distintos. */
.rdc-grid-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--primary-color);
}

/* ---------------------------------------------------------------------
   Pestaña 2 — Configurar Remisión
   --------------------------------------------------------------------- */
.rdc-section-title {
  margin: 0 0 1.2rem;
  padding-bottom: .6rem;
  border-bottom: 2px solid #eef2f7;
  color: #2c3e50;
  font-size: 1.3rem;
}

.rdc-required { color: var(--danger-color, #e74c3c); font-weight: 800; }

.rdc-field-full { grid-column: 1 / -1; }

.rdc-plantilla-box {
  background-color: #f0f7ff;
  padding: 15px;
  border-radius: 8px;
  border: 1px dashed var(--primary-color);
  margin-bottom: 20px;
}
.rdc-select-plantilla { border-color: var(--primary-color); font-weight: 700; }
.rdc-badge-sugerencia {
  font-size: .8rem;
  color: var(--success-color, #27ae60);
  font-weight: 700;
  white-space: nowrap;
}
.rdc-hint { color: #666; margin-top: 5px; display: block; font-size: .8rem; }

.rdc-check-container {
  display: flex;
  align-items: center;
  gap: .6rem;
  background-color: #e8f4f8;
  padding: .8rem;
  border-radius: .3rem;
  border: 1px solid #bee5eb;
  margin-bottom: 1rem;
}
.rdc-check-container label { font-weight: 700; color: #0c5460; cursor: pointer; }
.rdc-check-container input[type="checkbox"] { transform: scale(1.2); cursor: pointer; }
.rdc-check-container.rdc-highlight-new { background-color: #e8f8f5; border-color: #a3e4d7; }
.rdc-check-container.rdc-highlight-new label { color: #117a65; }

.rdc-input-group { display: flex; }
.rdc-input-group .form-control { border-radius: .25rem 0 0 .25rem; border-right: none; }
.rdc-btn-search-contact {
  background-color: #95a5a6;
  color: #fff;
  border: none;
  border-radius: 0 .25rem .25rem 0;
  padding: 0 .9rem;
  cursor: pointer;
}
.rdc-btn-search-contact:hover { background-color: #7f8c8d; }

.rdc-card-preview {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: .5rem;
  padding: 1.4rem;
  margin-top: 1.6rem;
}
.rdc-card-preview h4 { margin: 0 0 1rem; color: #555; font-size: 1rem; }

.rdc-btn-generate {
  width: 100%;
  justify-content: center;
  margin-top: 1.4rem;
  padding: .75rem 1.5rem;
  font-size: 1.02rem;
}

@keyframes rdcAutoSelectHighlight {
  0% { background-color: #d4edda; border-color: var(--success-color, #28a745); box-shadow: 0 0 8px rgba(40,167,69,0.5); }
  100% { background-color: transparent; border-color: var(--primary-color); box-shadow: none; }
}
.rdc-select-plantilla.rdc-auto-selected-highlight { animation: rdcAutoSelectHighlight 1.5s ease-out; }

/* Fila del documento recién registrado que llega preseleccionada desde Facturas/Créditos. */
@keyframes rdcFilaDestacada { from { background-color: #fff3cd; } to { background-color: transparent; } }
.rdc-fila-destacada td { animation: rdcFilaDestacada 2.4s ease-out; }

/* ---------------------------------------------------------------------
   Pestaña 3 — Bitácora
   --------------------------------------------------------------------- */
.rdc-bitacora-table { min-width: 1050px; table-layout: fixed; }
.rdc-bitacora-table tbody td { vertical-align: middle; }
/* Fecha, Moneda, Cant. Docs y Acciones centradas; Cliente/Aseguradora/
   Generado por se dejan a la izquierda por ser texto de longitud variable. */
.rdc-bitacora-table th:nth-child(1), .rdc-bitacora-table td:nth-child(1),
.rdc-bitacora-table th:nth-child(4), .rdc-bitacora-table td:nth-child(4),
.rdc-bitacora-table th:nth-child(5), .rdc-bitacora-table td:nth-child(5) {
  text-align: center;
}
.rdc-btn-ver-bitacora {
  background-color: var(--primary-color) !important;
  color: #fff;
  border: none;
  padding: .4rem .65rem;
  border-radius: .3rem;
  cursor: pointer;
}
.rdc-btn-ver-bitacora:hover { filter: brightness(1.08); }

/* ---------------------------------------------------------------------
   Modal de vista previa
   --------------------------------------------------------------------- */
.rdc-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  justify-content: center;
  align-items: flex-start;
}
.rdc-modal-overlay.active { display: flex; animation: fadeIn .3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.rdc-modal-scroll-area {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 5rem 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rdc-modal-actions {
  position: fixed;
  top: 1.2rem;
  right: 1.5rem;
  display: flex;
  gap: .5rem;
  z-index: 2100;
  flex-wrap: wrap;
}
.rdc-btn-modal-action {
  color: #fff;
  border: none;
  padding: .6rem 1.1rem;
  border-radius: .3rem;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: filter .2s;
  font-size: .92rem;
  white-space: nowrap;
}
.rdc-btn-modal-action:hover { filter: brightness(1.1); }
.rdc-btn-print { background: var(--success-color, #27ae60); }
.rdc-btn-word { background: #2b579a; }
.rdc-btn-word:disabled { opacity: .7; cursor: wait; filter: none; }
/* El aviso (p. ej. "Documento de Word descargado") debe verse encima del modal de vista previa (z-index 2000). */
.rdc-body #toast.toast-inline { z-index: 2200; }
.rdc-btn-close-modal { background: var(--danger-color, #e74c3c); }
.rdc-btn-share { background: #34495e; }
.rdc-btn-share.active { background: #2c3e50; }

.rdc-share-dropdown { position: relative; display: inline-block; }
.rdc-share-menu {
  position: absolute;
  top: 115%; right: 0;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border-radius: .4rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all .25s cubic-bezier(.25,.8,.25,1);
  z-index: 2101;
  min-width: 190px;
}
.rdc-share-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }
.rdc-share-item {
  padding: .8rem 1.2rem;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .95rem;
  font-weight: 600;
  color: #333;
  text-align: left;
  width: 100%;
  border-bottom: 1px solid #f0f0f0;
}
.rdc-share-item:last-child { border-bottom: none; }
.rdc-share-item:hover { background: #f4f7f6; }
.rdc-share-item.wsp i { color: #25D366; font-size: 1.05rem; }
.rdc-share-item.mail i { color: var(--danger-color, #e74c3c); font-size: 1.05rem; }

/* Hojas de documento — cada carta (backend/plantillas_remision/carta_*.html)
   trae su PROPIO <style> embebido (.page-preview, tipografía Inter/
   Merriweather, acento azul #1E3A8A) que el motor Handlebars compila
   server-side; ese <style> viaja dentro del HTML devuelto por /preparar y
   /bitacora/:codint y el navegador lo aplica normalmente al inyectarlo por
   innerHTML. Aquí solo se define el wrapper ".rdc-print-page" (uno por
   carta) que las envuelve al mostrarlas en el modal: le da el tamaño físico
   de una hoja Carta/Letter (8.5in x 11in, la misma unidad que ya usan las
   plantillas en su @media print) y separa visualmente varias páginas
   apiladas cuando incluyeBienvenida agrega una página adicional antes de
   la carta principal. */
.rdc-print-page {
  width: 8.5in;
  min-height: 11in;
  background: #fff;
  box-sizing: border-box;
  margin-bottom: 2rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.rdc-print-page:last-child { margin-bottom: 0; }
/* Cartas en hoja A4 (el paquete de la instancia lo indica con papel: "A4" en su catalogo.json). */
.rdc-print-page[data-papel="A4"] { width: 21cm; min-height: 29.7cm; }

/* El display:flex/block de estas reglas le ganaba al atributo [hidden] (la casilla de Bienvenida y la de encabezado
   se veían siempre): sin esto, ocultarlas desde el catálogo de la instancia no tiene efecto. */
.rdc-check-container[hidden],
.rdc-page .form-group[hidden],
.rdc-aviso-mezcla[hidden],
.rdc-badge-sugerencia[hidden] { display: none !important; }

/* Anexos de la carta (casillas) y aviso de selección mezclada */
.rdc-anexos-lista { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid #dbe5f0; border-radius: 8px; background: #f8fafc; }
.rdc-anexo { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: #1f2937; cursor: pointer; }
.rdc-anexo input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 auto; }
.rdc-anexo-cantidad { width: 64px; padding: 2px 6px; margin: 0 4px; border: 1px solid #b8cee5; border-radius: 6px; font: inherit; }
.rdc-aviso-mezcla { margin: 0 0 14px; padding: 10px 14px; border: 1px solid #f1c40f; border-left-width: 4px; border-radius: 8px; background: #fff9e6; color: #6b5300; font-size: .9rem; line-height: 1.4; }

@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body * { visibility: hidden; }
  #rdcPreviewModal, #rdcPreviewModal * { visibility: visible; }
  #rdcPreviewModal { position: absolute; left: 0; top: 0; width: 100%; height: auto; background: transparent; display: block; }
  .rdc-modal-scroll-area { padding: 0; overflow: visible; display: block; height: auto; }
  .rdc-modal-actions { display: none !important; }
  .rdc-print-page { width: 100%; min-height: auto; box-shadow: none; margin: 0; }
  .rdc-print-page[data-papel="A4"] { width: 100%; min-height: auto; }
  .rdc-print-page:not(:last-child) { page-break-after: always; }
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .rdc-body { overflow: auto; }
  .rdc-body #main-content { height: auto; min-height: 100vh; overflow: visible; }
  .rdc-page #tab-rdc-lista.tab-content.active,
  .rdc-page #tab-rdc-bitacora.tab-content.active { overflow: visible; }
  .rdc-page .rdc-workspace,
  .rdc-page #rdcBitWorkspace { flex-direction: column; overflow: visible; }
  .rdc-page .facturas-results-card,
  .rdc-page .facturas-table-wrap { overflow: visible; }
  .rdc-page #tab-rdc-registro.tab-content.active {
    height: auto;
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 760px) {
  .rdc-tabs .nav-link { min-height: 40px; padding: 8px 12px; font-size: .85rem; }
  .form-grid.dos-columnas { grid-template-columns: 1fr; }
  .rdc-print-page, .rdc-print-page[data-papel="A4"] { width: 100%; min-height: auto; }
  .rdc-modal-actions { top: .6rem; right: .6rem; }
}
