@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
  --font-principal: 'Inter', sans-serif;
  --sheet-footer-h: 96px;
}

body {
  font-family: var(--font-principal);
  background-color: var(--color-fondo);
  color: var(--color-texto);
}
html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* <- clave */
}
* { box-sizing: border-box; }


#catalogo {
  padding-bottom: 2rem;
  /* deja espacio para el botón flotante */
}

.grid-catalogo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

main {
  padding: 1rem;
  max-width: 100%;
}

.card {
  border: 1px solid #ccc;
  padding: 1rem;
  text-align: center;
}

.card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  /* cuadrado sin forzar 200px */
  object-fit: cover;
  border-radius: 8px;
}


/* Botón flotante */
.btn-float {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background-color: var(--color-primario);
  color: #0f172a;
  border: none;
  padding: 0.8rem 1rem;
  border-radius: 50px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 800;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}


@media (max-width: 480px) {
  .grid-catalogo {
    grid-template-columns: repeat(2, 1fr);
  }
}

.btn-remove {
  background: none;
  border: none;
  color: #cc0000;
  font-size: 1rem;
  margin-left: 0.5rem;
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

.btn-remove:hover {
  transform: scale(1.2);
  color: #990000;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.stepper button {
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
  background: #eee;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.stepper span {
  min-width: 20px;
  text-align: center;
  font-weight: bold;
}

.deslizador {
  background: linear-gradient(90deg, #ffffff, #e6f0ff, #ffffff);
  border: 1px solid var(--color-primario);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  user-select: none;
  touch-action: pan-y;
  cursor: grab;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  color: #004aad;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.05);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.deslizador:active {
  cursor: grabbing;
  box-shadow: 0 0 8px rgba(0, 74, 173, 0.3);
}


.filtros-container {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filtros-container select {
  padding: 0.5rem;
  font-size: 1rem;
}

.filtros-tipo {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filtros-tipo button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 4px;
  background: #eee;
  cursor: pointer;
  transition: background 0.2s ease;
}

.filtros-tipo button.activo {
  background-color: #004aad;
  color: white;
}

@media print {
  body * {
    visibility: hidden;
  }
  .btn-remove,
  .btn-float {
    display: none !important;
  }
}

/* Estilo temporal para impresión PDF */
.modo-pdf {
  position: static !important;
  width: 100% !important;
  height: auto !important;
  right: auto !important;
  background: white !important;
  padding: 1rem;
  box-shadow: none;
  border: none;
}

.boton {
  position: relative;
  padding: 0.8em 1.5em;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background-color: var(--color-primario);
  color: white;
  cursor: pointer;
  transition: background 0.3s ease;
}

.boton[disabled] {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.7;
}

.instrucciones {
  background: #f0f4ff;
  border-left: 4px solid var(--color-primario);
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  border-radius: 8px;
}
.instrucciones h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: #1a237e;
}

.boton.peligro {
  background-color: #ef6f6c;
  color: white;
}

@media (max-width: 480px) {
  .card {
    padding: 0.5rem;
    font-size: 0.9rem;
  }

  .card h3 {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    line-height: 1.2;
    word-break: break-word;
  }

  .card p {
    font-size: 0.85rem;
  }

  .boton {
    font-size: 0.9rem;
    padding: 0.6em 1.2em;
  }

  .btn-float {
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
  }

  .deslizador {
    max-width: 100%;
    padding: 0.4rem;
    font-size: 0.9rem;
    border-radius: 4px;
  }


  .card-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }

  .card-footer button {
    width: 100%;
    font-size: 0.9rem;
  }
}

.card.agregado {
  border: 2px solid var(--color-primario);
  box-shadow: 0 0 8px rgba(0, 74, 173, 0.4);
  transition: all 0.3s ease;
}

.catalogo-vacio {
  text-align: center;
  font-size: 1rem;
  color: #555;
  padding: 2rem 1rem;
  font-style: italic;
}

/* 🧾 Ítems tipo card en el resumen */
.item-resumen {
  background: #f8fafc;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-size: 0.95rem;
  color: #333;
}

.item-resumen .titulo {
  font-weight: 600;
  color: #111;
}

.item-resumen .fila {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #555;
}

.item-resumen .fila.total {
  font-weight: 600;
  color: var(--color-primario);
}

.item-resumen .acciones {
  text-align: right;
  margin-top: 0.5rem;
}

.item-resumen .btn-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 1rem;
  cursor: pointer;
}

/* FAB: oculto en escritorio */
@media (min-width: 768px) {
  #toggle-sidebar { display: none; }
}

