@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');



/* --------------------- ESTILOS GENERALES --------------------- */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

.encabezado {
    position: fixed;
    top: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffed00;
    padding: 0px 20px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.encabezado .logo img {
    width: 150px;
    height: auto;
}

.encabezado h1 {
    flex: 1;
    text-align: center;
    font-size: 30px;
    margin: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Roboto', sans-serif;
}

/* ----------- BÚSQUEDA DE COTIZACIÓN ----------- */
.buscar-cotizacion {
    display: flex;
    flex-direction: column;
    align-items: flex-start;  /* <- aquí el cambio */
    text-align: left;         /* <- asegura alineación interna */
    background-color: #fff;
    padding: 10px 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-family: Arial, sans-serif;
}

.texto-buscar { text-align: left; }

.texto-buscar p {
    font-size: 13px;
    color: #333;
    margin: 0 0 8px 0;
    font-weight: 500;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
    font-weight: bold;   
}

#form-buscar-cotizacion {
    display: flex;
    align-items: center;
    gap: 8px;
}

#form-buscar-cotizacion input {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 30px;
    font-size: 14px;
    width: 170px;
    outline: none;
    transition: all 0.3s ease;
}

#form-buscar-cotizacion input:focus {
    border-color: #007BFF;
    box-shadow: 0 0 6px rgba(0, 123, 255, 0.2);
}

#form-buscar-cotizacion button {
    background-color: #007BFF;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
}

#form-buscar-cotizacion button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}


#form-buscar-cotizacion button:hover {
    background-color: #0056b3;
}

/* --------------------- FILTROS --------------------- */
#productos {
    width: 68%;
    position: relative;
    padding-right: 12px;
}

.productos-header {
    position: sticky;
    top: 120px;
    background-color: #f5f5f5;
    padding: 10px 0 20px 0;
    text-align: center;
    z-index: 500;
    margin-bottom: 20px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}


#mostrar-productos {
    position: absolute;
    top: 50px;
    left: 0;
    padding: 10px 18px;
    border-radius: 5px;
    border: none;
    background-color: #28a745;
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    z-index: 600;
    transition: background-color 0.3s ease;
    display: none;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

#mostrar-empaque {
    position: absolute;
    top: 50px;
    right: 0;
    padding: 10px 18px;
    border-radius: 5px;
    border: none;
    background-color: #28a745;
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    z-index: 600;
    transition: background-color 0.3s ease;
    display: none;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

#mostrar-productos:hover,
#mostrar-empaque:hover {
    background-color: #218838;
}

.filtros-productos {
    text-align: center;
    margin-top: 10px;
}

.filtro-btn {
    background-color: #ffed00;
    color: #000;
    border: none;
    margin: 5px;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.filtro-btn:hover {
    background-color: #E6C931;
}

.filtro-btn.selected {
    background-color: #ccc;
    color: #333;
}

.search-container {
    margin-top: 15px;
    margin-bottom: 15px;
    text-align: center;
}

#barra-busqueda {
    width: 60%;
    max-width: 400px;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

#barra-busqueda:focus {
    border-color: #007BFF;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

/* --------------------- SECCIÓN PRODUCTOS Y CARRITO --------------------- */
main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 140px 20px 20px 20px;
    position: relative;
}

#productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.producto {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 230px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

.producto img {
    width: 100%;
    max-height: 90px;
    object-fit: contain;
    margin-bottom: 5px;
}

.producto p {
    margin: 4px 0;
    font-size: 14px;
}

.producto.sin-empaque {
    border: 2px solid red;
}

/* --------------------- BOTONES DE PRODUCTOS --------------------- */
.producto button {
    background-color: #007BFF;
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

.producto button:hover {
    background-color: #0056b3;
}

.producto button.agregado {
    background-color: #ccc;
    color: #333;
    cursor: default;
}

/* --------------------- SECCIÓN CARRITO --------------------- */
.carrito {
    width: 30%;
    position: sticky;
    top: 140px;
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    height: fit-content;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    max-height: 70vh;
    overflow-y: auto;
}

.carrito table {
    width: 100%;
    display: block;
    overflow-x: auto;
}

.carrito h2 {
    margin-top: 0;
    font-family: 'Roboto', sans-serif;
    font-weight: 500; /* Roboto Medium */
}

#carrito {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

#carrito th, #carrito td {
    border-bottom: 1px solid #ddd;
    padding: 5px;
    font-size: 13px;
    text-align: left;
}

#carrito input[type="number"] {
    width: 40px;
    padding: 3px;
    font-size: 12px;
}

#carrito th {
    background-color: #f0f0f0;
}

#totales {
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

#totales h3 {
    margin-top: 10px;
    font-size: 16px;
    color: #000;
}

