/* =========================================================================
   Nueva en Papel — Estilos del cliente (Mobile First, pasteles)
   ========================================================================= */

:root {
  --bg:        #faf7fb;
  --surface:   #ffffff;
  --primary:   #b8a4e3;   /* lavanda */
  --primary-d: #9c83d6;
  --accent:    #ffb4a2;   /* coral pastel */
  --mint:      #b8e6d5;
  --ink:       #3a3550;
  --muted:     #8a849c;
  --line:      #efeaf4;
  --ok:        #5bbf9a;
  --danger:    #e8806f;
  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 6px 22px rgba(120, 100, 160, 0.12);
  --shadow-sm: 0 2px 10px rgba(120, 100, 160, 0.10);
  --bar-h:     76px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0));
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ------------------------------- Header -------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, var(--primary) 0%, #c9b6ec 100%);
  color: #fff;
  padding: 14px 16px 12px;
  border-radius: 0 0 22px 22px;
  box-shadow: var(--shadow-sm);
}
.app-header .brand {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.app-header .brand h1 { font-size: 1.25rem; font-weight: 700; margin: 0; letter-spacing: .2px; }
.app-header .brand a.track-link {
  font-size: .8rem; background: rgba(255,255,255,.22);
  padding: 7px 12px; border-radius: 999px; font-weight: 600;
}

.search-box { position: relative; }
.search-box input {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 13px 16px 13px 44px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.search-box input:focus { outline: 2px solid var(--primary-d); }
.search-box .icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  font-size: 1.1rem; opacity: .5;
}

/* ---------------------------- Chips categorías -------------------------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 14px 16px 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ------------------------------ Catálogo -------------------------------- */
.catalog {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 14px 16px;
}
@media (min-width: 560px) { .catalog { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .catalog { grid-template-columns: repeat(4, 1fr); max-width: 960px; margin: 0 auto; } }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .12s;
}
.card:active { transform: scale(.98); }
.card .thumb {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #f3eefb, #fdeef0);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb .ph { font-size: 2.2rem; opacity: .35; }
.card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .info .name { font-weight: 600; font-size: .92rem; line-height: 1.25; }
.card .info .price { font-weight: 700; color: var(--primary-d); font-size: 1.02rem; }
.card .info .whole {
  font-size: .72rem; color: var(--muted);
  background: #f4f0fb; padding: 3px 8px; border-radius: 8px; align-self: flex-start;
}
.card .add {
  margin-top: auto;
  border: none; background: var(--primary); color: #fff;
  font-family: inherit; font-weight: 700; font-size: .9rem;
  padding: 11px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .15s;
}
.card .add:active { background: var(--primary-d); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 3rem; margin-bottom: 8px; }

/* --------------------------- Barra de carrito --------------------------- */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--bar-h);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -4px 20px rgba(120,100,160,.10);
  transform: translateY(120%);
  transition: transform .25s ease;
}
.cart-bar.show { transform: translateY(0); }
.cart-bar .summary { flex: 1; }
.cart-bar .summary .count { font-size: .78rem; color: var(--muted); }
.cart-bar .summary .total { font-size: 1.15rem; font-weight: 700; }
.cart-bar .open-cart {
  background: var(--primary); color: #fff; border: none;
  font-family: inherit; font-weight: 700; font-size: 1rem;
  padding: 14px 22px; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}

/* ------------------------------ Bottom sheet ---------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(58,53,80,.45);
  opacity: 0; visibility: hidden; transition: .2s;
}
.sheet-backdrop.show { opacity: 1; visibility: visible; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  max-height: 88vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s ease;
}
.sheet.show { transform: translateY(0); }
.sheet .handle { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 10px auto 4px; }
.sheet .sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 18px 10px; border-bottom: 1px solid var(--line);
}
.sheet .sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet .sheet-head .close { background: none; border: none; font-size: 1.4rem; color: var(--muted); cursor: pointer; }
.sheet .sheet-body { overflow-y: auto; padding: 12px 18px; flex: 1; }
.sheet .sheet-foot { padding: 14px 18px calc(18px + env(safe-area-inset-bottom,0)); border-top: 1px solid var(--line); }

/* Líneas del carrito */
.cart-line { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line .ci-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: #f3eefb; flex: 0 0 auto; }
.cart-line .ci-info { flex: 1; min-width: 0; }
.cart-line .ci-info .ci-name { font-weight: 600; font-size: .9rem; }
.cart-line .ci-info .ci-price { font-size: .82rem; color: var(--muted); }
.cart-line .ci-info .ci-price b { color: var(--primary-d); }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 32px; height: 32px; border-radius: 9px; border: 1.5px solid var(--line);
  background: #fff; font-size: 1.1rem; font-weight: 700; color: var(--primary-d); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty .n { min-width: 26px; text-align: center; font-weight: 700; }
.cart-line .ci-remove { background: none; border: none; font-size: 1.1rem; color: var(--danger); cursor: pointer; }

/* --------------------------------- Forms -------------------------------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 1rem; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-primary {
  width: 100%; border: none; background: var(--primary); color: #fff;
  font-family: inherit; font-weight: 700; font-size: 1.05rem;
  padding: 15px; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:disabled { opacity: .6; }
.btn-wa { background: #25d366; }
.btn-ghost {
  width: 100%; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font-family: inherit; font-weight: 600; font-size: 1rem; padding: 13px; border-radius: 14px; cursor: pointer;
}

.sheet-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.sheet-total .label { color: var(--muted); }
.sheet-total .amount { font-size: 1.5rem; font-weight: 700; }

/* --------------------------------- Toast -------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; z-index: 80; opacity: 0; transition: .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------ Confirmación ---------------------------- */
.success-box { text-align: center; padding: 18px 6px; }
.success-box .check { font-size: 3.4rem; }
.success-box h2 { margin: 6px 0; }
.success-box .code {
  display: inline-block; background: #f3eefb; color: var(--primary-d);
  font-weight: 700; letter-spacing: 1px; padding: 8px 16px; border-radius: 12px; margin: 6px 0 14px; font-size: 1.2rem;
}

/* ----------------------------- Seguimiento ------------------------------ */
.page { max-width: 620px; margin: 0 auto; padding: 16px; }
.track-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.track-tabs button {
  flex: 1; border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  font-family: inherit; font-weight: 600; padding: 11px; border-radius: 12px; cursor: pointer;
}
.track-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.order-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px; }
.order-card .oc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.order-card .oc-code { font-weight: 700; letter-spacing: .5px; }
.badge { font-size: .76rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
.badge-pendiente         { background: #fff1d6; color: #b07a13; }
.badge-comenzado         { background: #dbe9ff; color: #2f5fb0; }
.badge-pendiente_retirar { background: #e7dcff; color: #6b46c1; }
.badge-finalizado        { background: #d7f3e8; color: #1f8a63; }
.badge-entregado         { background: #d3f0d6; color: #2e7d32; }
.badge-cancelado         { background: #ffe0db; color: #c0392b; }

.order-card ul.oc-items { list-style: none; margin: 8px 0; padding: 0; }
.order-card ul.oc-items li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.order-card .oc-total { display: flex; justify-content: space-between; font-weight: 700; margin-top: 8px; }
.order-card .oc-note { background: #f3eefb; border-radius: 10px; padding: 9px 12px; margin-top: 8px; font-size: .85rem; }
.order-card .oc-note .t { font-size: .7rem; color: var(--muted); }

.hint { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 8px; }
.loading { text-align: center; padding: 40px; color: var(--muted); }