/* Ocultar sidebar en móvil */
@media (max-width: 767.98px) {
  #sidebar { display: none !important; }
}

/* ===== Bottom Sheet ===== */
.sheet { position: fixed; inset: 0; z-index: 70; display: none; }
.sheet[aria-hidden="false"] { display: block; }

.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); }

.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 70vh; max-height: 80vh;
  background: #fff; border-top-left-radius: 18px; border-top-right-radius: 18px;
  box-shadow: 0 -12px 32px rgba(0,0,0,.25);
  display: grid; grid-template-rows: auto 1fr auto;
  transform: translateY(100%); transition: transform .25s ease;
}
.sheet[aria-hidden="false"] .sheet-panel { transform: translateY(0); }

.sheet-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid #eee; }
.sheet-header h2 { margin:0; font-size:16px; }
.sheet-close { background:transparent; border:0; font-size:20px; padding:6px; }

/* Cuerpo de la sheet: deja espacio real para el footer + margen */
.sheet-body {
  overflow: auto;
  padding: 12px 16px;
  padding-bottom: calc(var(--sheet-footer-h) + 12px + env(safe-area-inset-bottom));
}

/* Footer de la sheet */
.sheet-footer {
  position: sticky; /* puede ser sticky si prefieres, ver nota abajo */
  bottom: 0;
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
}


.btn-primario { background:#ffbe0b; color:#111; font-weight:700; border:0; padding:12px; border-radius:10px; }
.btn-secundario { background:#e8f5ee; color:#0f8f3a; font-weight:700; border:0; padding:12px; border-radius:10px; }

/* Bloquea scroll del fondo cuando la sheet está abierta */
.body-lock { overflow: hidden; }

/* Oculta el FAB cuando la sheet esté abierta (requiere que la sheet esté después del FAB en el DOM) */
.body-lock #toggle-sidebar { display: none !important; }

/* ==== Fila con borrar por hover (desktop) + swipe (móvil) ==== */
tr.tr-swipe {
  position: relative;
  touch-action: pan-y; /* permite scroll vertical */
  will-change: transform;
}

/* Icono tacho flotante (usamos fuente Material Icons por ligaduras) */
tr.tr-swipe::after {
  content: "";
}

/* Desktop (puntero fino): al hover muestra tacho y fondo rojo suave */
@media (pointer: fine) {
  tr.tr-swipe:hover {
    background: rgba(239, 68, 68, 0.20); /* más visible */
    cursor: pointer;
  }

  /* Oculta el precio en la última celda al hacer hover */
  tr.tr-swipe:hover td:last-child {
    position: relative; /* referencia para el ::after */
    color: transparent; /* oculta texto pero mantiene ancho */
  }

  /* Icono centrado en la celda TOTAL */
  tr.tr-swipe:hover td:last-child::after {
    content: "delete_outline";
    font-family: "Material Icons";
    font-size: 22px;
    color: #ef4444; /* rojo */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
    pointer-events: none;
  }
}

/* Móvil: durante el swipe mostramos fondo rojo e icono */
tr.tr-swipe.swiping {
  background: rgba(239, 68, 68, 0.10);
}
tr.tr-swipe.show-trash::after {
  content: "delete_outline";
  font-family: "Material Icons";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #ef4444;
  opacity: 0.95;
  pointer-events: none;
}

/* Animación al restaurar la fila tras swipe incompleto */
td.swipe-td-anim {
  transition: transform 160ms ease;
}

/* Nunca permitas desbordes horizontales en componentes de pantalla completa */
#catalogo, .sheet, .sheet-panel {
  max-width: 100vw;
  overflow-x: hidden;
}
img, video {
  max-width: 100%;
  height: auto;
  display: block; /* evita espacios inline raros */
}

/* Imágenes de producto: consistencia absoluta */
.card img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;          /* móvil por defecto */
  object-fit: cover;
  object-position: center;
  display: block;
}

@media (min-width: 768px) {
  .card img {
    aspect-ratio: 1 / 1;        /* desktop cuadrado */
  }
}

/* En móvil, cards con menos padding para ganar ancho útil */
@media (max-width: 767.98px) {
  .card { padding: 1rem; }      /* ya lo ajustamos con p-4 en JS; esto es refuerzo */
}

