/* ============================================================
   Fuerza de Venta — refinamientos mobile-first
   Se carga después de adminlte.css y milking-theme.css.
   La mayoría de reglas viven dentro de @media (max-width:767.98px)
   para NO alterar la vista de escritorio.
   ============================================================ */

/* Nunca permitir scroll horizontal de toda la página.
   Las tablas anchas scrollean dentro de su .table-responsive. */
html, body { overflow-x: hidden; }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ---------- Teléfonos / tablets en vertical (<768px) ---------- */
@media (max-width: 767.98px) {

  /* Aprovechar el ancho: menos padding lateral */
  .content-wrapper .content,
  .content-header,
  .container-fluid { padding-left: .6rem; padding-right: .6rem; }
  .card-body { padding: .75rem; }

  /* Títulos más compactos */
  .content-header h1,
  .content-wrapper h1 { font-size: 1.35rem; }
  .content-header .col-sm-6,
  .content-header .col-sm-7 { max-width: 100%; flex: 0 0 100%; }

  /* Tarjetas separadas y a todo el ancho */
  .card { margin-bottom: .75rem; }

  /* Formularios: controles a todo el ancho y objetivos táctiles ≥44px */
  .form-control,
  .custom-select,
  .input-group-text,
  .select2-selection--single { min-height: 44px !important; font-size: 1rem; }
  .form-group label { font-weight: 600; margin-bottom: .25rem; }

  /* Botones: cómodos para el dedo */
  .btn { min-height: 44px; padding-top: .55rem; padding-bottom: .55rem; }
  .btn-sm { min-height: 38px; }
  /* Grupos de botones/toolbars se apilan a todo el ancho */
  .btn-toolbar > .btn,
  .form-actions > .btn { width: 100%; margin: 0 0 .5rem 0; }

  /* Select2 siempre a todo el ancho */
  .select2-container { width: 100% !important; }

  /* Tarjetas de resumen (small-box) más contenidas */
  .small-box .inner h3 { font-size: 1.9rem; }
  .small-box .icon { display: none; }

  /* Tablas: texto que respira; los precios/acciones no se parten */
  .table td, .table th { vertical-align: middle; }
  .table td.text-right, .table th.text-right,
  .table td .btn { white-space: nowrap; }

  /* Modales a pantalla casi completa */
  .modal-dialog { margin: .5rem; }

  /* Herramientas del card-header (buscador + filtro del catálogo) a lo ancho */
  .card-header .card-tools { position: static; float: none; width: 100%; flex-wrap: wrap; gap: 6px; margin-top: .5rem; }
  .card-header .card-tools > input,
  .card-header .card-tools > select { width: 100% !important; }

  /* Ocultar el footer de copyright para ganar espacio */
  .main-footer { padding: .5rem 1rem; font-size: .75rem; }
}

/* ---------- Accesos rápidos compactos (.fv-tile) ----------
   Alternativa al small-box de AdminLTE, que es muy alto (~130px).
   Una sola línea: ícono · etiqueta · número · flecha (~56px de alto).
   Apilados en celular ocupan menos que una sola caja de las viejas. */
