/* Ficha del libro, asistente, carrito y avisos */

.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgb(28 27 23 / 0.07); color: var(--ink);
  display: grid; place-items: center; font-size: 0.85rem; flex: none;
}
.icon-btn:hover { background: rgb(28 27 23 / 0.14); }

/* Ficha: panel de papel a la derecha (abajo en el celular) */
.sheet {
  position: absolute; right: var(--edge); top: 50%; width: min(400px, 40vw); max-height: calc(100% - 2 * var(--edge));
  overflow: auto; padding: 30px 28px 24px; border-radius: var(--radius-panel);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-panel);
  transform: translate(24px, -50%); opacity: 0;
  transition: transform 520ms var(--ease-out-expo), opacity 300ms ease;
}
.sheet.open { transform: translate(0, -50%); opacity: 1; }
.sheet.leaving { transition-duration: 240ms; }
.sheet-close { position: absolute; top: 14px; right: 14px; }
.sheet-cat { margin: 0 0 8px; font-size: var(--text-sm); font-weight: 600; color: var(--accent-ink); text-transform: uppercase; letter-spacing: 0.08em; }
.sheet-title { margin: 0; font: 400 var(--text-title)/1.02 var(--font-display); letter-spacing: -0.025em; padding-right: 30px; }
.sheet-author { margin: 6px 0 16px; font: italic 400 1.05rem var(--font-display); color: var(--ink-soft); }
.sheet-desc { margin: 0 0 20px; color: #3b382f; }
.sheet-price { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid rgb(28 27 23 / 0.1); }
.sheet-price strong { font: 400 1.9rem var(--font-display); letter-spacing: -0.02em; }
.sheet-price span { font-size: var(--text-sm); color: var(--accent-ink); font-weight: 500; }
.sheet-stock { display: flex; align-items: center; gap: 8px; margin: 8px 0 20px; font-size: 0.9rem; color: var(--ink-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--ok); }
.dot.last { background: var(--warn); }
.dot.out { background: var(--out); }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-actions .btn-primary { flex: 1; background: var(--night-700); color: var(--paper); }
.sheet-actions .btn-primary:hover { background: var(--night-800); }
.sheet-actions .btn-primary[data-mode="notify"] { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px rgb(28 27 23 / 0.3); }
.sheet-pay { margin-top: 18px; font-size: var(--text-sm); color: var(--ink-soft); }
.sheet-pay summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.sheet-pay p { margin: 8px 0 0; }

/* Paneles con encabezado (asistente y carrito) */
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 18px; border-bottom: 1px solid rgb(28 27 23 / 0.08); }
.panel-head div { flex: 1; display: grid; line-height: 1.2; }
.panel-head strong { font: 400 1.02rem var(--font-display); }
.panel-head span { font-size: var(--text-sm); color: var(--ink-soft); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--night-700); color: var(--accent); font: 400 0.8rem var(--font-display);
}

.assistant-btn {
  position: absolute; left: var(--edge); bottom: var(--edge); display: flex; align-items: center; gap: 10px;
  padding: 6px 18px 6px 6px; border-radius: var(--radius-pill); border: 0; background: var(--paper); color: var(--ink);
  font-weight: 500; box-shadow: var(--shadow-panel); transition: opacity var(--duration-normal), transform var(--duration-fast);
}
.assistant-btn:hover { transform: translateY(-2px); }
.assistant-btn[aria-expanded="true"] { opacity: 0; pointer-events: none; }

.assistant {
  position: absolute; left: var(--edge); bottom: var(--edge); width: min(390px, calc(100% - 2 * var(--edge)));
  height: min(560px, calc(100% - 120px)); display: flex; flex-direction: column;
  border-radius: var(--radius-panel); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-panel);
  animation: rise 420ms var(--ease-out-expo);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
