body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #fff;
  color: #333;
}

.navbar {
  background-color: #000;
  color: white;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-logo img {
  height: 40px;
}
.navbar-logo2 img {
  height: 80px;
}

.navbar-titulo {
  flex-grow: 1;
  text-align: center;
  font-size: 22px;
  font-weight: bold;
  color: white;
}

.carrito {
  font-size: 18px;
  cursor: pointer;
}

.contenedor {
  padding: 20px;
  max-width: 1200px;
  margin: auto;
}

.categoria {
  margin-bottom: 40px;
}

.titulo-categoria {
  font-size: 20px;
  font-weight: bold;
  color: #006699;
  border-bottom: 2px solid #ccc;
  margin-bottom: 15px;
  padding-bottom: 5px;
}

.grid-productos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.tarjeta-producto {
  background: white;
  border-radius: 12px;
  border: 1px solid #ccc;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.tarjeta-producto .encabezado {
  background-color: #f57c00;
  color: white;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  position: relative;
}

.tarjeta-producto .encabezado2 {
  background-color: #392a7f;
  color: white;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  position: relative;
}

.tarjeta-producto .variedades {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #424242;
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.tarjeta-producto .contenido {
  display: flex;
  justify-content: center; /* Centra horizontalmente */
  align-items: center;     /* Centra verticalmente */
  padding: 10px;
  height: 150px;           /* Fijás altura para lograr centrado */
}

.imagen-producto {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.precio {
  font-size: 18px;
  font-weight: bold;
  color: #000;
}

.tarjeta-producto .descripcion {
  padding: 0 10px 10px 10px;
  font-size: 12px;
  color: #555;
  border-top: 1px solid #ddd;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  z-index: 3000;
  overflow-y: auto;
  padding: 30px 0;
}

.modal-content {
  margin: auto;
  background: #fff;
  padding: 20px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px; right: 15px;
  font-size: 18px;
  cursor: pointer;
  color: #333;
}

.modal-content h2 {
  margin-top: 0;
  color: #333;
}

.modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.modal-content td {
  padding: 8px 10px;
  border-bottom: 1px solid #ddd;
}

.modal-content td:first-child {
  font-weight: bold;
  width: 40%;
}


.tabla-carrito {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabla-carrito table {
  width: 80%;
  border-collapse: collapse;
}


.tabla-carrito td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: left;
}
.tabla-carrito th {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: center;
}


.btn-cant {
  width: 30px;
  padding: 4px;
  margin: 0 4px;
  font-size: 14px;
  cursor: pointer;
}

.qty-input {
  width: 50px;
  text-align: center;
}

.btn-agregar {
  margin-top: 15px;
  padding: 8px 16px;
  background-color: #ff9800;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-agregar:hover {
  background-color: #e68900;
}
/* Panel carrito desplegable */
.carrito-panel {
  position: fixed;
  right: -400px;
  top: 0;
  width: 350px;
  height: 100%;
  background: #fff;
  box-shadow: -2px 0 5px rgba(0,0,0,0.2);
  transition: right 0.3s ease;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.carrito-panel.abierto {
  right: 0;
}

.carrito-header {
  padding: 15px;
  background: #ff9800;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cerrar-carrito {
  font-size: 24px;
  cursor: pointer;
}

.carrito-contenido {
  padding: 15px;
  overflow-y: auto;
  flex: 1;
}

.carrito-item {
  border-bottom: 1px solid #ddd;
  padding: 10px 0;
}

.carrito-item strong {
  display: block;
  margin-bottom: 4px;
}
/* Estilo responsive para celulares */
@media screen and (max-width: 768px) {
  .contenedor-tarjetas {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
  }

  .tarjeta {
      width: 90% !important;
      margin: 10px 0;
  }

  .tarjeta img {
      max-width: 100%;
      height: auto;
  }

  .nombre {
      font-size: 1.1em;
      text-align: center;
  }
}

/* ===== Modal mobile-friendly ===== */
@media (max-width: 576px) {
  /* Ocupa toda la pantalla en móviles (sin bordes) */
  #modal.modal {
    padding: 0;                 /* quita padding del overlay */
  }
  #modal .modal-content {
    width: 100%;
    max-width: none;
    height: 100vh;              /* vista completa */
    max-height: none;           /* ignora el 90vh anterior */
    margin: 0;                  /* centra ocupando toda la pantalla */
    border-radius: 0;           /* sin esquinas para look app */
    padding: 0;                 /* manejamos paddings por secciones */
    display: flex;
    flex-direction: column;
  }

  /* Respeta las “safe areas” (iPhone con notch, etc.) */
  #modal .modal-content {
    padding-top: calc(env(safe-area-inset-top, 0px));
    padding-bottom: calc(env(safe-area-inset-bottom, 0px));
  }

  /* Header fijo con sombra sutil */
  #modal .modal-header {
    position: sticky; top: 0;
    background: #fff; z-index: 1;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
  }
  #modal .modal-title {
    margin: 0; font-size: 16px; font-weight: 700; color: #333; flex: 1;
  }

  /* Botón cerrar más grande y fácil de tocar */
  #modal .modal-close {
    position: static;           /* ya no absoluto */
    font-size: 22px;
    padding: 6px 10px;
    color: #333;
  }

  /* Cuerpo scrollable con fricción suave */
  #modal .modal-body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px 16px;
  }

  /* Footer fijo con acción principal */
  #modal .modal-footer {
    position: sticky; bottom: 0;
    background: #fff; z-index: 1;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    display: flex; gap: 8px; justify-content: flex-end;
  }

  /* Tablas dentro del modal: que ocupen todo y hagan scroll horizontal si hace falta */
  #modal .tabla-carrito { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #modal .tabla-carrito table { width: 100%; min-width: 560px; }

  /* Animación de entrada tipo “slide-up” */
  #modal[aria-hidden="false"] .modal-content {
    animation: modalSlideUp .22s ease-out;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(16px); opacity: .0; }
    to   { transform: translateY(0);    opacity: 1;  }
  }
}

