/* ============================================================================
   ESPERALOYA — reportes.css  v4.0
   Desktop-optimizado + print fix
   ============================================================================ */

/* ── Filter card ─────────────────────────────────────────────────────────── */
.filter-card {
  background: var(--white);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226,232,240,.6);
  margin-bottom: 16px;
}
.filter-card h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; margin: 0 0 14px;
  color: var(--g500); font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
}
.filter-card h3 .icon-svg { width: 14px; height: 14px; }

/* ── Grid de filtros: móvil ──────────────────────────────────────────────── */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.mini-field {
  border: 1.5px solid var(--g200);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  transition: border-color var(--t), box-shadow var(--t);
}
.mini-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.mini-field label {
  display: block; font-size: 10px; color: var(--g400);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 5px;
}
.mini-field input,
.mini-field select {
  border: none; padding: 0; height: auto;
  font-size: 14px; font-weight: 600; color: var(--navy);
  box-shadow: none; background: none;
}
.mini-field input:focus,
.mini-field select:focus { box-shadow: none; border: none; }

/* ── Botones de acción ───────────────────────────────────────────────────── */
.filter-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.btn-outline {
  flex: 1; min-width: 100px;
  height: 42px; border-radius: var(--r-sm);
  border: 1.5px solid var(--g200);
  background: var(--white);
  color: var(--g700); font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color var(--t), box-shadow var(--t), color var(--t);
  cursor: pointer;
  white-space: nowrap;
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.btn-print {
  flex: 1; min-width: 100px;
  height: 42px; border-radius: var(--r-sm);
  border: none;
  background: linear-gradient(135deg, var(--blue) 0%, #1D4ED8 100%);
  color: white; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 3px 10px rgba(37,99,235,.3);
  transition: opacity var(--t), transform var(--t);
  cursor: pointer; white-space: nowrap;
}
.btn-print:hover { opacity: .9; transform: translateY(-1px); }

/* ── KPI grid de reportes ────────────────────────────────────────────────── */
.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 16px;
}

/* ── Barras de método de pago ────────────────────────────────────────────── */
.payment-bars { display: flex; flex-direction: column; gap: 16px; }
.payment-bar-row { display: flex; flex-direction: column; gap: 6px; }
.payment-bar-head {
  display: flex; justify-content: space-between;
  align-items: center; font-size: 13px;
}
.payment-bar-head .label { color: var(--g600); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.payment-bar-head .label .icon-svg { width: 15px; height: 15px; }
.payment-bar-head .value { color: var(--navy); font-weight: 700; }
.payment-bar-track { height: 6px; border-radius: 99px; background: var(--g100); overflow: hidden; }
.payment-bar-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue) 0%, var(--blue-mid) 100%); transition: width .4s ease; }
.payment-bar-pct   { font-size: 11px; color: var(--g400); font-weight: 600; text-align: right; }

/* ── Dropdown selector ───────────────────────────────────────────────────── */
.rpt-dropdown { position: relative; }