/* --- Cards en móvil --- */
@media (max-width: 767.98px) {
  /* Precio más grande y destacado */
  .card .precio {
    font-size: 1.6rem;  /* ~25px */
    color: #111;
  }

  /* Descripción más compacta */
  .card .descripcion {
    font-size: 0.78rem;   /* un poco más pequeña */
    color: #555;
    line-height: 1.3;
    margin-bottom: 0.5rem;
  }

  /* Clamp si no usas plugin de Tailwind */
  .card .descripcion {
    display: -webkit-box;
    -webkit-line-clamp: 2;   /* máximo 2 líneas */
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Handle de arrastre en la cabecera */
.sheet-grabber{
  width:44px; height:5px; border-radius:999px;
  background:#D1D5DB; /* gray-300 */
  margin:6px auto 6px; 
}

/* Evita que el overscroll del body cierre la sheet por rebote */
.sheet-body{
  overscroll-behavior-y: contain;  /* no propaga "pull" hacia el contenedor */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Pequeño feedback al arrastrar el panel (cuando lo movemos con JS) */
.sheet-panel.dragging{
  transition: none !important;
}

/* ====== Pulido visual de la sheet ====== */

/* Backdrop un poquito más suave y con blur */
.sheet-backdrop { background: rgba(0,0,0,.38); backdrop-filter: blur(3px); }

/* Panel con más radio y sombra más realista */
.sheet-panel{
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -18px 40px rgba(0,0,0,.28);
}

/* Header: título centrado, tipografía clara */
.sheet-header{
  padding: 10px 16px 6px; /* un pelín más compacto */
  border-bottom: 1px solid #eef2f7;
}
.sheet-header h2{
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a; /* slate-900 */
  letter-spacing: .2px;
  text-align: center;
  flex: 1;
}

/* Handle / grabber */
.sheet-grabber{
  width: 42px; height: 5px; border-radius: 999px;
  background: #d1d5db; margin: 4px auto 6px;
}

/* Cuerpo: scroll suave y padding consistente */
.sheet-body{
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 10px 14px;
  padding-bottom: calc(var(--sheet-footer-h) + 14px + env(safe-area-inset-bottom));
}

.sheet-body tbody td{
  padding: 10px 6px;
  vertical-align: middle;
}
.sheet-body tbody tr:nth-child(odd){ background: #fafafa; }
.sheet-body tbody tr:hover{ background: #f1f5f9; } /* leve hover */

/* Columna ITEM ocupa más, las otras compactas (móvil) */
@media (max-width: 767.98px){
  .sheet-body thead th:first-child,
  .sheet-body tbody td:first-child{ width: 52%; }
  .sheet-body thead th:nth-child(2),
  .sheet-body tbody td:nth-child(2){ width: 14%; text-align:center; }
  .sheet-body thead th:nth-child(3),
  .sheet-body tbody td:nth-child(3),
  .sheet-body thead th:nth-child(4),
  .sheet-body tbody td:nth-child(4){ width: 17%; text-align: right; }
}

/* Footer: separación visual, gradiente y sombra interior */
.sheet-footer{
  background: #fff;
  border-top: 1px solid #eef2f7;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.06) inset; /* inner */
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.sheet-footer::before{
  content:""; display:block; height:10px; margin:-12px -16px 8px -16px;
  background: linear-gradient(to top, rgba(0,0,0,0.06), rgba(0,0,0,0));
  border-top-left-radius: 20px; border-top-right-radius: 20px;
}

/* Botones: consistencia de tamaños y foco */
.sheet-footer button{
  font-weight: 700;
  border: 0;
}
.sheet-footer button:focus-visible{
  outline: 2px solid rgba(59,130,246,.85); outline-offset: 2px;
}

/* Ajustes de columnas en móvil para evitar desalineo */
@media (max-width: 767.98px){
  .sheet-body thead th:first-child,
  .sheet-body tbody td:first-child{ width: 52%; }
  .sheet-body thead th:nth-child(2),
  .sheet-body tbody td:nth-child(2){ width: 14%; text-align:center; }
  .sheet-body thead th:nth-child(3),
  .sheet-body tbody td:nth-child(3),
  .sheet-body thead th:nth-child(4),
  .sheet-body tbody td:nth-child(4){ width: 17%; text-align:right; }
}

.sheet-panel { overflow: hidden; }

.sheet-body {
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* === Encabezado normal (sin sticky) === */
.sheet-body table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.sheet-body thead th {
  /* sin position: sticky */
  background: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;   /* slate-500 */
  letter-spacing: .2px;
  padding: 10px 6px;
  box-shadow: none;
}

/* Línea divisoria bajo el encabezado (opcional) */
.sheet-body thead tr {
  border-bottom: 1px solid #e5e7eb;
}

/* Mantén tus reglas existentes: */
.sheet-body tbody td{ padding: 10px 6px; vertical-align: middle; }
.sheet-body tbody tr:nth-child(odd){ background: #fafafa; }
.sheet-body tbody tr:hover{ background: #f1f5f9; }
