/*
 * Pedidos en línea (pedidos.js): el botón «Pide en línea» junto a la carta y la hoja de pedidos. Solo se carga en
 * negocios con pedidos. Usa los colores de cada sitio (variables de styles.css y del <style> del index.html). En
 * celular la hoja ocupa toda la pantalla; desde 600 px es una ventana centrada (como la hoja "Reservar").
 */

/* Botón junto a la carta */
.pd-cta { display: grid; justify-items: center; gap: 10px; margin-top: 22px; }
.pd-abrir { min-height: 56px; padding-inline: 28px; font-size: 1.08rem; }
.pd-cta-texto { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .92rem; font-weight: 600; }
.pd-cta-texto .icon { width: 1.15em; height: 1.15em; color: var(--accent-deep); flex: none; }

/* Hoja */
.pd {
  width: 100%; max-width: 100%; height: 100%; height: 100dvh; max-height: 100%; max-height: 100dvh;
  margin: 0; padding: 0; border: 0; overflow: hidden; background: var(--bg); color: var(--ink);
}
.pd[open] { display: flex; flex-direction: column; }
.pd::backdrop { background: rgb(var(--shade) / .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@media (min-width: 600px) {
  .pd {
    width: min(580px, calc(100vw - 48px)); height: fit-content; min-height: min(640px, calc(100vh - 48px));
    max-height: min(920px, calc(100vh - 48px)); max-height: min(920px, calc(100dvh - 48px));
    margin: auto; border-radius: 26px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .pd[open] { animation: pd-entra .24s ease-out; }
  @keyframes pd-entra { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
}
.pd-head {
  display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.pd-head-text { flex: 1; min-width: 0; padding-inline: 6px; }
.pd-kicker {
  color: var(--accent-deep); font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pd-title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.75rem; line-height: 1.1; }
.pd-title:focus { outline: none; }
.pd-back, .pd-close { flex: none; color: var(--ink); }
.pd-back:hover, .pd-close:hover { background: var(--bg-alt); }
.pd-back .icon, .pd-close .icon { width: 24px; height: 24px; }
.pd-bar { flex: none; height: 3px; background: var(--bg-alt); }
.pd-bar span { display: block; width: 0; height: 100%; background: var(--primary); transition: width .25s ease; }
.pd-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 28px; }
.pd-foot {
  flex: none; display: grid; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line);
}
@media (min-width: 600px) { .pd-body { padding: 18px 24px 28px; } .pd-foot { padding: 14px 24px 18px; } }
.pd .btn { text-decoration: none; }
.pd-grande { width: 100%; min-height: 60px; font-size: 1.08rem; }
.pd-grande:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.pd-pagar[aria-busy="true"] { opacity: .85; cursor: progress; }
.pd-ancho { width: 100%; margin-top: 14px; }

/* Categorías y productos */
.pd-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 4px; scrollbar-width: none; }
.pd-chips::-webkit-scrollbar { display: none; }
.pd-chip {
  flex: none; min-height: 42px; padding: 8px 16px; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer;
}
.pd-chip.pd-activa { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.pd-chips-cuando { flex-wrap: wrap; overflow: visible; }
.pd-cat {
  scroll-margin-top: 8px; margin: 18px 0 8px; color: var(--accent-deep); font-size: .82rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
}
.pd-lista { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.pd-prod {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface);
}
.pd-prod-con { border-color: var(--primary); }
.pd-prod-foto {
  flex: none; width: 72px; height: 72px; margin: -2px 0 -2px -4px; border-radius: 12px; object-fit: cover;
  background: var(--bg-alt);
}
.pd-prod-texto { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.pd-prod-nombre { font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.pd-prod-desc { color: var(--ink-soft); font-size: .86rem; line-height: 1.35; }
.pd-prod-precio { color: var(--price); font-weight: 800; font-variant-numeric: tabular-nums; }
.pd-cant { flex: none; display: flex; align-items: center; gap: 6px; }
.pd-agregar {
  min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--primary); border-radius: 12px;
  background: transparent; color: var(--ink); font-weight: 800; cursor: pointer;
}
.pd-agregar:hover { background: var(--primary); color: var(--on-primary); }
.pd-mas {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  font-size: 1.4rem; font-weight: 800; line-height: 1; cursor: pointer;
}
.pd-mas:disabled { opacity: .4; cursor: not-allowed; }
.pd-num { min-width: 1.6em; text-align: center; font-weight: 900; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

/* Opciones (entrega y pago) */
.pd-opciones { display: grid; gap: 10px; margin-bottom: 16px; }
.pd-opcion {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.pd-opcion.pd-activa { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.pd-opcion-icono {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--bg-alt); color: var(--accent-deep);
}
.pd-opcion-icono .icon { width: 24px; height: 24px; }
.pd-opcion.pd-activa .pd-opcion-icono { background: var(--primary); color: var(--on-primary); }
.pd-opcion-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pd-opcion-titulo { font-size: 1.05rem; font-weight: 800; }
.pd-opcion-sub { color: var(--ink-soft); font-size: .9rem; overflow-wrap: anywhere; }
.pd-opciones-pago { grid-template-columns: 1fr; }
@media (min-width: 480px) { .pd-opciones-pago { grid-template-columns: repeat(3, 1fr); } .pd-opciones-pago .pd-opcion { flex-direction: column; align-items: flex-start; } }

/* Campos */
.pd-sub { margin: 4px 0 10px; color: var(--accent-deep); font-weight: 800; }
.pd-campo { display: grid; gap: 6px; margin-bottom: 14px; }
.pd-etiqueta { font-weight: 700; font-size: .95rem; }
.pd-input {
  width: 100%; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem;
}
textarea.pd-input { min-height: 72px; resize: vertical; }
.pd-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: 14px; }
.pd-cel { display: grid; grid-template-columns: minmax(0, 150px) 1fr; gap: 8px; }
.pd-trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.pd-error {
  margin: 4px 0 10px; padding: 10px 14px; border-radius: 12px; background: #FDE8E4; color: #8A1F11; font-weight: 700;
}

/* Resumen y pago */
.pd-resumen { margin: 0 0 12px; padding: 4px 14px; list-style: none; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); }
.pd-res-fila { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.pd-res-fila:last-child { border-bottom: 0; }
.pd-res-cant { flex: none; min-width: 2.2em; color: var(--accent-deep); font-weight: 800; }
.pd-res-nombre { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pd-res-precio { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; }
.pd-res-total .pd-res-nombre, .pd-res-total .pd-res-precio { font-size: 1.15rem; font-weight: 900; }
.pd-entrega { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; color: var(--ink-soft); font-weight: 600; }
.pd-entrega .icon { flex: none; width: 1.3em; height: 1.3em; color: var(--accent-deep); }
.pd-prueba {
  display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 6px; padding: 12px 14px; border-radius: 14px;
  background: var(--note-bg); color: var(--ink); font-size: .92rem; line-height: 1.45;
}
.pd-prueba .icon { flex: none; width: 1.2em; height: 1.2em; margin-top: 2px; color: var(--accent-deep); }

/* Pedido recibido */
.pd-ok { display: grid; justify-items: center; gap: 6px; padding: 10px 0 16px; text-align: center; }
.pd-ok-icono { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--primary); color: var(--on-primary); }
.pd-ok-icono .icon { width: 38px; height: 38px; }
.pd-ok-numero { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 2rem; line-height: 1.1; }
.pd-ok-texto { max-width: 34ch; font-size: 1.08rem; font-weight: 700; }
.pd-pasos { margin: 6px 0 16px; padding: 0; list-style: none; display: grid; gap: 0; }
.pd-paso {
  position: relative; padding: 10px 0 10px 40px; color: var(--ink-soft); font-weight: 600;
}
.pd-paso::before {
  content: ""; position: absolute; left: 8px; top: 12px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface);
}
.pd-paso:not(:last-child)::after { content: ""; position: absolute; left: 17px; top: 32px; bottom: -10px; width: 2px; background: var(--line); }
.pd-hecho { color: var(--ink); }
.pd-hecho::before { border-color: var(--primary); background: var(--primary); }
.pd-ahora { color: var(--ink); font-weight: 800; }
.pd-ahora::before { border-color: var(--primary); box-shadow: 0 0 0 4px var(--tap); }
@media (prefers-reduced-motion: no-preference) { .pd-ahora::before { animation: pd-pulso 1.4s ease-in-out infinite; } }
@keyframes pd-pulso { 50% { box-shadow: 0 0 0 8px var(--tap); } }
.pd-pagado { color: var(--ink-soft); font-size: .92rem; text-align: center; }