/* --------------------- INTERRUPTOR EMPAQUE --------------------- */
.caja-empaque {
    border: 2px dashed green;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
    border-radius: 10px;
    background-color: #f8fff8;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

.caja-empaque p {
    margin: 0 0 8px 0;
    font-weight: bold;
}

#switch-empaque {
    transform: scale(1.5);
    cursor: pointer;
}

/* --------------------- BOTÓN PDF --------------------- */
#generar-pdf {
    background-color: #28a745;
    color: #fff;
    border: none;
    padding: 12px 25px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    width: 100%;
    opacity: 0.5;
    pointer-events: none;
    font-size: 16px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

#generar-pdf.enabled {
    opacity: 1;
    pointer-events: auto;
}

#generar-pdf:hover {
    background-color: #218838;
}

button {
    font-family: Arial, sans-serif;
}

/* --------------------- CAMPOS CLIENTE --------------------- */
.datos-cliente {
    margin-bottom: 25px;
}

.datos-cliente label {
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    font-weight: 500; /* Roboto Medium */
}

.datos-cliente input,
.datos-cliente select {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}

input.error {
    border: 2px solid red;
}

.doc-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

.doc-container select {
    width: 35%;
}

.doc-container input {
    width: 65%;
}

/* --------------------- BOTÓN BORRAR --------------------- */
.borrar-btn {
    background-color: #dc3545;
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400; /* Regular */
}

.borrar-btn:hover {
    background-color: #c82333;
}

/* --------------------- ANIMACIÓN AGREGAR --------------------- */
.fly-img {
    position: absolute;
    z-index: 9999;
    width: 80px;
    transition: all 1.2s ease;
    pointer-events: none;
    opacity: 1;
}

/* --------------------- RESPONSIVE --------------------- */
@media (max-width: 1024px) {
    main {
        flex-direction: column;
    }

    #productos {
        width: 100%;
    }

    .carrito {
        width: 100%;
        position: static;
        max-height: none;
        margin-top: 20px;
    }
}


/* ======= Modal bonito ======= */
.modal-wrapper {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: 'Montserrat', sans-serif;
}
.modal-wrapper.open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
}
.modal-dialog {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 20px 22px;
  width: min(420px, 92vw);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  animation: modalPop .18s ease-out;
}
@keyframes modalPop { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-dialog h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  letter-spacing: .2px;
}
.modal-dialog p { margin: 6px 0 16px; color: #444; line-height: 1.4; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn-primary, .modal-actions .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}
.modal-actions .btn-primary { background: #16a34a; color: #fff; }
.modal-actions .btn-primary:hover { filter: brightness(0.95); }
.modal-actions .btn-secondary { background: #e5e7eb; color: #111827; }

/* === Observaciones con el mismo look de los inputs === */
.datos-cliente #cliente-observaciones {
  width: 100%;
  height: 44px;          /* mismo alto visual que los inputs */
  min-height: 44px;      /* pisamos overrides anteriores */
  max-height: 120px;     /* si el usuario lo agranda, que no rompa el layout */
  padding: 10px 12px;    /* mismo padding */
  border: 1px solid #d1d5db;   /* mismo borde gris suave */
  border-radius: 8px;     /* mismo radio que los inputs */
  background: #fff;
  font: inherit;          /* misma fuente/tamaño de los inputs */
  line-height: 1.2;
  resize: vertical;       /* que se pueda agrandar si quiere escribir más */
  box-sizing: border-box;
  margin-top: 8px;        /* separación igual que los inputs */
}

.datos-cliente #cliente-observaciones::placeholder {
  color: #9ca3af;         /* mismo color de placeholder */
}

.datos-cliente #cliente-observaciones:focus {
  outline: none;
  border-color: #16a34a;                  /* mismo foco verde del resto */
  box-shadow: 0 0 0 4px rgba(22,163,74,.15);
}

/* ==== Modal para imagen grande ==== */
.img-modal {
  display: none;              /* toggled por .open */
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 4000; /* antes 2000 */
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.img-modal.open { display: flex; }

.img-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 16px;
  box-shadow: 0 10px 35px rgba(0,0,0,0.4);
}

.img-modal .img-close {
  position: absolute;
  top: 16px;
  right: 24px;
  font-size: 32px;
  color: #fff;
  cursor: pointer;
  user-select: none;
}

/* === CTA flotante: Ver totales y generar PDF === */
.cta-scroll {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2500;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 10px 24px rgba(22,163,74,.35);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  opacity: .95;
}
.cta-scroll:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(22,163,74,.45);
}
.cta-scroll.pulse {
  animation: pulse-cta 1.2s infinite;
}
@keyframes pulse-cta {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,.4); }
  70%  { box-shadow: 0 0 0 14px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

/* === Tooltip minimalista === */
.tooltip-bubble {
  position: fixed;
  z-index: 2600;
  background: rgba(0,0,0,.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.tooltip-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0,0,0,.85);
}

/* === Tooltip global fijo (debajo del botón) === */
.tooltip-fixed {
  position: fixed;
  z-index: 2600;
  background: rgba(0,0,0,.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
  white-space: normal;           /* permite salto de línea */
  word-break: break-word;
  max-width: min(80vw, 360px);   /* nunca se sale horizontalmente */
}

/* Compensa el header pegajoso al hacer scroll a "Total Final" */
#total-final-anchor {
  scroll-margin-top: 96px; /* ajusta si tu header es más alto/bajo */
}

/* Oculta elementos interactivos cuando hay modal */
.modal-active .cta-scroll { 
  display: none !important; 
}
.modal-active .tooltip-bubble,
.modal-active #tooltip-global {
  display: none !important;
}