.rpt-dropdown__trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px;
  border: 1.5px solid var(--g200);
  border-radius: var(--r-sm);
  background: var(--white);
  cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t);
  user-select: none;
}
.rpt-dropdown__trigger:hover,
.rpt-dropdown.open .rpt-dropdown__trigger {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.rpt-dropdown__icon {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rpt-dropdown__icon .icon-svg { width: 14px; height: 14px; }
.rpt-dropdown__icon.blue   { background: var(--blue-light);   color: var(--blue); }
.rpt-dropdown__icon.green  { background: var(--green-light);  color: var(--green); }
.rpt-dropdown__icon.red    { background: var(--red-light);    color: var(--red); }
.rpt-dropdown__icon.purple { background: var(--purple-light); color: var(--purple); }
.rpt-dropdown__icon.orange { background: var(--orange-light); color: var(--orange); }
.rpt-dropdown__label { flex: 1; font-size: 14px; font-weight: 600; color: var(--navy); }
.rpt-dropdown__chevron { width: 15px; height: 15px; color: var(--g400); transition: transform var(--t); }
.rpt-dropdown.open .rpt-dropdown__chevron { transform: rotate(180deg); }

.rpt-dropdown__menu {
  display: none;
  position: absolute; top: calc(100% + 5px); left: 0; right: 0;
  background: var(--white);
  border: 1.5px solid var(--g200);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 50; overflow: hidden;
  animation: dropIn .16s cubic-bezier(.4,0,.2,1);
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.rpt-dropdown.open .rpt-dropdown__menu { display: block; }

.rpt-option {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; cursor: pointer;
  transition: background var(--t-fast);
  border-bottom: 1px solid var(--g100);
}
.rpt-option:last-child { border-bottom: none; }
.rpt-option:hover { background: var(--g50); }
.rpt-option.active { background: var(--blue-light); }
.rpt-option__icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rpt-option__icon .icon-svg { width: 15px; height: 15px; }
.rpt-option__icon.blue   { background: var(--blue-light);   color: var(--blue); }
.rpt-option__icon.green  { background: var(--green-light);  color: var(--green); }
.rpt-option__icon.red    { background: var(--red-light);    color: var(--red); }
.rpt-option__icon.purple { background: var(--purple-light); color: var(--purple); }
.rpt-option__icon.orange { background: var(--orange-light); color: var(--orange); }
.rpt-option__label { flex: 1; font-size: 13.5px; font-weight: 500; color: var(--g700); }
.rpt-option.active .rpt-option__label { font-weight: 700; color: var(--blue); }
.rpt-option__check { width: 15px; height: 15px; color: var(--blue); opacity: 0; transition: opacity var(--t-fast); }
.rpt-option.active .rpt-option__check { opacity: 1; }

/* ── DESKTOP ─────────────────────────────────────────────────────────────── */
@media (min-width: 901px) {

  /* Filtros en una sola fila horizontal */
  .filter-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    align-items: start;
  }
  /* Año ocupa 1 columna normal */
  .mini-field[style*="grid-column:1/-1"] {
    grid-column: auto !important;
  }
  /* Selector tipo reporte ocupa la 4ta columna */
  .rpt-selector-wrap {
    grid-column: auto !important;
  }

  /* Botones de acción en fila, proporciones fijas */
  .filter-actions {
    flex-wrap: nowrap;
  }
  .filter-actions .btn-outline,
  .filter-actions .btn-print {
    flex: none;
    min-width: auto;
    padding: 0 18px;
  }
  .filter-actions #btn-filtrar { flex: 1; }
  .filter-actions #btn-imprimir { flex: 1; }
  .filter-actions #btn-exportar-excel { flex: 1; }
  .filter-actions #btn-exportar-pdf   { flex: 1; }

  /* Dropdown no se extiende más allá de su columna */
  .rpt-dropdown__menu {
    min-width: 260px;
    right: auto;
  }

  /* KPI en 4 columnas */
  .report-kpi-grid { grid-template-columns: repeat(4, 1fr); }

  /* Dash cards de reportes en 2 columnas */
  .rpt-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   IMPRESIÓN — corregido
   El error anterior era que #print-report estaba dentro de un .screen con
   display:none, lo que impide que @media print lo muestre.
   Solución: moverlo fuera del screen en el HTML y usar @media print aquí.
   ══════════════════════════════════════════════════════════════════════════ */

#print-report { display: none; }

@media print {
  /* Ocultar TODO excepto el bloque de impresión */
  body > *:not(#print-wrapper) { display: none !important; }
  #print-wrapper { display: block !important; }
  #print-report  { display: block !important; }

  /* Fallback: si el bloque está inline, mostrar solo él */
  #topbar, #sidebar, #sidebar-overlay, #bottomnav,
  #app, .no-print { display: none !important; }
  #print-report { display: block !important; position: static !important; }

  @page { size: 8.5in 11in; margin: .55in; }

  body  { background: white !important; display: block !important; padding: 0 !important; margin: 0 !important; }
}

#print-report .print-header { text-align: center; margin-bottom: 24px; border-bottom: 2px solid #0D1B2A; padding-bottom: 14px; }
#print-report .print-header h1 { font-size: 20px; margin: 0 0 3px; color: #0D1B2A; font-family: Arial, sans-serif; }
#print-report .print-header p  { font-size: 12px; color: #555; margin: 3px 0; font-family: Arial, sans-serif; }

#print-report table { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 16px; font-family: Arial, sans-serif; }
#print-report table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid #333; font-weight: 700; color: #000; background: #f5f5f5; }
#print-report table td { padding: 5px 8px; border-bottom: 1px solid #ddd; color: #222; }
#print-report table tr:nth-child(even) td { background: #fafafa; }

#print-report .print-totals { margin-top: 16px; font-size: 13px; font-family: Arial, sans-serif; border-top: 1px solid #ddd; padding-top: 12px; }
#print-report .print-totals div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #eee; }
#print-report .print-totals div.final { border-top: 2px solid #333; border-bottom: none; padding-top: 10px; margin-top: 6px; font-weight: 700; font-size: 15px; }
