/* cart.css (exclusivo para cart.html) */
:root{
  --primary:#2563EB;
  --dark:#0F172A;
  --light:#F9FAFB;
  --gray:#64748B;
  --shadow: 0 10px 30px rgba(2,6,23,.08);
  --radius: 16px;

  /* footer compacto */
  --footerSafe: 96px; /* altura base aproximada (se ajusta con wrap) */
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--light);
  color: var(--dark);
  overflow-x:hidden;

  /* ✅ Menos espacio “por si acaso”, pero con safe-area */
  padding-bottom: calc(var(--footerSafe) + env(safe-area-inset-bottom, 0px));
}

/* Topbar */
.topbar{
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15,23,42,.08);
}
.topbar-inner{
  max-width: 1050px;
  margin: 0 auto;
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}
.topbar-left{ display:flex; align-items:center; gap: 12px; min-width: 0; }
.back-btn{
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.10);
  background: white;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
}
.title-wrap{ min-width:0; }
.title{ margin:0; font-size: 1.05rem; font-weight: 900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.subtitle{ margin:2px 0 0; color: var(--gray); font-size: .82rem; font-weight: 600; }

.page{ max-width: 1050px; margin: 0 auto; padding: 16px; }

/* Cart groups/items */
.tenant-group{
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15,23,42,.06);
  margin-bottom: 14px;
}
.tenant-header{
  display:flex; align-items:center; gap: 10px;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid rgba(15,23,42,.06);
  font-weight: 900;
}
.tenant-header i{ color: var(--primary); }

.cart-item{
  display:flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(15,23,42,.08);
}
.cart-item:last-child{ border-bottom:none; }