/* Tarjeta de producto con botón siempre alineado */
#productos-grid { align-items: stretch; }     /* asegura alturas iguales por fila */

.producto{
  display: flex;
  flex-direction: column;
  height: 100%;
}

.producto img{
  height: 120px;               /* ajusta si usas otro alto */
  object-fit: contain;
  align-self: center;
}

/* Título con 2 líneas máximas, altura fija */
.producto .nombre{
  margin: 8px 0 4px;
  text-align: center;
  min-height: 44px;            /* ~2 líneas */
  max-height: 44px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;       /* limita a 2 líneas */
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* Precio compactado */
.producto .precio{
  text-align: center;
  margin: 0 0 12px;
}

/* Empuja el botón al fondo de la tarjeta */
.producto .agregar-btn{
  margin-top: auto;
}

/* Barra legal fija inferior */
#barra-legal{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #0f172a;          /* tono oscuro elegante */
  color: #ffffff;
  font-size: 12px;               /* delgadita */
  line-height: 1.3;
  padding: 8px 12px;             /* delgada pero legible */
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 -6px 16px rgba(0,0,0,0.2);
  word-wrap: break-word;
}

/* Altura de la barra legal (aprox). Ajusta si la haces más alta/baja */
:root{ --barra-legal-h: 56px; }



/* Si tu botón tenía otro bottom, ya no hace falta: lo reemplaza esta regla */


/* Evitar que el contenido quede tapado por la barra */
main, body{
  padding-bottom: 52px;          /* ajusta si tu contenido se queda muy cerca */
}

@media (max-width: 768px){
  #barra-legal{ font-size: 11px; padding: 10px 12px; }
  main, body{ padding-bottom: 64px; }
}
/* Elevar cualquier botón fijo que tenga esta clase */
.evita-barra-legal{
  position: fixed;                 /* si ya lo usas, se respeta */
  bottom: calc(16px + var(--barra-legal-h));
  /* z-index alto por si acaso */
  z-index: 10000;
}

/* ---- Espaciado y consistencia en la grilla de productos ---- */
#productos-grid{
  /* funciona con grid o flex (Chrome soporta gap en flex) */
  gap: 24px 20px;           /* fila / columna */
  row-gap: 24px;
  column-gap: 20px;
  /* Si tu contenedor no es grid y quieres forzar grid, descomenta: */
  /* display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); */
}

#productos-grid .producto{
  margin: 0;                /* evita márgenes que “pegan” filas */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;                /* separación interna estable */
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  height: 100%;
  overflow: hidden;         /* por si algo se sale */
}

#productos-grid .producto img{
  width: 100%;
  height: 160px;            /* uniforma altura de imagen */
  object-fit: contain;
  display: block;
}

#productos-grid .producto p{
  margin: 0;                /* evita colapsos de margen */
  text-align: center;
  line-height: 1.25;
}

/* El botón siempre queda al fondo sin pisar la tarjeta de abajo */
#productos-grid .producto .agregar-btn{
  margin-top: auto;
}

#productos-grid .producto picture { display:block; }
#productos-grid .producto img {
  display:block;
  width:100%;
  height:auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  content-visibility: auto;
  contain-intrinsic-size: 600px 600px;
}

/* Ajuste de tamaño de imagen en las tarjetas */
#productos-grid .producto picture { display:block; }

#productos-grid .producto img {
  display:block;
  width:100%;
  height:auto;
  /* imágenes menos altas y sin recorte */
  aspect-ratio: 4 / 3;       /* antes era 1/1: hacía la tarjeta más alta */
  object-fit: contain;       /* evita cortar etiquetas/fotos */
  background:#fff;
  border-radius: 10px;
  padding: 6px;              /* pequeño respiro al borde de la foto */
}

/* Título con 2 líneas y puntos suspensivos */
#productos-grid .producto .nombre {
  margin: 8px 0 4px;
  font-size: .95rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;     /* usa 3 si quieres una línea más */
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.25em * 2);  /* reserva alto para 2 líneas */
}

/* Fuerza visibilidad inmediata en las primeras N tarjetas */
#productos-grid .producto:nth-child(-n+12) img {
  content-visibility: visible;
  contain-intrinsic-size: auto;
}
