/* ============================================================
   Pixel Vendedor — chat.css
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pv-accent:    #1d4ed8;
  --pv-accent2:   #2563eb;
  --pv-deep:      #0f172a;
  --pv-mid:       #1e293b;
  --pv-surface:   #f1f5f9;
  --pv-border:    #e2e8f0;
  --pv-text:      #1e293b;
  --pv-muted:     #64748b;
  --pv-green:     #16a34a;
  --pv-red:       #dc2626;
  --pv-panel-w:   220px;
  --pv-radius:    22px;
  /* Tamaño de ventana desktop */
  --pv-win-w:     min(1100px, 94vw);
  --pv-win-h:     min(750px, 92vh);
}

/* ── Trigger flotante ───────────────────────────────────── */
#pv-trigger {
  position: fixed; bottom: 20px; right: 20px; z-index: 9998;
  border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer; transition: opacity .2s, transform .2s;
}
#pv-trigger.hidden { opacity: 0; transform: scale(0); pointer-events: none; }

.pv-trigger-wrap { position: relative; display: inline-flex; flex-direction: column; align-items: center; }
.pv-trigger-mascot { width: 88px; height: auto; filter: drop-shadow(0 4px 12px rgba(0,0,0,.3)); }
.pv-trigger-badge {
  margin-top: 8px; background: var(--pv-accent); color: #fff;
  padding: 6px 14px; border-radius: 20px; font-size: .75rem; font-weight: 700;
}
#pv-cart-badge {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: #fff; font-size: .7rem; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── Overlay container ──────────────────────────────────── */
#pv-container {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 10px; pointer-events: none;
}
#pv-container.visible { pointer-events: all; }

/* ── Ventana ────────────────────────────────────────────── */
#pv-window {
  display: flex;
  width: var(--pv-win-w); height: var(--pv-win-h);
  border-radius: var(--pv-radius); overflow: hidden;
  box-shadow: 0 32px 90px rgba(15,23,42,.5);
  transform: translateY(18px) scale(.96); opacity: 0;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s cubic-bezier(.4,0,.2,1);
}
#pv-container.visible #pv-window { transform: translateY(0) scale(1); opacity: 1; }

/* ── Panel lateral ──────────────────────────────────────── */
#pv-side-panel {
  width: var(--pv-panel-w); min-width: var(--pv-panel-w);
  background: linear-gradient(170deg, var(--pv-deep), var(--pv-mid));
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 14px; color: #fff; justify-content: space-between;
}
.pv-panel-logo    { max-width: 130px; height: auto; object-fit: contain; }
.pv-panel-center  { flex: 1; display: flex; align-items: center; justify-content: center; }
.pv-panel-mascot  { width: 150px; height: auto; }
.pv-panel-bottom  { width: 100%; text-align: center; }
.pv-panel-name    { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.pv-panel-status  { font-size: .75rem; opacity: .75; display: flex; align-items: center; gap: 6px; justify-content: center; }
.pv-status-dot    { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; }

/* ── Área de chat ───────────────────────────────────────── */
#pv-chat-area { flex: 1; display: flex; flex-direction: column; background: #fff; min-width: 0; }

/* Header */
.pv-header {
  padding: 12px 14px; border-bottom: 1px solid var(--pv-border);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.pv-header-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pv-header-mini  { width: 40px; height: 40px; object-fit: contain; border-radius: 50%; flex-shrink: 0; }
.pv-header-info  { min-width: 0; }
.pv-header-info h2 { color: var(--pv-text); font-size: 1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-header-info p  { color: var(--pv-muted); font-size: .75rem; margin: 0; }
.pv-header-btns  { display: flex; gap: 6px; flex-shrink: 0; }
.pv-hbtn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--pv-border); background: #fff;
  cursor: pointer; color: var(--pv-text); font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
}
.pv-hbtn:hover { background: var(--pv-surface); }

/* Mensajes */
#pv-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--pv-surface);
}

