/* Preventa: alta, edición y detalle (/preventas/nueva, /preventas/editar/{id}, /preventas/detalle/{id}).
   Usa las piezas de presupuesto-form.css (pf-cab, pf-tarjeta, pf-buscar, pf-lista, pf-opcion, pf-campo,
   pf-agregar, pf-btn, pf-avatar, pf-barra-movil…) y acá va lo propio, con prefijo pvf-: artículos a la
   izquierda y a la derecha cliente, datos y totales con las acciones. Hoja global (los .razor.css no
   se cargan). */
.pvf-pagina {
    --pvf-verde: #15803d;
    --pvf-fondo-suave: #f7f8fa;
    margin: 0 auto;
}

/* ── Cabecera: estado (pf-estado sin modificador = ámbar, Borrador) ── */
.pf-estado.pvf-confirmada { background: #dcfce7; color: #166534; }
.pf-estado.pvf-convertida { background: var(--pf-azul-claro); color: var(--pf-azul); }
.pf-estado.pvf-cancelada { background: #f1f2f4; color: var(--pf-atenuado); }
.pvf-cab-acciones { flex-wrap: wrap; justify-content: flex-end; }

/* ── Distribución ── */
.pvf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.pvf-layout .pf-tarjeta { margin-bottom: 0; }
.pvf-lateral { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.pvf-tarjeta { padding: 1rem 1rem 1.05rem; }
.pvf-tarjeta-titulo {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    margin-bottom: .75rem; color: #374151; font-size: .9rem; font-weight: 500;
}

/* ── Cliente ── */
.pvf-cliente-elegido { display: flex; align-items: flex-start; gap: .75rem; }
.pvf-avatar { flex: 0 0 40px; width: 40px; height: 40px; font-size: .85rem; }
.pvf-cliente-texto { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.pvf-cliente-texto strong { font-size: .98rem; font-weight: 600; overflow-wrap: anywhere; }
.pvf-cliente-texto small { color: #4b5563; font-size: .83rem; overflow-wrap: anywhere; }
.pvf-tarjeta-cliente .pf-buscar input:disabled { background: #f6f7f9; }

/* ── Datos de la preventa ── */
.pvf-campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.pvf-ancho { grid-column: 1 / -1; }
.pvf-campos .pf-campo > span { font-size: .85rem; font-weight: 500; }
.pvf-campos .pf-campo > input,
.pvf-campos .pf-campo > select { height: 42px; }
.pvf-pagina .pf-campo > input:disabled,
.pvf-pagina .pf-campo > select:disabled { background-color: #f6f7f9; color: var(--pf-texto); opacity: 1; }
.pvf-arca { padding: .65rem .75rem; border: 1px solid var(--pf-borde); border-radius: 10px; background: #fafbfc; }
.pvf-arca .form-check { margin: 0; }
.pvf-arca .form-check-label { font-size: .9rem; font-weight: 500; }
.pvf-arca p { margin: .3rem 0 0; color: var(--pf-atenuado); font-size: .8rem; line-height: 1.4; }

/* ── Artículos ── */
.pvf-agregar { grid-template-columns: minmax(0, 1fr) 96px 120px auto; }

.pvf-tabla-contenedor { overflow-x: auto; }
.pvf-tabla { width: 100%; border-collapse: collapse; font-size: .93rem; }
.pvf-tabla th {
    padding: .7rem .6rem; background: var(--pvf-fondo-suave); border-bottom: 1px solid var(--pf-borde);
    color: var(--pf-atenuado); font-size: .82rem; font-weight: 500; text-align: left; white-space: nowrap;
}
.pvf-tabla td { padding: .6rem; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.pvf-tabla tbody tr:last-child td { border-bottom: 0; }
.pvf-tabla th:first-child, .pvf-tabla td:first-child { padding-left: 1.25rem; }
.pvf-tabla th:last-child, .pvf-tabla td:last-child { padding-right: 1rem; }
.pvf-tabla tbody tr:hover { background: #fafbfc; }
.pvf-tabla tr.pvf-editable { cursor: pointer; }
.pvf-col-cant { width: 136px; text-align: center !important; white-space: nowrap; }
.pvf-col-precio { width: 126px; text-align: right !important; white-space: nowrap; }
.pvf-col-var { width: 96px; text-align: center !important; white-space: nowrap; }
.pvf-col-total { width: 126px; text-align: right !important; font-weight: 600; white-space: nowrap; }
.pvf-col-acciones { width: 76px; text-align: right !important; white-space: nowrap; }

.pvf-item-nombre {
    display: block; max-width: 100%; padding: 0; border: 0; background: none; color: var(--pf-texto);
    font: inherit; font-weight: 500; text-align: left; overflow-wrap: anywhere;
}
button.pvf-item-nombre { cursor: pointer; }
button.pvf-item-nombre:hover { color: var(--pf-azul); }
.pvf-item-sub { display: block; margin-top: .1rem; color: var(--pf-atenuado); font-size: .8rem; }
.pvf-pin { margin-left: .25rem; color: #d97706; font-size: .8rem; }

.pvf-cantidad { display: inline-flex; align-items: center; gap: .3rem; }
.pvf-cantidad-btn {
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--pf-borde); border-radius: 8px; background: #fff; color: var(--pf-texto); font-size: 1rem; line-height: 1;
}
.pvf-cantidad-btn:hover:not(:disabled) { background: #f3f4f6; }
.pvf-cantidad-btn:disabled { opacity: .4; }
.pvf-cantidad input {
    width: 52px; height: 32px; padding: 0 .2rem; border: 1px solid transparent; border-radius: 6px; background: transparent;
    font-weight: 600; text-align: center; -moz-appearance: textfield;
}
.pvf-cantidad input:hover { border-color: var(--pf-borde); }
.pvf-cantidad input:focus,
.pvf-var:focus { outline: none; border-color: var(--pf-azul); background: #fff; box-shadow: 0 0 0 3px rgba(35, 84, 143, .12); }
.pvf-var {
    width: 76px; height: 36px; padding: 0 .55rem; border: 1px solid var(--pf-borde); border-radius: 8px; background: #fff;
    text-align: right; -moz-appearance: textfield;
}
.pvf-cantidad input::-webkit-inner-spin-button, .pvf-var::-webkit-inner-spin-button,
.pvf-cantidad input::-webkit-outer-spin-button, .pvf-var::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pvf-descuento { color: var(--pf-azul) !important; }
.pvf-recargo { color: var(--pf-naranja) !important; }

.pvf-icono {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 8px; background: transparent; color: #9ca3af; font-size: .9rem;
}
.pvf-icono:hover { background: #f3f4f6; color: var(--pf-texto); }
.pvf-icono-quitar:hover { background: #fee2e2; color: var(--pf-rojo); }

/* Celular: un renglón por tarjeta */
.pvf-item-movil { padding: .8rem 1rem; border-top: 1px solid #f0f1f3; }
.pvf-item-movil:first-child { border-top: 0; }
.pvf-item-movil-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.pvf-item-movil-pie { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem .6rem; margin-top: .55rem; }
.pvf-item-movil-pie > strong { margin-left: auto; font-size: 1rem; }
.pvf-item-movil-dato { color: #4b5563; font-size: .9rem; }
.pvf-var-movil { display: inline-flex; align-items: center; gap: .35rem; margin: 0; color: var(--pf-atenuado); font-size: .78rem; white-space: nowrap; }
.pvf-var-movil .pvf-var { width: 64px; height: 32px; }

/* ── Totales y acciones ── */
.pvf-totales { margin: 0 0 1rem; }
.pvf-totales > div { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .3rem 0; font-size: .92rem; }
.pvf-totales dt { font-weight: 400; color: #4b5563; }
.pvf-totales dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pvf-totales .pvf-total { align-items: center; margin-top: .25rem; padding-top: .75rem; border-top: 1px solid var(--pf-borde); }
.pvf-totales .pvf-total dt { color: var(--pf-texto); font-weight: 600; }
.pvf-totales .pvf-total dd { font-size: 1.85rem; font-weight: 700; letter-spacing: -.01em; }
.pvf-acciones { display: flex; flex-direction: column; gap: .5rem; }
.pvf-acciones .pf-btn { width: 100%; }
.pvf-acciones .pf-btn-primario { height: 52px; border-radius: 12px; font-size: 1.05rem; }
.pvf-acciones-principal:empty { display: none; }

/* Barra fija del celular: el botón puede ocupar dos renglones */
.pvf-barra-movil .pf-btn { height: auto; min-height: 44px; padding: .4rem .9rem; white-space: normal; text-align: center; line-height: 1.2; }

@media (max-width: 1099.98px) {
    .pvf-layout { grid-template-columns: minmax(0, 1fr) 300px; }
    .pvf-col-precio { width: 108px; }
}

/* Tablet y celular: una columna; el cliente va arriba de los artículos */
@media (max-width: 991.98px) {
    .pvf-layout { display: flex; flex-direction: column; gap: 1rem; }
    .pvf-layout > * { width: 100%; }
    .pvf-lateral { display: contents; }
    .pvf-tarjeta-cliente { order: 1; }
    .pvf-carrito { order: 2; }
    .pvf-tarjeta-datos { order: 3; }
    .pvf-tarjeta-totales { order: 4; }
}

@media (max-width: 767.98px) {
    .pvf-agregar { grid-template-columns: 1fr 1fr; }
    .pvf-carrito .pf-tarjeta-cab-acciones { width: 100%; }
    .pvf-carrito .pf-tarjeta-cab-acciones .pf-btn { flex: 1 1 auto; }
    /* El botón principal ya está en la barra fija de abajo */
    .pvf-acciones-principal { display: none; }
    .pvf-tarjeta-totales { margin-bottom: .25rem; }
}
