:root{
  --primary:#6BBF59;
  --secondary:#3A5A40;
  --bg:#fff;
  --text:#111;
  --radius:16px;
  --space:8px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* ===== Header (mobile + layouts no-split) ===== */
.hdr{
  position:sticky;
  top:0;
  z-index:1000;
  background:#fff;
  border-bottom:1px solid #eee;
}
.hdr #header-img{
  display:block;
  width:100%;
  height:auto;
  max-height:320px;
  object-fit:cover;
}
@media (min-width: 900px){
  .hdr #header-img{ object-fit:contain; background:#fff; }
}

.wrap.mini{
  max-width:1200px;
  margin:0 auto;
  padding:8px 16px;
  display:flex;
  align-items:center;
}
#conn-status{
  margin-left:auto;
  font-size:12px;
  color:#666;
}
#conn-status-side{
  margin-left:auto;
  font-size:12px;
  color:#666;
}

.hidden{ display:none !important; }

/* ===== Main ===== */
main{
  max-width:1200px;
  margin:0 auto;
  padding:16px;
}

/* ===== Catálogo grid (mobile / no-split) ===== */
.grid{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:16px;
}
@media (max-width: 1199px){
  .grid{ grid-template-columns:repeat(2, 1fr); }
}
@media (max-width: 899px){
  .grid{ grid-template-columns:1fr; }
}

/* ===== Card (base) ===== */
.card{
  border:1px solid #e6e6e6;
  border-radius:var(--radius);
  overflow:hidden;             /* ok, pero NO vamos a fijar ratio alto */
  background:#fff;
  display:grid;
  grid-template-columns:3fr 2fr;
  min-height:240px;            /* clave: evita “aplastado” */
}

.card-img{ background:#f7f7f7; }
.card-img img{
  width:100%;
  aspect-ratio:1/1;            /* foto cuadrada */
  object-fit:cover;
  display:block;
}

.card-body{
  padding:14px;
  display:grid;
  grid-template-rows:auto 1fr auto;
  gap:8px;
  min-height:0;
}
.card-title{
  font-size:18px;
  margin:0;
}
.card-desc{
  font-size:13px;
  color:#555;
}

/* bottom: mobile y base */
.card-bottom{
  margin-top:auto;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
}
.card-price{ font-weight:700; }

.qty{
  display:inline-flex;
  gap:8px;
  align-items:center;
  border:1px solid #ddd;
  border-radius:999px;
  padding:4px 10px;
  width:max-content;
}
.qty button, .plus{
  border:0;
  background:#f1f5f0;
  border-radius:999px;
  padding:6px 10px;
  cursor:pointer;
  font-size:16px;
  line-height:1;
}
.plus{
  width:32px;
  height:32px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

/* Clamp de texto en desktop para que no “invada” el bottom */
@media (min-width: 900px){
  .card-title{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
  }
  .card-desc{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:3;
    overflow:hidden;
  }
}

/* ===== Resumen (mobile / no-split) ===== */
#resumen{
  position:sticky;
  bottom:0;
  background:#fff;
  border-top:1px solid #eee;
  padding:10px 16px;
}
#resumen-list{
  font-size:14px;
  color:#444;
  margin-bottom:6px;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.resumen-item{
  display:flex;
  justify-content:space-between;
  gap:12px;
}
.resumen-left{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.resumen-right{ font-weight:600; }
.resumen-empty{
  color:#666;
  font-size:13px;
  padding:4px 0;
}
#resumen .bar{
  display:flex;
  align-items:center;
  gap:12px;
}
.total-label{ opacity:.8; }
.total-money{ font-weight:700; }
#btn-confirmar{
  margin-left:auto;
  background:var(--primary);
  color:#fff;
  border:0;
  border-radius:12px;
  padding:10px 16px;
  cursor:pointer;
}
#btn-confirmar:disabled{ opacity:.5; cursor:not-allowed; }

/* ===== Auth Sheet ===== */
#auth-sheet{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding:16px;
  z-index:2000;
}
.sheet{
  width:100%;
  max-width:520px;
  background:#fff;
  border-radius:16px 16px 0 0;
  padding:16px;
  box-shadow:0 -6px 20px rgba(0,0,0,.15);
}
.field{ display:flex; flex-direction:column; gap:6px; margin:8px 0; }
.row{ display:flex; gap:8px; }
@media (max-width: 520px){ .row{ flex-direction:column; } }

