/* gestion-pagos.css — Estilo profesional alineado con el sistema */

.gestion-pagos-page {
  background: #f4f6f9;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  color: #1f2937;
}

.gestion-pagos-page .container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 24px;
}

/* ── ENCABEZADO ── */
.header-dashboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.header-dashboard h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
}
.subtitulo-seccion {
  margin: 4px 0 0;
  font-size: 13px;
  color: #6b7280;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── BOTONES ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--color-primario, #2563eb); color: #fff; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ── KPIs (estilo resumen-card) ── */
.kpi-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi-card:nth-child(1) { background: #eff6ff; border: 1px solid #bfdbfe; }
.kpi-card:nth-child(1) h3 { color: #1e40af; }
.kpi-card:nth-child(2) { background: #fef2f2; border: 1px solid #fecaca; }
.kpi-card:nth-child(2) h3 { color: #991b1b; }
.kpi-card:nth-child(3) { background: #f0fdf4; border: 1px solid #bbf7d0; }
.kpi-card:nth-child(3) h3 { color: #065f46; }
.kpi-card:nth-child(4) { background: #fffbeb; border: 1px solid #fde68a; }
.kpi-card:nth-child(4) h3 { color: #92400e; }
.kpi-card h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kpi-card p {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #1f2937;
}
.kpi-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  text-transform: none;
  letter-spacing: 0;
}

/* ── SECCIONES ── */
.card-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.card-section__header {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}
.card-section__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
}
.card-section__sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: #6b7280;
}
.card-section__body {
  padding: 16px 20px;
}

/* ── FILTROS ── */
.form-row {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}
.form-row > div { min-width: 140px; flex: 1 1 160px; }
.field { display: flex; flex-direction: column; }
.field label {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}
.field input, .field select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #1f2937;
  font-family: inherit;
}
.filtro-mes-combo__btn {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #1f2937;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.filtro-mes-combo__btn:focus {
  outline: none;
  border-color: var(--color-primario, #2563eb);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.filtro-mes-combo__panel {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow: auto;
}
.filtro-mes-combo__panel[hidden] {
  display: none !important;
}
.filtro-mes-combo__anio {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  font-weight: 700;
  margin-bottom: 4px;
}
.filtro-mes-combo__opcion {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: #1f2937;
  border-radius: 4px;
  cursor: pointer;
}
.filtro-mes-combo__opcion:hover,
.filtro-mes-combo__opcion.is-activa {
  background: #eff6ff;
}
#btnBuscarDocumento, #btnLimpiarBusqueda {
  height: 36px;
  width: 36px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btnBuscarDocumento:hover, #btnLimpiarBusqueda:hover { background: #f3f4f6; }

/* ── RESULTADOS ── */
.resultados-wrapper {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.resultados-wrapper__header {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}
.resultados-wrapper__header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
}
.resultados-wrapper__header p {
  margin: 4px 0 0;
  font-size: 12px;
  color: #6b7280;
}
#resultados-documentos {
  border-radius: 0 0 12px 12px;
}

.tabla-productos {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}
.tabla-productos thead th {
  position: sticky;
  top: var(--header-total-h, 56px);
  z-index: 2;
  background: #f8fafc;
  color: #475569;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 6px;
  white-space: nowrap;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0;
}
.tabla-productos tbody td {
  padding: 8px 6px;
  border-bottom: 1px solid #f1f5f9;
  color: #1f2937;
  vertical-align: middle;
  font-size: 12px;
}
.tabla-productos tbody tr:nth-child(even) { background: #fafbfc; }
.tabla-productos tbody tr:hover { background: #f0f4ff; }
.tabla-productos tbody tr:last-child td { border-bottom: none; }

/* Ocultar columnas menos importantes en pantallas pequeñas */
@media (max-width: 1400px) {
  .tabla-productos th:nth-child(5),
  .tabla-productos td:nth-child(5),
  .tabla-productos th:nth-child(7),
  .tabla-productos td:nth-child(7) { display: none; }
}

.col-numero { font-weight: 700; color: #0f172a; }
.badge-numero-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  font-family: inherit;
  background: #e0f2fe;
  color: #0c4a6e;
  transition: opacity 0.15s;
}
.badge-numero-btn:hover { opacity: 0.8; }
.badge-numero-btn:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}
.col-total, .col-costo, .col-abono, .col-saldo {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.col-saldo.saldo-pendiente { color: #dc2626; font-weight: 700; }
.col-saldo.saldo-cero { color: #059669; font-weight: 700; }

/* ── BADGES ── */
.badge-cartera, .badge-produccion, .badge-entrega, .badge-anticipo, .badge-costo, .badge-abono {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-al-dia, .badge-ok { background: #d1fae5; color: #065f46; }
.badge-vence-hoy, .badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-vencido, .badge-pausado { background: #fee2e2; color: #991b1b; }
.badge-vencido-fuerte { background: #fecaca; color: #7f1d1d; }
.badge-no-iniciada, .badge-neutro { background: #e5e7eb; color: #4b5563; }
.badge-cancelada-doc { background: #f3f4f6; color: #374151; border: 1px solid #9ca3af; }
.badge-proceso { background: #dbeafe; color: #1d4ed8; }
.badge-listo { background: #ede9fe; color: #6d28d9; }
.badge-finalizado { background: #cffafe; color: #0f766e; }
.badge-pendiente-anticipo { background: #ffedd5; color: #9a3412; }
.badge-cubierto { background: #dcfce7; color: #166534; }
.badge-no-requiere { background: #e0f2fe; color: #0c4a6e; }

/* ── BADGE PRODUCCIÓN / ENTREGA CLICKABLE ── */
.badge-produccion-btn,
.badge-entrega-btn {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.badge-produccion-btn:hover,
.badge-entrega-btn:hover:not(:disabled) { opacity: 0.8; }
.badge-entrega-btn:disabled {
  cursor: default;
  opacity: 1;
}
.badge-entrega-btn.badge-ok {
  cursor: pointer;
}
.badge-prod-pendiente { background: #fecaca !important; color: #991b1b !important; }

/* ── ACCIONES ── */
.acciones-tabla {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}
.acciones-tabla button {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.acciones-tabla button:hover { background: #f3f4f6; }
.acciones-tabla button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-link-costos.badge-costo,
.btn-link-abono.badge-abono {
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-link-costos.badge-costo:hover,
.btn-link-abono.badge-abono:hover { opacity: 0.8; }
.badge-costo-ok { background: #dbeafe; color: #1d4ed8; }
.badge-costo-vacio { background: #e5e7eb; color: #4b5563; }
.badge-abono-ok { background: #dcfce7; color: #166534; }
.badge-abono-vacio { background: #e5e7eb; color: #4b5563; }

/* ── PAGINACIÓN ── */
.paginacion-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px 14px;
}
.btn-paginacion {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
}
.btn-paginacion:hover:not(:disabled) { background: #f3f4f6; }
.btn-paginacion:disabled { opacity: 0.5; cursor: not-allowed; }
#info-paginacion { font-size: 13px; color: #6b7280; }

/* ── FILAS ── */
.estado-vacio-tabla {
  padding: 24px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}
.fila-vencida { background: #fef2f2 !important; }

/* ── MODALES ── */
.modal {
  position: fixed; inset: 0; display: none;
  justify-content: center; align-items: center;
  z-index: 3000; background: rgba(0,0,0,0.4);
  padding: 16px;
}
/* SweetAlert (z-index ~1060) debe quedar encima de .modal */
body .swal2-container {
  z-index: 10050 !important;
}
.modal-content {
  background: #fff; border-radius: 12px; padding: 24px;
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
#modal-vista-documento .modal-content { max-width: 900px; }
.modal h2, .modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 700; color: #1a1a2e; }
.modal-cerrar-superior { text-align: right; margin-bottom: 4px; }
.modal-cerrar-superior button, .cerrar-modal, .cerrar-modal-previsualizar {
  background: none; border: none; font-size: 18px; cursor: pointer;
  padding: 4px; color: #9ca3af; line-height: 1;
}
.modal-cerrar-superior button:hover { color: #1f2937; }
.modal-acciones {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; justify-content: flex-end; margin-top: 16px;
}
#form-registrar-pago { display: flex; flex-direction: column; gap: 12px; }
.aviso-pago-exceso {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  font-weight: 600;
}

/* ── AUTOCOMPLETE ── */
.gestion-pagos-page .posicion-relativa { position: relative; }
.gestion-pagos-page .sugerencias-container {
  position: absolute; top: calc(100% + 4px); left: 0;
  max-height: 280px; overflow-y: auto;
  background: #fff; border: 1px solid var(--color-primario, #2563eb);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 30000; display: none;
  width: max-content; min-width: 100%; max-width: 500px;
}
.gestion-pagos-page .sugerencia-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px; color: #1f2937;
}
.gestion-pagos-page .sugerencia-item:hover { background: #eff6ff; font-weight: 600; }
.gestion-pagos-page .sugerencia-item.error { color: #dc2626; background: #fef2f2; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .gestion-pagos-page .container { padding: 12px; }
  .kpi-container { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 576px) {
  .kpi-container { grid-template-columns: 1fr; }
  .header-dashboard h1 { font-size: 18px; }
  .form-row > div { flex: 1 1 100%; }
}

.btn-facturado { border: 2px solid #22c55e !important; border-radius: 6px; padding: 4px !important; }