/* Desktop: un toquecito de ancho y borde más marcado (opcional) */
@media (min-width: 577px) {
  #modal .modal-content {
    max-width: 720px;   /* puedes ajustar 640–900 */
    border-radius: 10px;
  }
}

/* Bloqueo de scroll del body cuando el modal está abierto */
body.modal-open {
  overflow: hidden;
  touch-action: none;
}


/* ===== Estilos generales útiles (opcionales) ===== */
#modal .tabla-carrito {
  width: 100%;
  border-collapse: collapse;
}
#modal .tabla-carrito th,
#modal .tabla-carrito td {
  border: 1px solid #eee;
  padding: 8px 10px;
}
#modal .tabla-carrito thead th {
  background: #f7f7f7;
}
/* Header "pegado" dentro de la scroll-area */
#modal .scroll-area thead th {
  position: sticky; top: 0; z-index: 1;
}

/* ===== Solo móviles en vertical ===== */
@media (max-width: 576px) and (orientation: portrait) {
  /* Ignora el width inline=1200px en móviles */
  #modal .modal-content {
    width: 100vw !important;     /* ← override al inline */
    height: 100vh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 0;                  /* manejamos paddings por secciones */
  }

  /* Close cómodo arriba a la derecha */
  #modal .modal-close {
    position: absolute;
    right: 10px; top: 8px;
    font-size: 24px;
    line-height: 1;
    background: transparent; border: 0;
  }

  /* Título y subtítulo, sin scroll */
  #modal #modal-titulo {
    margin: 0; padding: 12px 40px 10px 12px; /* deja lugar al close */
    font-size: 16px; font-weight: 700;
    border-bottom: 1px solid #eee;
    background: #fff;
  }
  #modal .titulo-categoria {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    font-weight: 600;
  }

  /* Barras de acción arriba/abajo, fijas visualmente (no scrollean) */
  #modal .barra-acciones {
    padding: 10px 12px;
    margin: 0 !important;             /* anulamos márgenes inline */
    background: #fff;
    border-top: 1px solid #eee;
  }

  /* SOLO la tabla scrollea y ocupa todo el espacio disponible */
  #modal .scroll-area {
    flex: 1;                           /* llena el alto libre del modal */
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* scroll suave iOS */
    padding: 10px 12px;                /* respiración lateral */
    background: #fff;
  }

  /* Si tu tabla es ancha, permití scroll horizontal */
  #modal .scroll-area .tabla-carrito { min-width: 520px; }

  /* Animación de entrada sutil */
  #modal[aria-hidden="false"] .modal-content {
    animation: modalSlideUp .22s ease-out;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
}

/* Bloquear scroll del body cuando el modal está abierto (opcional) */
body.modal-open {
  overflow: hidden;           /* mantiene el fondo fijo */
  /* touch-action: none;  ← eliminar esta línea */
}

/* Columna 1 = Código: más angosta y sin salto */
#modal .tabla-carrito th:nth-child(1),
#modal .tabla-carrito td:nth-child(1){
  width: 9ch;           /* ~7 caracteres */
  max-width: 12ch;       /* límite superior */
  white-space: nowrap;  /* no hacer salto de línea */
  overflow: hidden;     
  text-overflow: ellipsis; /* ... si se pasa */
  font-variant-numeric: tabular-nums; /* números alineados */
}

/* Columna 1 = Código: más angosta y sin salto */
#modal .tabla-carrito th:nth-child(2),
#modal .tabla-carrito td:nth-child(2){
  width: 40ch;           /* ~7 caracteres */
  max-width: 45ch;       /* límite superior */
  white-space: nowrap;  /* no hacer salto de línea */
  overflow: hidden;     
  text-overflow: ellipsis; /* ... si se pasa */
  font-variant-numeric: tabular-nums; /* números alineados */
}
