/*
 * Reporte · Productos Vendidos.
 *
 * Framework propio `--pv-*`, acotado a #reporteProductosVendidos. Todo el estilo
 * vive acá: la vista no lleva <style> ni style=" (método de Pacientes).
 *
 * Misma paleta INSTITUCIONAL que el reporte de Cuentas por Pagar: UN acento
 * (índigo #3f51b5, el de `pacientes/css`) + escala de grises. Los agrupamientos y
 * orígenes NO llevan color propio: son categorías, no estados.
 *
 * Reglas responsive heredadas de esa pantalla (ver su _DOC_): nada de `col-lg-*`
 * de Bootstrap —sus breakpoints miran la VENTANA y el sidebar se lleva 236 px—,
 * grids con `auto-fit` y `min-width: 0` en cada celda.
 */

#reporteProductosVendidos {
    --pv-paper: #f8f9fa;
    --pv-surface: #ffffff;
    --pv-ink: #2d3748;
    --pv-muted: #6c757d;
    --pv-faint: #9aa3ad;
    --pv-line: #e5e7eb;
    --pv-line-strong: #d1d5db;
    --pv-primary: #3f51b5;
    --pv-primary-dark: #2c3a8c;
    --pv-primary-soft: #eef0fb;
    --pv-radius: 14px;
}

