/* ═══════════════════════════════════════════════════════════════
   recibos.css v2 — Layout rediseñado (UI/UX Pro Max)
   Industria: fintech/enterprise · Estilo: Dashboard Clean Data-Dense
   ═══════════════════════════════════════════════════════════════ */

/* ─── CONTENEDOR PRINCIPAL (forzar arriba sin romper el flex de la app) ─── */
#page-recibos {
  padding: 0 !important;
  margin: 0 !important;
  flex: 1;
  min-width: 0;
  /* Sin animación de entrada para evitar salto visual */
  animation: none !important;
}
/* El .container global tiene max-width:900px y padding:20px — lo anulamos */
#page-recibos > .container,
#page-recibos .container {
  padding: 14px 16px !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box;
}
/* El .content-area tiene overflow-y:auto — el hero debe arrancar desde el borde */
.content-area:has(#page-recibos.active) {
  padding: 0 !important;
}
#page-recibos.active {
  animation: none !important;
}

/* ─── HERO ADMIN: buscador + acciones al inicio ─── */
.rec-hero {
  background: linear-gradient(135deg, #1A3C8F 0%, #2251b8 100%);
  border-radius: 0 0 16px 16px;   /* solo esquinas inferiores redondeadas */
  padding: 20px;
  margin-bottom: 16px;
  margin-top: 0;
  color: #fff;
  box-shadow: 0 4px 20px rgba(26,60,143,.2);
}
.rec-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.rec-hero h2 {
  font-size: 20px;
  font-weight: 900;
  margin: 0;
  letter-spacing: -.5px;
}
.rec-hero-subtitle {
  font-size: 12px;
  opacity: .82;
  margin-top: 3px;
}
.rec-hero-acciones {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.rec-hero-acciones .btn {
  background: rgba(255,255,255,.18) !important;
  color: #fff !important;
  border: 1.5px solid rgba(255,255,255,.25) !important;
  font-weight: 700;
}
.rec-hero-acciones .btn:hover {
  background: rgba(255,255,255,.28) !important;
}

/* Buscador grande y prominente */
.rec-hero-search {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rec-hero-search input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  background: transparent;
}
.rec-hero-search input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}
.rec-hero-search-btn {
  padding: 10px 18px;
  background: #1A3C8F;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.rec-hero-search-btn:hover { background: #122b6a; }
.rec-hero-hint {
  font-size: 11px;
  margin-top: 8px;
  opacity: .75;
  color: #fff;
}

/* Resultados búsqueda admin (aparecen como dropdown bajo el hero) */
.rec-search-results {
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  margin-top: -8px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  position: relative;
  z-index: 10;
}
.rec-search-results::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 24px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
  transform: rotate(45deg);
}

/* ─── Vista admin: sin padding para que hero toque el borde ─── */
#recAdminView {
  padding: 0 !important;
}
/* El padding va SOLO debajo del hero, en el cuerpo del contenido */
#recAdminView > *:not(.rec-hero) {
  padding-left: 16px;
  padding-right: 16px;
}