/* ── Burbujas ───────────────────────────────────────────── */
.pv-msg { display: flex; }
.pv-msg.user { justify-content: flex-end; }
.pv-bubble {
  max-width: 90%; background: #fff; border: 1px solid var(--pv-border);
  padding: 10px 13px; border-radius: 14px;
  color: var(--pv-text); line-height: 1.55; font-size: .9rem;
}
.pv-msg.user .pv-bubble { background: var(--pv-accent); border-color: var(--pv-accent); color: #fff; }

/* ── Botones de acción ──────────────────────────────────── */
.pv-btn-row { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.pv-btn-primary, .pv-btn-secondary {
  border: none; border-radius: 10px; padding: 9px 16px;
  font-weight: 700; cursor: pointer; font-size: .87rem;
  transition: background .15s; touch-action: manipulation;
  min-height: 40px;
}
.pv-btn-primary  { background: var(--pv-accent); color: #fff; }
.pv-btn-primary:hover  { background: var(--pv-accent2); }
.pv-btn-secondary { background: #e8edf5; color: #2d3a52; }
.pv-btn-secondary:hover { background: #d6dff0; }

/* Chips */
.pv-chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.pv-chip {
  border: 1px solid var(--pv-border); background: #fff; border-radius: 20px;
  padding: 8px 14px; cursor: pointer; font-size: .85rem;
  transition: border-color .15s, background .15s; touch-action: manipulation;
}
.pv-chip:hover   { border-color: var(--pv-accent); background: #eff6ff; }
.pv-chip.active  { background: var(--pv-accent); border-color: var(--pv-accent); color: #fff; }
.pv-chip.disabled { opacity: .45; cursor: not-allowed; }
.pv-chip.added   { background: #dcfce7; border-color: var(--pv-green); color: #15803d; }

/* ── Inputs ─────────────────────────────────────────────── */
.pv-lead-wrap {
  display: flex; flex-direction: column; gap: 10px;
  background: #fff; border: 1px solid var(--pv-border);
  border-radius: 14px; padding: 12px;
}
.pv-input {
  width: 100%; border: 1px solid var(--pv-border); border-radius: 10px;
  padding: 10px 12px; font-size: .9rem; color: var(--pv-text);
  -webkit-appearance: none; appearance: none;
}
.pv-input:focus { outline: none; border-color: var(--pv-accent); }

/* ── Catálogo ───────────────────────────────────────────── */
.pv-catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 12px; padding: 4px 0; }
.pv-prod-card    { background: #fff; border: 1px solid var(--pv-border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.pv-prod-inner   { display: flex; gap: 10px; padding: 10px; }
.pv-prod-img, .pv-prod-img-ph { width: 80px; height: 80px; border-radius: 10px; flex-shrink: 0; }
.pv-prod-img     { object-fit: cover; }
.pv-prod-img-ph  { background: var(--pv-surface); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.pv-prod-info    { flex: 1; min-width: 0; }
.pv-prod-sku     { font-size: .72rem; color: var(--pv-muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pv-prod-nombre  { font-weight: 700; font-size: .88rem; color: var(--pv-text); line-height: 1.3; margin-top: 2px; }
.pv-prod-desc    { font-size: .77rem; color: var(--pv-muted); margin-top: 3px; line-height: 1.4; }
.pv-prod-precio  { font-weight: 700; color: var(--pv-accent); margin-top: 5px; font-size: .92rem; }
.pv-prod-precio small { font-weight: 500; color: var(--pv-muted); font-size: .78rem; }
.pv-stock        { display: inline-block; font-size: .73rem; font-weight: 600; border-radius: 20px; padding: 2px 8px; margin-top: 4px; }
.pv-stock.ok     { background: #dcfce7; color: #15803d; }
.pv-stock.out    { background: #fee2e2; color: #b91c1c; }

/* Producto dentro de burbuja */
.pv-bubble .pv-prod-inner { padding: 0; margin-bottom: 6px; }
.pv-bubble .pv-prod-img,
.pv-bubble .pv-prod-img-ph { width: 70px; height: 70px; }

/* ── Carrito ─────────────────────────────────────────────── */
.pv-cart-list  { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.pv-cart-item  {
  display: flex; align-items: center; justify-content: space-between;
  background: #f8fafc; border: 1px solid var(--pv-border);
  border-radius: 10px; padding: 9px 12px; font-size: .85rem;
}
.pv-cart-info  { line-height: 1.5; min-width: 0; flex: 1; margin-right: 8px; }
.pv-qty-btn    {
  border: 1px solid var(--pv-border); background: #fff;
  width: 26px; height: 26px; border-radius: 6px;
  cursor: pointer; font-size: 1rem; line-height: 1;
  touch-action: manipulation; flex-shrink: 0;
}
.pv-qty-val    { display: inline-block; min-width: 26px; text-align: center; font-weight: 700; }
.pv-del-btn    { border: none; background: transparent; color: var(--pv-red); cursor: pointer; font-size: 1rem; padding: 4px; flex-shrink: 0; touch-action: manipulation; }
.pv-cart-total { text-align: right; font-size: .9rem; color: var(--pv-text); }
.pv-cart-total b { color: var(--pv-accent); font-size: 1rem; }
.pv-cart-total small { display: block; color: var(--pv-muted); font-size: .78rem; }

/* ── Contador de cantidad ───────────────────────────────── */
.pv-counter-row { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 0; }
.pv-counter-btn {
  width: 42px; height: 42px; border: none; border-radius: 10px;
  background: #e0e7ef; font-size: 1.4rem; color: var(--pv-accent);
  cursor: pointer; touch-action: manipulation;
}
.pv-counter-val {
  min-width: 60px; text-align: center; font-size: 1.3rem; font-weight: 700;
  color: var(--pv-accent); background: #eff6ff;
  border: 1px solid #bfdbfe; border-radius: 10px; padding: 7px 10px;
}

/* ── Datos de pago ──────────────────────────────────────── */
.pv-pago-datos {
  background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: 10px; padding: 10px 13px;
  font-size: .87rem; line-height: 1.7; margin-top: 4px;
}

/* ── Upload comprobante ─────────────────────────────────── */
.pv-upload-label {
  display: block; border: 2px dashed var(--pv-border); border-radius: 12px;
  padding: 18px; text-align: center; cursor: pointer;
  color: var(--pv-muted); font-size: .88rem; transition: border-color .15s, color .15s;
}
.pv-upload-label:hover { border-color: var(--pv-accent); color: var(--pv-accent); }
.pv-upload-preview img {
  width: 100%; max-height: 160px; object-fit: contain;
  border-radius: 10px; margin-top: 8px; border: 1px solid var(--pv-border);
}

/* ── Resumen final ──────────────────────────────────────── */
.pv-resumen      { text-align: center; padding: 10px 6px; line-height: 1.8; font-size: .9rem; }
.pv-resumen-icon { font-size: 2.2rem; margin-bottom: 8px; }

/* ================================================================
   RESPONSIVE MOBILE
   ================================================================ */

/* Ocultar panel lateral en tablet/móvil */

/* ── Buscador del catálogo ──────────────────────────────── */
.pv-catalog-search { width: 100%; padding: 0 0 2px 0; }
.pv-catalog-search .pv-input { font-size: 16px; }
@media (max-width: 768px) {
  #pv-side-panel { display: none; }

  #pv-container { padding: 0; align-items: stretch; justify-content: stretch; }

  #pv-window {
    width: 100vw;
    /* dvh evita el salto de la barra del navegador en móvil */
    height: 100dvh;
    height: 100vh; /* fallback para browsers sin dvh */
    max-width: none; max-height: none;
    border-radius: 0;
  }

  /* Catálogo en 1 columna */
  .pv-catalog-grid { grid-template-columns: 1fr; gap: 8px; }

  /* Burbujas más anchas */
  .pv-bubble { max-width: 94%; }

  /* Trigger más pequeño */
  .pv-trigger-mascot { width: 68px; }
  .pv-trigger-badge  { font-size: .7rem; padding: 5px 10px; }
}

/* Móvil fino — pantallas ≤ 480px */
@media (max-width: 480px) {
  /* Header compacto con área táctil mínima */
  .pv-header { padding: 8px 12px; min-height: 54px; }
  .pv-header-mini { width: 36px; height: 36px; }
  .pv-header-info h2 { font-size: .88rem; }
  .pv-header-info p  { font-size: .7rem; }
  .pv-hbtn { width: 36px; height: 36px; font-size: .9rem; border-radius: 10px; }
  .pv-header-btns { gap: 5px; }

  /* Padding reducido en mensajes */
  #pv-messages { padding: 10px; gap: 8px; }
  /* Ocultar scrollbar en móvil para look más limpio */
  #pv-messages { scrollbar-width: none; -ms-overflow-style: none; }
  #pv-messages::-webkit-scrollbar { display: none; }

  /* Burbujas full width */
  .pv-bubble { max-width: 100%; font-size: .87rem; padding: 9px 11px; border-radius: 12px; }

  /* Inputs: font-size 16px previene el zoom automático en iOS */
  .pv-input { font-size: 16px; padding: 12px 13px; min-height: 46px; border-radius: 12px; -webkit-appearance: none; }
  .pv-lead-wrap { padding: 11px; gap: 9px; }

  /* Chips más grandes y táctiles */
  .pv-chip { padding: 10px 14px; font-size: .84rem; min-height: 40px; }
  .pv-chips-wrap { gap: 7px; }

  /* Botones de acción — mínimo 44px altura (estándar HIG/Material) */
  .pv-btn-primary, .pv-btn-secondary {
    padding: 12px 18px; font-size: .87rem;
    min-height: 46px; border-radius: 12px;
  }
  /* En filas, que los botones crezcan al mismo ancho */
  .pv-btn-row { gap: 8px; }
  .pv-btn-row .pv-btn-primary,
  .pv-btn-row .pv-btn-secondary { flex: 1; min-width: 0; justify-content: center; display: flex; align-items: center; }

  /* Catálogo: imagen un poco más pequeña */
  .pv-prod-img, .pv-prod-img-ph { width: 68px; height: 68px; }
  .pv-prod-nombre { font-size: .86rem; }

  /* Carrito: botones de cantidad más táctiles */
  .pv-cart-item { padding: 8px 10px; }
  .pv-qty-btn   { width: 32px; height: 32px; font-size: 1.1rem; border-radius: 8px; }
  .pv-qty-val   { min-width: 30px; font-size: .9rem; }

  /* Contador en producto */
  .pv-counter-btn { width: 50px; height: 50px; font-size: 1.6rem; border-radius: 12px; }
  .pv-counter-val { font-size: 1.2rem; padding: 8px 14px; min-width: 64px; }

  /* Upload */
  .pv-upload-label { padding: 22px 14px; font-size: .9rem; border-radius: 14px; }

  /* Datos de pago */
  .pv-pago-datos { font-size: .85rem; padding: 10px 12px; }

  /* Resumen */
  .pv-resumen { font-size: .88rem; }
  .pv-resumen-icon { font-size: 2.6rem; }
}

/* Móvil muy pequeño ≤ 360px */
@media (max-width: 360px) {
  .pv-header-info h2 { font-size: .82rem; }
  .pv-bubble         { font-size: .84rem; }
  .pv-chip           { padding: 9px 11px; font-size: .81rem; }
  .pv-btn-primary, .pv-btn-secondary { padding: 11px 14px; font-size: .83rem; min-height: 44px; }
  .pv-prod-img, .pv-prod-img-ph { width: 60px; height: 60px; }
}

/* Landscape móvil (pantalla baja) */
@media (max-height: 480px) and (max-width: 900px) {
  .pv-header { padding: 6px 12px; min-height: 46px; }
  .pv-header-mini { width: 30px; height: 30px; }
  #pv-messages { padding: 8px 10px; gap: 6px; }
  .pv-bubble { font-size: .85rem; padding: 7px 10px; }
  .pv-catalog-grid { grid-template-columns: repeat(2, 1fr); }
}