/* ---------------- Contenedor ---------------- */
#reporteProductosVendidos { max-width: 100%; overflow-x: hidden; }
#reporteProductosVendidos .pv-shell { background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: 16px; overflow: hidden; max-width: 100%; }
#reporteProductosVendidos .pv-head { padding: 22px 24px; border-bottom: 1px solid var(--pv-line); }
#reporteProductosVendidos .pv-head h4 { font-size: clamp(1.05rem, 2.2vw, 1.3rem); font-weight: 700; color: var(--pv-ink); margin: 0; }
#reporteProductosVendidos .pv-head h4 .bi { color: var(--pv-primary); }
#reporteProductosVendidos .pv-sub { color: var(--pv-muted); font-size: 12.5px; margin: 5px 0 0; max-width: 82ch; line-height: 1.55; }
#reporteProductosVendidos .pv-chip-head { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--pv-muted); background: var(--pv-paper); border: 1px solid var(--pv-line); padding: 5px 11px; border-radius: 6px; }
#reporteProductosVendidos .pv-body { padding: 18px; background: var(--pv-paper); }
@media (min-width: 768px) { #reporteProductosVendidos .pv-body { padding: 22px 24px; } }

/* ---------------- Filtros ---------------- */
#reporteProductosVendidos .pv-filter { background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-radius); padding: 16px; margin-bottom: 16px; }
#reporteProductosVendidos .pv-filter label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--pv-faint); margin: 0 0 6px; display: block; }
#reporteProductosVendidos .pv-filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px 14px; align-items: end; }
@media (min-width: 1600px) {
    #reporteProductosVendidos .pv-filtros { grid-template-columns: repeat(auto-fit, minmax(185px, 280px)); justify-content: start; }
}
#reporteProductosVendidos .pv-campo { min-width: 0; }
#reporteProductosVendidos .pv-campo .form-control { width: 100%; min-width: 0; max-width: 100%; }
#reporteProductosVendidos .pv-campo--boton { display: flex; align-items: flex-end; }
#reporteProductosVendidos .pv-filter .form-control { border-radius: 8px; border: 1px solid var(--pv-line-strong); height: 40px; font-size: 13.5px; color: var(--pv-ink); }
#reporteProductosVendidos .pv-filter .form-control:focus { border-color: var(--pv-primary); box-shadow: 0 0 0 3px rgba(63, 81, 181, .14); }
#reporteProductosVendidos .pv-btn { height: 40px; border-radius: 8px; font-weight: 600; font-size: 13.5px; border: 1px solid var(--pv-primary); color: #fff; padding: 0 22px; width: 100%; min-width: 0; white-space: nowrap; background: var(--pv-primary); }
#reporteProductosVendidos .pv-btn:hover { background: var(--pv-primary-dark); border-color: var(--pv-primary-dark); }
#reporteProductosVendidos .pv-btn:disabled { opacity: .6; }

/* Buscador con autocompletar: el componente envuelve el input en `.ac-wrap`, que ya
   dibuja el marco. La regla de arriba lleva id y le gana a la neutralización propia
   del componente (0-3-0) ⇒ doble borde si no se anula acá. */
#reporteProductosVendidos .pv-buscar-wrap { position: relative; }
#reporteProductosVendidos .pv-filter .ac-wrap { height: 40px; min-width: 0; padding: 0 10px; border: 1px solid var(--pv-line-strong); border-radius: 8px; background: var(--pv-surface); }
#reporteProductosVendidos .pv-filter .ac-wrap:focus-within { border-color: var(--pv-primary); box-shadow: 0 0 0 3px rgba(63, 81, 181, .14); }
#reporteProductosVendidos .pv-filter .ac-wrap .form-control,
#reporteProductosVendidos .pv-filter .ac-wrap .form-control:focus { height: 38px; padding: 0; border: 0; box-shadow: none; background: transparent; border-radius: 0; }

/* ---------------- KPIs ---------------- */
#reporteProductosVendidos .pv-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-bottom: 14px; }
#reporteProductosVendidos .pv-metric { background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: 10px; padding: 11px 13px; min-width: 0; }
#reporteProductosVendidos .pv-metric .m-k { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pv-faint); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#reporteProductosVendidos .pv-metric .m-v { font-size: 1.1rem; font-weight: 700; color: var(--pv-ink); margin-top: 5px; line-height: 1.15; overflow-wrap: anywhere; }
#reporteProductosVendidos .pv-metric .m-s { font-size: 11px; color: var(--pv-muted); margin-top: 2px; }
#reporteProductosVendidos .pv-metric.total { border-color: var(--pv-primary); background: var(--pv-primary-soft); }
#reporteProductosVendidos .pv-metric.total .m-k { color: var(--pv-primary-dark); }
#reporteProductosVendidos .pv-metric.total .m-v { color: var(--pv-primary-dark); font-size: 1.3rem; }

/* ---------------- Selector de vista ---------------- */
#reporteProductosVendidos .pv-vistas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
#reporteProductosVendidos .pv-vista { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--pv-line-strong); background: var(--pv-surface); color: var(--pv-muted); border-radius: 8px; padding: 7px 15px; cursor: pointer; user-select: none; }
#reporteProductosVendidos .pv-vista.activa { color: #fff; background: var(--pv-primary); border-color: var(--pv-primary); }

/* ---------------- Tabla ---------------- */
#reporteProductosVendidos .pv-tabla-card { background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-radius); overflow: hidden; }
#reporteProductosVendidos .pv-tabla-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--pv-line); }
#reporteProductosVendidos .pv-tabla-top .t-titulo { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--pv-muted); min-width: 0; }
#reporteProductosVendidos .pv-tabla-acciones { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 260px; justify-content: flex-end; min-width: 0; }
#reporteProductosVendidos .pv-tabla-top .form-control { height: 36px; font-size: 13px; border-radius: 8px; border: 1px solid var(--pv-line-strong); flex: 1 1 170px; width: auto; min-width: 0; max-width: 260px; }
#reporteProductosVendidos .pv-btn-excel { height: 36px; border-radius: 8px; border: 1px solid var(--pv-line-strong); background: var(--pv-surface); color: var(--pv-muted); font-size: 12.5px; font-weight: 600; padding: 0 13px; white-space: nowrap; }
#reporteProductosVendidos .pv-btn-excel:hover { border-color: var(--pv-primary); color: var(--pv-primary-dark); background: var(--pv-primary-soft); }

#reporteProductosVendidos .pv-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
#reporteProductosVendidos table.pv-tabla { width: 100%; min-width: 700px; margin: 0; border-collapse: collapse; font-size: 13px; }
#reporteProductosVendidos table.pv-tabla thead th { background: var(--pv-paper); color: var(--pv-muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--pv-line); white-space: nowrap; }
#reporteProductosVendidos table.pv-tabla thead th[data-col] { cursor: pointer; user-select: none; }
#reporteProductosVendidos table.pv-tabla thead th[data-col]::after { content: "\2195"; margin-left: 6px; opacity: .3; font-size: 11px; }
#reporteProductosVendidos table.pv-tabla thead th[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; color: var(--pv-primary); }
#reporteProductosVendidos table.pv-tabla thead th[aria-sort="descending"]::after { content: "\2193"; opacity: 1; color: var(--pv-primary); }
#reporteProductosVendidos table.pv-tabla thead th.col-num { text-align: right; }
#reporteProductosVendidos table.pv-tabla thead th.col-fit { width: 1%; }
#reporteProductosVendidos table.pv-tabla tbody td { padding: 10px 12px; border-bottom: 1px solid var(--pv-line); color: var(--pv-ink); vertical-align: middle; overflow-wrap: anywhere; }
#reporteProductosVendidos table.pv-tabla tbody tr:hover { background: var(--pv-paper); }
#reporteProductosVendidos table.pv-tabla tbody tr:last-child td { border-bottom: 0; }

#reporteProductosVendidos .pv-fuerte { font-weight: 700; color: var(--pv-ink); }
#reporteProductosVendidos .pv-sec { font-size: 11.5px; color: var(--pv-muted); margin-top: 2px; }
#reporteProductosVendidos .pv-etiqueta { display: inline-block; margin-right: 5px; vertical-align: 1px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--pv-muted); background: var(--pv-paper); border: 1px solid var(--pv-line-strong); border-radius: 5px; padding: 2px 8px; white-space: nowrap; }
#reporteProductosVendidos .pv-ficha { font-size: 10.5px; font-weight: 700; color: var(--pv-primary-dark); background: var(--pv-primary-soft); border-radius: 5px; padding: 1px 6px; margin-left: 6px; }
#reporteProductosVendidos .pv-num { text-align: right; white-space: nowrap; }
#reporteProductosVendidos .pv-num.fuerte { font-weight: 700; }
#reporteProductosVendidos .pv-accion { display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--pv-primary-dark); background: var(--pv-primary-soft); border: 1px solid var(--pv-primary); border-radius: 7px; padding: 5px 9px; white-space: nowrap; text-decoration: none; }
#reporteProductosVendidos .pv-accion:hover { background: var(--pv-primary); color: #fff; text-decoration: none; }
#reporteProductosVendidos .pv-sin-doc { font-size: 11px; color: var(--pv-faint); }

#reporteProductosVendidos .pv-vacio { text-align: center; padding: 40px 16px; color: var(--pv-muted); font-size: 14px; }
#reporteProductosVendidos .pv-vacio .bi { display: block; font-size: 2rem; color: var(--pv-faint); margin-bottom: 8px; }

/* Paginación */
#reporteProductosVendidos .pv-pag { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--pv-line); font-size: 12.5px; color: var(--pv-muted); }
#reporteProductosVendidos .pv-pag-btns { display: flex; gap: 6px; flex-wrap: wrap; }
#reporteProductosVendidos .pv-pag-btn { min-width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--pv-line-strong); background: var(--pv-surface); color: var(--pv-ink); font-size: 12.5px; font-weight: 600; padding: 0 9px; }
#reporteProductosVendidos .pv-pag-btn.activo { background: var(--pv-primary); border-color: var(--pv-primary); color: #fff; }
#reporteProductosVendidos .pv-pag-btn:disabled { opacity: .45; }

#reporteProductosVendidos #pv_resultado { display: none; }
#reporteProductosVendidos .pv-nota { font-size: 11px; color: var(--pv-faint); margin-top: 8px; }
#reporteProductosVendidos .pv-aviso { font-size: 11.5px; color: var(--pv-primary-dark); background: var(--pv-primary-soft); border: 1px solid var(--pv-primary); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; display: none; }

/* ---------------- Responsive: la tabla pasa a tarjetas ---------------- */
@media (max-width: 991.98px) {
    #reporteProductosVendidos table.pv-tabla { min-width: 0; }
    #reporteProductosVendidos table.pv-tabla thead { display: none; }
    #reporteProductosVendidos table.pv-tabla,
    #reporteProductosVendidos table.pv-tabla tbody,
    #reporteProductosVendidos table.pv-tabla tr,
    #reporteProductosVendidos table.pv-tabla td { display: block; width: 100%; }
    #reporteProductosVendidos table.pv-tabla tr { border: 1px solid var(--pv-line); border-radius: 10px; margin-bottom: 10px; padding: 4px 0; }
    #reporteProductosVendidos table.pv-tabla tbody td { border-bottom: 0; display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; }
    #reporteProductosVendidos table.pv-tabla tbody td::before { content: attr(data-label); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--pv-faint); flex-shrink: 0; }
    #reporteProductosVendidos .pv-num { text-align: right; }
}