/* ─── KPIs COMPACTOS ─── */
.rec-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rec-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border-top: 3px solid #1A3C8F;
  transition: transform .2s, box-shadow .2s;
  min-width: 0;
}
.rec-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.rec-kpi-card.k-orange { border-top-color: #ea580c; }
.rec-kpi-card.k-green  { border-top-color: #16a34a; }
.rec-kpi-card.k-red    { border-top-color: #dc2626; }
.rec-kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: .6px;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.rec-kpi-badge {
  font-size: 8px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
  background: #eef2fb;
  color: #1A3C8F;
  letter-spacing: .5px;
}
.rec-kpi-badge.danger  { background: #fef2f2; color: #dc2626; }
.rec-kpi-badge.warning { background: #fff7ed; color: #ea580c; }
.rec-kpi-val {
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -.8px;
  line-height: 1.1;
  margin-top: 2px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.rec-kpi-val.mora { color: #dc2626; }
.rec-kpi-val.pending { color: #ea580c; }
.rec-kpi-sub { font-size: 10px; color: #64748b; margin-top: 3px; }

/* ─── SECCIONES SECUNDARIAS ─── */
.rec-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  margin-bottom: 14px;
}
.rec-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.rec-section-title {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.2px;
}
.rec-section-meta {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

/* ─── Aging bars ─── */
.rec-aging-bars {
  display: flex;
  height: 12px;
  border-radius: 99px;
  overflow: hidden;
  background: #f1f5f9;
  margin-bottom: 10px;
}
.rec-aging-seg { transition: flex .5s; }
.rec-aging-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.rec-aging-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}
.rec-aging-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ─── Filtros chips ─── */
.rec-filtros {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.rec-chip {
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background: #f1f5f9;
  color: #475569;
  transition: all .2s;
  border: none;
  font-family: inherit;
}
.rec-chip.active { background: #1A3C8F; color: #fff; }
.rec-chip:hover:not(.active) { background: #e2e8f0; }

/* ─── Tabla compacta ─── */
.rec-table-wrap { overflow-x: auto; width: 100%; max-width: 100%; -webkit-overflow-scrolling: touch; }
.rec-table { width: 100%; border-collapse: collapse; }
.rec-table thead th {
  text-align: left;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: .6px;
  text-transform: uppercase;
  border-bottom: 1.5px solid #f1f5f9;
  background: #f8fafc;
}
.rec-table tbody td {
  padding: 10px;
  font-size: 12px;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
}
.rec-table tbody tr:hover { background: #f8fafc; }
.rec-td-codigo { font-weight: 800; color: #1A3C8F; font-family: monospace; font-size: 11px; }
.rec-td-cliente strong { display: block; color: #0f172a; font-weight: 700; font-size: 12px; }
.rec-td-cliente span { font-size: 10px; color: #94a3b8; }
.rec-td-amount { font-weight: 800; color: #0f172a; font-size: 13px; }

/* ─── Pills de estado ─── */
.rec-pill {
  font-size: 9px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  letter-spacing: .3px;
}
.rec-pill .sdot { width: 5px; height: 5px; border-radius: 50%; }
.rec-pill.pendiente { background: #fff7ed; color: #ea580c; }
.rec-pill.pendiente .sdot { background: #ea580c; }
.rec-pill.aplicado { background: #dcfce7; color: #16a34a; }
.rec-pill.aplicado .sdot { background: #16a34a; }
.rec-pill.rechazado { background: #fef2f2; color: #dc2626; }
.rec-pill.rechazado .sdot { background: #dc2626; }

/* ─── Botones de acción en tabla ─── */
.rec-acciones { display: flex; gap: 4px; }
.rec-btn-acc {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: inherit;
}
.rec-btn-acc.ver { background: #eef2fb; color: #1A3C8F; }
.rec-btn-acc.ver:hover { background: #1A3C8F; color: #fff; }
.rec-btn-acc.aprobar { background: #dcfce7; color: #16a34a; }
.rec-btn-acc.aprobar:hover { background: #16a34a; color: #fff; }
.rec-btn-acc.rechazar { background: #fef2f2; color: #dc2626; }
.rec-btn-acc.rechazar:hover { background: #dc2626; color: #fff; }

/* ─── Cliente cards (resultado de búsqueda) ─── */
.rec-cli-card {
  background: #fff;
  border: 1.5px solid #f1f5f9;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all .2s;
}
.rec-cli-card:hover {
  border-color: #1A3C8F;
  background: #f8fafc;
  transform: translateX(3px);
}
.rec-cli-name { font-size: 13px; font-weight: 800; color: #0f172a; margin-bottom: 2px; }
.rec-cli-status { font-size: 10px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.rec-cli-status.aldia { color: #16a34a; }
.rec-cli-status.vencido { color: #ea580c; }
.rec-cli-status.mora { color: #dc2626; }
.rec-cli-dot { width: 6px; height: 6px; border-radius: 50%; }
.rec-cli-dot.aldia { background: #16a34a; }
.rec-cli-dot.vencido { background: #ea580c; }
.rec-cli-dot.mora { background: #dc2626; }
.rec-cli-amount { text-align: right; }
.rec-cli-val { font-size: 14px; font-weight: 800; color: #0f172a; }
.rec-cli-sub { font-size: 10px; color: #94a3b8; margin-top: 2px; }

/* ─── Modal overlay ─── */
.rec-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.rec-modal-overlay.open { display: flex; }
.rec-modal {
  background: #fff;
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.rec-modal.wide { max-width: 760px; }
.rec-modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}
.rec-modal-head h3 {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}
.rec-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rec-modal-close:hover { background: #fef2f2; color: #dc2626; }
.rec-modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.rec-modal-foot {
  padding: 14px 22px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  background: #fafbfc;
}

/* ─── Form del modal ─── */
.rec-medio-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rec-medio-btn {
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.rec-medio-btn.selected { border-color: #1A3C8F; background: #eef2fb; color: #1A3C8F; }
.rec-medio-btn:hover:not(.selected) { border-color: #cbd5e1; background: #f8fafc; }

.rec-fac-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  gap: 10px;
}
.rec-fac-row:last-child { border-bottom: none; }
.rec-fac-chk { width: 18px; height: 18px; accent-color: #1A3C8F; cursor: pointer; flex-shrink: 0; }
.rec-fac-info { flex: 1; margin-left: 8px; min-width: 0; }
.rec-fac-cod { font-size: 12px; font-weight: 800; color: #0f172a; }
.rec-fac-date { font-size: 10px; color: #94a3b8; margin-top: 1px; }
.rec-fac-saldo { text-align: right; flex-shrink: 0; min-width: 90px; }
.rec-fac-pend { font-size: 13px; font-weight: 800; color: #0f172a; }
.rec-fac-input {
  width: 110px;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  text-align: right;
  outline: none;
  flex-shrink: 0;
}
.rec-fac-input:focus { border-color: #1A3C8F; }
.rec-fac-input:disabled { background: #f8fafc; color: #94a3b8; }

.rec-totals {
  background: #eef2fb;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.rec-totals-label { font-size: 11px; font-weight: 700; color: #122b6a; letter-spacing: .4px; }
.rec-totals-val { font-size: 18px; font-weight: 900; color: #1A3C8F; }

/* ─── Medios config row ─── */
.rec-medio-config {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1.5px solid #f1f5f9;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
}
.rec-medio-config.inactive { opacity: .5; }
.rec-medio-config-emoji { font-size: 22px; width: 36px; text-align: center; }
.rec-medio-config-info { flex: 1; min-width: 0; }
.rec-medio-config-name { font-size: 13px; font-weight: 700; color: #0f172a; }
.rec-medio-config-code { font-size: 10px; color: #94a3b8; font-family: monospace; }
.rec-switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  background: #cbd5e1;
  border-radius: 99px;
  cursor: pointer;
  transition: background .2s;
}
.rec-switch.on { background: #16a34a; }
.rec-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
}
.rec-switch.on::after { left: 18px; }

.rec-form-label {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  margin-bottom: 6px;
  display: block;
  letter-spacing: .4px;
}
.rec-form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  color: #1e293b;
  outline: none;
  background: #fff;
}
.rec-form-input:focus { border-color: #1A3C8F; }
.rec-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Empty state ─── */
.rec-empty {
  text-align: center;
  padding: 32px 20px;
  color: #94a3b8;
}
.rec-empty-icon { font-size: 40px; margin-bottom: 8px; }
.rec-empty-msg { font-size: 13px; font-weight: 600; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .rec-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .rec-form-row { grid-template-columns: 1fr; }
  .rec-table { font-size: 11px; }
  .rec-table thead th, .rec-table tbody td { padding: 7px; }
  .rec-hero h2 { font-size: 17px; }
  .rec-hero-acciones .btn { font-size: 11px; padding: 7px 10px; }
}
@media (max-width: 600px) {
  .rec-kpi-grid { grid-template-columns: 1fr; }
  .rec-kpi-val { font-size: 19px; }
  .rec-btn-acc { font-size: 9px; padding: 3px 7px; }
  .rec-hero-search input { font-size: 13px; padding: 10px; }
  .rec-hero-search-btn { padding: 8px 12px; font-size: 12px; }
}

/* ─── IMPRESIÓN: solo mostrar el recibo con membrete ─── */
@media print {
  /* Ocultar TODA la app */
  .header, .sidebar-nav, .app-layout, #page-recibos,
  .rec-modal-overlay, .nav-tabs, .no-print,
  .rec-hero, .rec-kpi-grid, .rec-section,
  .rec-search-results, footer { display: none !important; }

  /* Mostrar SOLO el modal de factura/recibo */
  #modalFactura {
    display: block !important;
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    z-index: auto !important;
  }
  #modalFactura .modal {
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  #modalFactura .modal-close { display: none !important; }
  #modalFactura .no-print { display: none !important; }

  /* Recibo imprimible: legible y limpio */
  .factura-print {
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 10mm !important;
    margin: 0 !important;
    font-size: 12pt !important;
  }
  .factura-print .membrete { border-bottom-color: #000 !important; }
  .factura-print .membrete .logo-membrete { max-height: 50px !important; }
  .factura-print .negocio { font-size: 16pt !important; }
  .factura-print .nit { font-size: 11pt !important; }
  .factura-print .info { font-size: 9pt !important; }
  .factura-print table th {
    background: #1A3C8F !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .factura-print .totales { font-size: 14pt !important; }
  .factura-print .footer { font-size: 9pt !important; }

  /* Forzar fondo blanco */
  body { background: white !important; margin: 0 !important; padding: 0 !important; }
  * { color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
}