input, textarea{
  width:100%;
  padding:10px;
  border:1px solid #ddd;
  border-radius:10px;
  font-size:16px;
}
textarea{ min-height:70px; }
.actions{ display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }
.btn{ border:0; border-radius:10px; padding:10px 14px; cursor:pointer; }
.btn.cancel{ background:#eee; }
.btn.primary{ background:var(--primary); color:#fff; }

/* ===== Ticket ===== */
#ticket{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:2500;
}
.ticket{
  width:100%;
  max-width:560px;
  background:#fff;
  border-radius:16px;
  padding:16px;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
}
#ticket-content{
  padding:16px;
  border:1px dashed #e0e0e0;
  border-radius:12px;
  background:#fafafa;
}
.tkt-head{ display:flex; gap:12px; align-items:center; margin-bottom:8px; }
#tkt-logo{ height:36px; display:none; }
.tkt-title h3{ margin:0; font-size:18px; }
.tkt-sub{ font-size:12px; color:#555; }
.tkt-info{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:8px 0 12px; }
.tkt-items{ display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.tkt-row{ display:flex; justify-content:space-between; gap:10px; border-bottom:1px dashed #e8e8e8; padding-bottom:6px; }
.tkt-left{ font-size:14px; }
.tkt-right{ font-size:14px; font-weight:600; }
.tkt-total{ display:flex; justify-content:space-between; gap:10px; font-size:16px; font-weight:700; margin-top:4px; }
.tkt-note{ margin-top:10px; font-size:12px; color:#666; }
.ticket-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:space-between;
  margin-top:12px;
}

/* ===== Closed ===== */
#closed{
  max-width:860px;
  margin:40px auto;
  padding:20px;
  border:1px dashed #c8e6c9;
  border-radius:16px;
  background:#fafdf9;
}
#closed h2{ margin:0 0 8px; font-size:22px; }
#closed p{ margin:0 0 12px; color:#444; }

/* ===== Toast ===== */
#toast{
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%);
  background:#222;
  color:#fff;
  padding:8px 12px;
  border-radius:10px;
  opacity:0;
  transition:opacity .2s;
  z-index:3000;
}
#toast.show{ opacity:1; }

/* ===== XS tweaks ===== */
@media (max-width: 360px){
  .card{ min-height:220px; }
  .card-title{ font-size:16px; }
  .qty button,.plus{ padding:5px 9px; font-size:15px; }
  .plus{ width:30px; height:30px; }
}

/* ==========================================================
   DESKTOP SPLIT 30/70 (solo PC real) — NO toca mobile
   ========================================================== */
.sidehdr{ display:none; }
.sidehdr-img{
  width:100%;
  aspect-ratio:1/1;
  overflow:hidden;
  background:#fff;
}
#header-img-side{
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;          /* recorte central */
  object-position:center 60%;/* un toque abajo para que “agarre” el logo */
}

@media (min-width: 1024px) and (hover:hover) and (pointer:fine){
  body{ overflow:hidden; }
  .hdr{ display:none; }

  main#app{
    position:fixed;
    inset:0;
    max-width:none;
    margin:0;
    padding:0;
    display:grid;
    grid-template-columns:30% 70%;
    background:var(--bg);
  }

  /* Columna derecha: catálogo scroll */
  #catalogo{
    grid-column:2;
    height:100%;
    overflow-y:auto;
    padding:16px;
    min-width:0;
    align-content:start;
  }

  /* 2 columnas y filas con mínimo (evita aplastado) */
  #catalogo.grid{
    grid-template-columns:repeat(2, 1fr) !important;
    grid-auto-rows:minmax(240px, auto);
  }

  /* Columna izquierda: 50% header, 50% carrito */
  #resumen{
    grid-column:1;
    height:100%;
    position:relative;
    bottom:auto;
    border-top:0;
    border-right:1px solid #eee;
    padding:0;
    background:#fff;

    display:grid;
    grid-template-rows:50% 1fr;
    overflow:hidden;
  }

  .sidehdr{
    display:block;
    border-bottom:1px solid #eee;
    overflow:hidden;
  }

  .resumen-pane{
    display:flex;
    flex-direction:column;
    overflow:hidden;
    min-height:0;
  }

  #resumen-list{
    padding:10px 16px;
    margin:0;
    overflow-y:auto;
    flex:1 1 auto;
    min-height:0;
  }

  #resumen .bar{
    padding:10px 16px;
    border-top:1px solid #eee;
    background:#fff;
    flex:0 0 auto;
  }

  /* CLAVE: en pantallas muy anchas, la foto NO crece infinito */
  .card{
    grid-template-columns:clamp(190px, 34%, 260px) 1fr;
    min-height:240px;
  }
}

/* Ultra-wide: 3 columnas en el catálogo */
@media (min-width: 1500px) and (hover:hover) and (pointer:fine){
  #catalogo.grid{ grid-template-columns:repeat(3, 1fr) !important; }
  .card{ grid-template-columns:clamp(180px, 33%, 235px) 1fr; }
}