.fv-tile {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 56px;
  padding: .5rem .75rem;
  margin-bottom: .5rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .35rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  color: #343a40;
  text-decoration: none;
  transition: background .15s ease, box-shadow .15s ease;
}
.fv-tile:hover,
.fv-tile:focus {
  background: #f8f9fa;
  color: #343a40;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.09);
}
.fv-tile-icon {
  flex: 0 0 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
}
.fv-tile-text  { flex: 1 1 auto; min-width: 0; }
.fv-tile-label { font-weight: 600; font-size: .98rem; line-height: 1.2; }
.fv-tile-sub   { display: block; font-size: .75rem; color: #6c757d; }
.fv-tile-num   { font-size: 1.35rem; font-weight: 700; line-height: 1; }
.fv-tile-go    { flex: 0 0 auto; color: #adb5bd; font-size: .8rem; }

/* ---------- Listado de clientes del vendedor (.fv-cli) ----------
   Cada cliente es una tarjeta que se despliega al tocarla y ofrece
   dos acciones: ver sus datos o hacer un pedido a una sucursal. */
.fv-cli {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .35rem;
  margin-bottom: .5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  overflow: hidden;
}
.fv-cli-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  min-height: 58px;
  padding: .55rem .75rem;
  background: none;
  border: 0;
  text-align: left;
  color: #343a40;
}
.fv-cli-head:hover,
.fv-cli-head:focus { background: #f8f9fa; outline: none; }
.fv-cli-info { flex: 1 1 auto; min-width: 0; }
.fv-cli-nom {
  display: block;
  font-weight: 600;
  font-size: .98rem;
  line-height: 1.25;
}
.fv-cli-meta {
  display: block;
  font-size: .75rem;
  color: #6c757d;
}
.fv-cli-meta code { font-size: .72rem; color: #495057; }
.fv-cli-suc { flex: 0 0 auto; font-weight: 600; }
.fv-cli-go {
  flex: 0 0 auto;
  color: #adb5bd;
  font-size: .8rem;
  transition: transform .18s ease;
}
.fv-cli.abierto .fv-cli-go { transform: rotate(180deg); }

/* El cuerpo solo existe cuando la tarjeta está abierta. */
.fv-cli-body { display: none; padding: .25rem .75rem .75rem; border-top: 1px solid #eceff1; }
.fv-cli.abierto .fv-cli-body { display: block; }
.fv-cli-body .btn { margin-top: .5rem; }

/* Sucursales: segundo nivel, se despliega desde "Hacer pedido por sucursal". */
.fv-suc { display: none; margin-top: .5rem; }
.fv-suc.abierto { display: block; }
.fv-suc-tit {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6c757d;
  margin-bottom: .35rem;
}
/* Es un <button> dentro de un form (crear el pedido es un POST, no un enlace),
   así que hay que anular los estilos propios del botón. */
.fv-suc-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  min-height: 48px;
  padding: .45rem .6rem;
  margin-bottom: .35rem;
  border: 1px solid #e0e0e0;
  border-left: 3px solid #012A78;
  border-radius: .3rem;
  background: #fbfcfd;
  color: #343a40;
  font: inherit;
  text-align: left;
  text-decoration: none;
}
.fv-suc-item:hover,
.fv-suc-item:focus { background: #eef3fb; color: #343a40; text-decoration: none; }
.fv-suc-txt { flex: 1 1 auto; min-width: 0; }
.fv-suc-alias { display: block; font-weight: 600; font-size: .9rem; line-height: 1.2; }
.fv-suc-txt small { display: block; color: #6c757d; font-size: .74rem; }

/* ---------- Toma de pedido (.fv-prod) ----------
   Una fila por producto: nombre y precio a la izquierda, y a la derecha la
   unidad y el contador. Todo el catálogo cabe en una pantalla que se recorre. */
.fv-prod {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .65rem;
  margin-bottom: .35rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .35rem;
}
.fv-prod.elegido {
  border-color: #012A78;
  background: #f3f7ff;
  box-shadow: inset 3px 0 0 #012A78;
}
.fv-prod-info { flex: 1 1 auto; min-width: 0; }
.fv-prod-nom  { display: block; font-weight: 600; font-size: .92rem; line-height: 1.25; }
.fv-prod-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 .25rem;
  font-size: .75rem;
  color: #6c757d;
}
.fv-prod-precio { font-weight: 600; color: #2e7d32; }

/* Marca del producto. Mientras no haya archivo de logo en dist/img/marcas/ se
   muestra el nombre; al colocarlo, fv_marca_chip() sirve la imagen sin más. */
.fv-marca {
  display: inline-block;
  padding: 0 .3rem;
  margin-right: .25rem;
  border-radius: 3px;
  background: #6c757d;
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.fv-marca-los-andes { background: #0a4d9e; }
.fv-marca-silsa     { background: #c62828; }
.fv-marca-paturrita { background: #ef6c00; }

.fv-marca-logo {
  height: 14px;
  width: auto;
  max-width: 54px;
  margin-right: .3rem;
  object-fit: contain;
  vertical-align: -2px;
}

.fv-prod-ctrl { flex: 0 0 auto; display: flex; align-items: center; gap: .25rem; }

/* Selector de línea: refrigerado y ambiente son cadenas de frío distintas. */
.fv-lineas { display: flex; gap: .35rem; }
.fv-linea-btn {
  flex: 1 1 0;
  min-height: 38px;
  padding: .35rem .5rem;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  background: #fff;
  color: #495057;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fv-linea-btn:hover { background: #f1f3f5; }
.fv-linea-btn.activa { background: #012A78; border-color: #012A78; color: #fff; }

/* Acordeón de dos niveles: línea → categoría → productos. Todo cerrado al
   entrar, para que el catálogo de 68 productos quepa de un vistazo. */
.fv-grupo-tit,
.fv-cat-tit {
  display: flex;
  align-items: center;
  gap: .4rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: .25rem;
}

/* Nivel 1 — línea (Refrigerado / Ambiente) */
.fv-grupo { margin-bottom: .4rem; }
.fv-grupo-tit {
  min-height: 46px;
  padding: .4rem .65rem;
  background: #eef1f6;
  border-left: 3px solid #012A78;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #012A78;
}
.fv-grupo-tit:hover { background: #e3e9f3; }
.fv-grupo-nom { flex: 1 1 auto; min-width: 0; }
/* Poca sangría a propósito: cada nivel le quita ancho al nombre del producto,
   que es lo que el vendedor lee. La jerarquía ya se ve por color y tamaño. */
.fv-grupo-body { display: none; padding-left: .2rem; }
.fv-grupo.abierto > .fv-grupo-body { display: block; }

/* Nivel 2 — categoría */
.fv-cat { margin: .3rem 0; }
.fv-cat-tit {
  min-height: 42px;
  padding: .35rem .6rem;
  background: #fff;
  border: 1px solid #dee2e6 !important;
  font-size: .8rem;
  font-weight: 600;
  color: #343a40;
}
.fv-cat-tit:hover { background: #f8f9fa; }
.fv-cat-nom { flex: 1 1 auto; min-width: 0; }
.fv-cat-body { display: none; padding: .35rem 0 .1rem .2rem; }
.fv-cat.abierto > .fv-cat-body { display: block; }

/* Contadores y estado */
.fv-grupo-n, .fv-cat-n {
  flex: 0 0 auto;
  background: #adb5bd;
  color: #fff;
  border-radius: 10px;
  padding: 0 .45rem;
  font-size: .68rem;
  font-weight: 700;
}
.fv-grupo-n { background: #012A78; }
/* Cuántos productos elegidos hay dentro: se ve aunque esté cerrado. */
.fv-elegidos {
  flex: 0 0 auto;
  background: #2e7d32;
  color: #fff;
  border-radius: 10px;
  padding: 0 .45rem;
  font-size: .68rem;
  font-weight: 700;
}
.fv-elegidos::before { content: '✓ '; }
.fv-cat.con-elegidos > .fv-cat-tit { border-color: #2e7d32 !important; background: #f4faf5; }

.fv-chev { flex: 0 0 auto; font-size: .7rem; opacity: .55; transition: transform .18s ease; }
.fv-grupo.abierto > .fv-grupo-tit .fv-chev,
.fv-cat.abierto   > .fv-cat-tit   .fv-chev { transform: rotate(180deg); }

/* Botón de unidad: caja o unidad suelta. */
.fv-uni-btn, .fv-uni-fija {
  min-width: 46px;
  height: 34px;
  padding: 0 .35rem;
  border-radius: .25rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fv-uni-btn  { border: 1px solid #012A78; background: #fff; color: #012A78; }
.fv-uni-btn:hover { background: #012A78; color: #fff; }
.fv-uni-fija { border: 1px dashed #ced4da; background: #f8f9fa; color: #868e96; }

/* Contador: objetivos de 34px, cómodos para el pulgar sin ocupar toda la fila. */
.fv-paso {
  width: 34px;
  height: 34px;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  background: #f8f9fa;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  color: #343a40;
  padding: 0;
}
.fv-paso:hover { background: #e9ecef; }
.fv-cant {
  width: 52px;
  height: 34px;
  text-align: center;
  font-weight: 700;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  padding: 0 .15rem;
}
/* Ocultar las flechitas nativas: ya hay botones −/+ */
.fv-cant::-webkit-outer-spin-button,
.fv-cant::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fv-cant[type=number] { -moz-appearance: textfield; }

/* En celular el nombre manda: el control se mantiene compacto. */
@media (max-width: 380px) {
  .fv-prod { gap: .35rem; padding: .45rem .5rem; }
  .fv-uni-btn, .fv-uni-fija { min-width: 40px; }
  .fv-cant { width: 44px; }
}

/* ---------- Encabezado de sección y estado vacío ----------
   Comunes a las pantallas del vendedor, para que se lean como una sola. */
.fv-seccion {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6c757d;
  margin: .75rem 0 .4rem;
}
.fv-vacio {
  text-align: center;
  color: #6c757d;
  padding: 1.75rem 1rem;
  background: #fff;
  border: 1px dashed #dee2e6;
  border-radius: .35rem;
}

/* ---------- Pedidos recientes (.fv-venta) ----------
   Misma fila-tarjeta que el catálogo, con el cliente como dato principal. */
.fv-venta {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 58px;
  padding: .5rem .65rem;
  margin-bottom: .35rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .35rem;
  color: #343a40;
  text-decoration: none;
}
.fv-venta:hover,
.fv-venta:focus { background: #f8f9fa; color: #343a40; text-decoration: none; }
.fv-venta-txt  { flex: 1 1 auto; min-width: 0; }
.fv-venta-cli  {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  line-height: 1.25;
  /* El nombre del cliente puede ser largo: se recorta antes que romper la fila. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fv-venta-meta  { display: block; font-size: .74rem; color: #6c757d; }
.fv-venta-der   { flex: 0 0 auto; text-align: right; }
.fv-venta-total { display: block; font-weight: 700; font-size: .9rem; }

/* ---------- Barra de acción fija inferior (opt-in) ----------
   Añadir class="fv-action-bar" a un contenedor de botones para
   dejarlo pegado abajo (útil en el formulario de pedido). */
.fv-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 1020;
  background: #fff;
  border-top: 1px solid #dee2e6;
  padding: .6rem .75rem;
  box-shadow: 0 -2px 8px rgba(0,0,0,.07);
  margin-left: -.6rem;
  margin-right: -.6rem;
}