.log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 0.92rem; animation: rise 320ms var(--ease-out-expo); }
.msg.bot { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.06); }
.msg.me { align-self: flex-end; background: var(--night-700); color: var(--paper); border-bottom-right-radius: 4px; }
.msg.typing { display: flex; gap: 4px; padding: 14px; }
.msg.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); animation: blink 1s infinite; }
.msg.typing i:nth-child(2) { animation-delay: 0.15s; }
.msg.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 50% { opacity: 0.25; } }
.recs { display: grid; gap: 8px; margin-top: 10px; }
.rec { display: flex; gap: 10px; padding: 8px; border-radius: 10px; background: var(--paper); }
.thumb { flex: none; border-radius: 3px; background-repeat: no-repeat; box-shadow: 0 2px 6px rgb(0 0 0 / 0.25); }
.rec-info { display: grid; gap: 2px; min-width: 0; }
.rec-info strong { font: 400 0.92rem/1.15 var(--font-display); }
.rec-info > span { font-size: 0.78rem; color: var(--ink-soft); }
.rec-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.rec-actions button { border: 0; border-radius: var(--radius-pill); padding: 6px 11px; font-size: 0.76rem; font-weight: 600; }
.rec-go { background: var(--night-700); color: var(--paper); }
.rec-add { background: rgb(28 27 23 / 0.08); }
.rec-out { font-size: 0.76rem; color: var(--out); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.chip { border: 1px solid rgb(28 27 23 / 0.16); background: transparent; border-radius: var(--radius-pill); padding: 6px 11px; font-size: 0.78rem; text-align: left; }
.chip:hover { border-color: var(--night-700); background: #fff; }
.ask { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgb(28 27 23 / 0.08); }
.ask input { flex: 1; min-width: 0; border: 1px solid rgb(28 27 23 / 0.16); border-radius: var(--radius-pill); padding: 11px 15px; font: inherit; font-size: 0.9rem; background: #fff; color: var(--ink); }
.ask input:focus { outline: none; border-color: var(--night-700); }
.ask button { width: 42px; border: 0; border-radius: 50%; background: var(--night-700); color: var(--paper); font-weight: 700; }

/* Carrito */
.cart {
  position: absolute; top: var(--edge); right: var(--edge); bottom: var(--edge); width: min(380px, calc(100% - 2 * var(--edge)));
  display: flex; flex-direction: column; border-radius: var(--radius-panel); background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-panel); animation: slide 420ms var(--ease-out-expo); overflow: hidden;
}
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }
.cart-scroll { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 8px 18px 18px; overflow: auto; }
.cart .step { display: none; }
.cart[data-step="items"] .step-items, .cart[data-step="checkout"] .step-checkout { display: grid; gap: 10px; }
.cart[data-step="items"] .totals > div:not(.grand):not(:first-child) { display: none; }
.cart[data-step="redirect"] .cart-scroll, .cart[data-step="done"] .cart-scroll { display: none; }
.cart-redirect { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--ink-soft); }
.cart[data-step="redirect"] .cart-redirect { display: flex; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgb(0 158 227 / 0.2); border-top-color: var(--mp); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cart-thumb { width: 34px; height: 50px; object-fit: cover; border-radius: 2px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); }
.choice { border: 0; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; font-size: 0.9rem; }
.choice legend { font-weight: 600; margin-bottom: 6px; font-size: 0.86rem; }
.choice label { display: flex; gap: 8px; align-items: center; padding: 9px 11px; border-radius: 10px; background: #fff; border: 1px solid rgb(20 20 20 / 0.1); cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--night-700); box-shadow: inset 0 0 0 1px var(--night-700); }
.choice small { margin-left: auto; color: var(--ink-soft); }
.choice input { accent-color: var(--night-700); }
.back { justify-self: start; }
.cart-items { list-style: none; margin: 0; padding: 0; }
.cart-empty { color: var(--ink-soft); font-size: 0.9rem; }
.cart-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgb(28 27 23 / 0.08); }
.cart-info { flex: 1; display: grid; }
.cart-info strong { font: 400 0.98rem/1.2 var(--font-display); }
.cart-info span { font-size: 0.8rem; color: var(--ink-soft); }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgb(28 27 23 / 0.2); background: transparent; }
.qty button:disabled { opacity: 0.35; cursor: default; }
.delivery { border: 0; padding: 0; margin: 16px 0 8px; display: grid; gap: 8px; font-size: 0.9rem; }
.delivery legend { font-weight: 600; margin-bottom: 6px; }
.delivery label { display: flex; gap: 8px; align-items: center; }
.delivery input { accent-color: var(--night-700); }
.totals { margin: 8px 0 14px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; }
.totals dd { margin: 0; }
.totals .grand { font: 400 1.25rem var(--font-display); padding-top: 10px; border-top: 1px solid rgb(28 27 23 / 0.1); }
.btn-mp { border: 0; border-radius: 12px; padding: 14px; background: var(--mp); color: #fff; font-weight: 600; }
.btn-mp:disabled { opacity: 0.4; cursor: default; }
.fineprint { font-size: 0.72rem; color: var(--ink-soft); margin: 10px 0 0; }
.cart-paid { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.cart[data-step="done"] .cart-paid { display: flex; }
.paid-check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 2rem; margin: 0 0 12px; animation: bump 600ms var(--ease-out-expo); }
.cart-paid h3 { font: 400 1.5rem var(--font-display); margin: 0 0 8px; }
.cart-paid p { color: var(--ink-soft); margin: 0 0 20px; }

.toast {
  position: absolute; left: 50%; top: calc(var(--edge) * 4.4); transform: translate(-50%, -10px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: var(--radius-pill); background: var(--paper); color: var(--ink); font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--shadow-panel); white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { animation: toast 2.6s var(--ease-out-expo); }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -10px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

@media (max-width: 900px) {
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 58%; border-radius: var(--radius-panel) var(--radius-panel) 0 0;
    padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); transform: translateY(30px);
  }
  .sheet.open { transform: none; }
  .sheet-title { font-size: 1.5rem; }
  .sheet-desc { font-size: 0.9rem; margin-bottom: 14px; }
  .assistant { left: 0; right: 0; bottom: 0; width: auto; height: 78%; border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
  .cart { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 80%; border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
}