.item-img{
  width: 74px; height: 74px;
  border-radius: 14px;
  background: #EEF2F7;
  overflow:hidden;
  border: 1px solid rgba(15,23,42,.06);
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.item-img img{ width:100%; height:100%; object-fit:cover; display:block; }

.item-details{ flex:1; min-width:0; }
.item-name{
  margin: 0 0 4px;
  font-weight: 900;
  font-size: .95rem;
  line-height: 1.25;
  overflow:hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.item-price{ color: var(--primary); font-weight: 900; }

.qty-control{
  display:flex; align-items:center; gap: 10px;
  margin-top: 10px;
  background: #F1F5F9;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.06);
  width: fit-content;
}
.qty-btn{
  border:none;
  background:transparent;
  cursor:pointer;
  font-weight: 900;
  padding: 2px 8px;
  font-size: 1rem;
  user-select:none;
}
.qty-val{ font-weight: 900; min-width: 22px; text-align:center; }

.delete-btn{
  width: 40px; height: 40px;
  border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  color:#EF4444;
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.18);
  flex-shrink:0;
  align-self:center;
}

/* Empty */
.empty-cart{
  text-align:center;
  padding: 38px 18px;
  color: var(--gray);
  background: white;
  border: 1px solid rgba(15,23,42,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-cart i{ font-size: 3.2rem; opacity:.25; margin-bottom: 10px; display:block; color: var(--dark); }
.empty-cart h3{ margin:0 0 6px; color: var(--dark); font-weight: 900; }
.empty-cart p{ margin:0 0 14px; }

/* Botón inline para el empty state */
.btn-inline{
  display:inline-flex;
  gap:8px;
  align-items:center;
}

/* ✅ Bottom bar (más discreto) */
.bottom-bar{
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 -10px 30px rgba(2,6,23,.06);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-inner{
  max-width: 1050px;
  margin: 0 auto;
  padding: 8px 16px;          /* ✅ menos alto */
  display:flex;
  align-items:center;         /* ✅ centrado */
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;            /* wrap solo cuando haga falta */
}

/* ⏰ Banner horario */
.closed-banner{
  margin: 12px auto 12px;
  width: min(980px, 92vw);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #1f2937;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 6px 14px rgba(0,0,0,.08);
}
.closed-banner .title{
  font-weight: 900;
  margin-bottom: 4px;
}
.closed-banner .msg{
  color: #374151;
  font-size: .9rem;
}
.closed-banner .tenants{
  margin-top: 6px;
  color: #111827;
  font-size: .9rem;
  font-weight: 800;
}
.closed-banner .next{
  color: #6b7280;
  font-size: .9rem;
  margin-top: 4px;
}

/* Seleccion parcial */
.selection-bar{
  margin: 10px auto 12px;
  width: min(980px, 92vw);
  background: #ffffff;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 12px;
  padding: 10px 12px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.selection-actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
}
.selection-info{
  color: var(--gray);
  font-size: .85rem;
  font-weight: 800;
}
.item-select{
  margin-top: 6px;
  display:flex;
  align-items:center;
  gap: 8px;
  font-size: .85rem;
  font-weight: 800;
  color: #0f172a;
}
.item-select input{
  width: 16px;
  height: 16px;
}

.checkout-panel{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 140px;
}
.checkout-card{
  background: #ffffff;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.checkout-head h3{
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}
.checkout-head p{
  margin: 6px 0 0;
  color: var(--gray);
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.45;
}
.checkout-muted{
  color: var(--gray);
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.5;
}
.payment-methods{
  margin-top: 12px;
  display:grid;
  gap: 10px;
}
.payment-tenant-group{
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 16px;
  padding: 12px;
  background: #f8fafc;
  display:grid;
  gap: 10px;
}
.payment-tenant-group-warn{
  background: rgba(248, 250, 252, .7);
}
.payment-group-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.payment-group-head strong{
  font-size: .92rem;
  font-weight: 900;
  color: var(--dark);
}
.payment-group-head span{
  color: var(--gray);
  font-size: .8rem;
  font-weight: 800;
}
.payment-group-options{
  display:grid;
  gap: 10px;
}
.payment-method{
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  display:flex;
  align-items:flex-start;
  gap: 10px;
  cursor:pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.payment-method:hover{
  border-color: rgba(37,99,235,.28);
  transform: translateY(-1px);
}
.payment-method.active{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 10px 22px rgba(37,99,235,.10);
  background: rgba(37,99,235,.04);
}
.payment-method input{
  margin-top: 3px;
  width: 17px;
  height: 17px;
}
.payment-method .icon{
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(37,99,235,.10);
  color: var(--primary);
  flex: 0 0 auto;
}
.payment-method .meta{
  min-width: 0;
}
.payment-method .meta strong{
  display:block;
  font-size: .92rem;
  font-weight: 900;
  color: var(--dark);
}
.payment-method .meta span{
  display:block;
  margin-top: 4px;
  color: var(--gray);
  font-size: .83rem;
  font-weight: 700;
  line-height: 1.45;
}
.payment-detail{
  margin-top: 12px;
  display:grid;
  gap: 10px;
}
.payment-tenant{
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  padding: 12px;
  background: #f8fafc;
}
.payment-tenant .name{
  font-weight: 900;
  color: var(--dark);
  margin-bottom: 6px;
}
.payment-method-label{
  color: var(--primary);
  font-size: .82rem;
  font-weight: 900;
  margin-bottom: 6px;
}
.payment-lines{
  display:grid;
  gap: 4px;
  color: #334155;
  font-size: .83rem;
  font-weight: 700;
  line-height: 1.45;
}
.payment-link{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(37,99,235,.22);
  background: rgba(37,99,235,.08);
  color: #0f172a;
  font-weight: 900;
  text-decoration: none;
}
.auth-checkout-box{
  margin-top: 12px;
  display:grid;
  gap: 12px;
}

.delivery-minirow{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}

.select{
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 12px;
  padding: 9px 12px;          /* ✅ un poco menor */
  background: white;
  font-weight: 900;
  outline:none;
  cursor:pointer;
}

.btn-ghost{
  border:1px solid rgba(15,23,42,.12);
  background:white;
  color: var(--dark);
  padding: 9px 12px;          /* ✅ un poco menor */
  border-radius: 12px;
  cursor:pointer;
  font-weight: 900;
  display:inline-flex;
  align-items:center;
  gap: 8px;
  white-space: nowrap;
}
.btn-icon{
  padding:8px 10px;
}

.pill{
  font-size: .78rem;
  font-weight: 900;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-ok{ color:#065F46; background:#ECFDF5; border-color:#A7F3D0; }
.pill-warn{ color:#B45309; background:#FFFBEB; border-color:#FDE68A; }

/* ✅ Fee note colapsable */
.fee-note{
  max-width: 520px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #fde68a;
  background: #fffbeb;
}
.fee-note summary{
  list-style:none;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;          /* ✅ compacto */
  font-size: .78rem;
  font-weight: 900;
  color:#b45309;
  user-select:none;
}
.fee-note summary::-webkit-details-marker{ display:none; }
.fee-note .fee-note-body{
  padding: 8px 10px;
  padding-top: 0;
  font-size: .78rem;
  font-weight: 900;
  color:#b45309;
}

/* Totales (compacto) */
.totals{
  display:flex;
  flex-direction:column;
  gap:2px;                    /* ✅ menos espacio */
  min-width: 210px;
  align-items:flex-end;
}
.trow{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  width: 100%;
  font-size:.82rem;
  color: var(--gray);
  font-weight: 800;
}
.trow b{ color: var(--dark); font-weight: 900; }
.trow.fee b{ color:#d97706; }
.trow.total{
  font-size: .95rem;
  color: var(--dark);
  margin-top: 1px;
}
.trow.total b{ font-size:1.18rem; letter-spacing: -.02em; }

.btn-pay{
  background: var(--dark);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 11px 14px;         /* ✅ un poco menor */
  font-weight: 900;
  cursor: pointer;
  display:inline-flex;
  align-items:center;
  gap: 10px;
  white-space: nowrap;
}
.btn-pay:disabled{ opacity:.55; cursor:not-allowed; }

/* Modal backdrop + sheet */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  padding: 12px;
}
.modal-backdrop.show{ display:flex; }

.modal-sheet{
  width: 100%;
  max-width: 560px;
  max-height: min(92vh, 780px);
  background: white;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.20);
  border: 1px solid rgba(15,23,42,.08);
  display:flex; flex-direction:column;
}
.modal-head{
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15,23,42,.08);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
  flex: 0 0 auto;
}
.modal-body{
  padding: 14px 16px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  overflow:auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-actions{
  display:flex; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(15,23,42,.08);
  flex: 0 0 auto;
  background: white;
}

.label-strong{ font-weight:900; color:#0F172A; }
.map-picked-text{ font-size:.86rem; color:#334155; font-weight:800; }

.btn-secondary{
  flex:1;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  color:#0F172A;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 900;
  cursor:pointer;
}
.btn-primary-solid{
  flex:1;
  background: var(--dark);
  color:white;
  border:none;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 900;
  cursor:pointer;
}
.btn-primary-solid:disabled{ opacity:.6; cursor:not-allowed; }
.modal-link{
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.result-sheet{
  max-width: 680px;
}

/* Map area */
#map-picker{
  width:100%;
  height: 42vh;
  min-height: 260px;
  max-height: 420px;
  background: #EEF2F7;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.08);
  overflow: hidden;
}

/* Desktop drawer */
@media (min-width: 900px){
  #map-modal.modal-backdrop{
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
    background: rgba(0,0,0,0.12);
  }
  #map-modal .modal-sheet{
    height: 100%;
    width: 440px;
    max-width: 440px;
    max-height: 100vh;
    border-radius: 0;
    border-left: 1px solid rgba(15,23,42,.10);
    box-shadow: -16px 0 50px rgba(0,0,0,0.20);
  }
  #map-picker{
    height: 52vh;
    max-height: 520px;
  }
}

/* ✅ En móvil: footer aún más compacto y sin “tres líneas gigantes” */
@media (max-width: 620px){
  :root{ --footerSafe: 104px; }

  .bottom-inner{
    padding: 8px 12px;
    gap: 8px;
  }

  /* totales en una sola fila (más discreto) */
  .totals{
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    min-width: auto;
  }
  .trow{
    width: auto;
    gap: 8px;
    font-size: .78rem;
  }
  .trow span{ display:none; } /* ✅ oculta labels */
  .trow b{ font-weight: 900; }
  .trow.total b{ font-size: 1.05rem; }
}

@media (max-width: 820px){
  .checkout-panel{
    grid-template-columns: 1fr;
  }
}

/* Util */
.hidden{ display:none !important; }

@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior:auto !important; transition:none !important; animation:none !important; }
}
