.pedrito-chat {
  --pedrito-color: #00a884;
  position: fixed;
  bottom: 20px;
  z-index: 999999;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
.pedrito-chat.pedrito-derecha { right: 20px; }
.pedrito-chat.pedrito-izquierda { left: 20px; }

.pedrito-burbuja {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--pedrito-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  transition: transform .15s ease;
}
.pedrito-burbuja:hover { transform: scale(1.06); }

.pedrito-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  /* el panel cuelga del contenedor, que ya está a --pedrito-offset del borde inferior */
  max-height: calc(100vh - var(--pedrito-offset, 20px) - 80px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pedrito-izquierda .pedrito-panel { left: 0; right: auto; }

.pedrito-cabecera {
  background: var(--pedrito-color);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pedrito-cabecera > div:first-child { min-width: 0; }
.pedrito-cabecera b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pedrito-cabecera span { font-size: 11px; opacity: .85; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pedrito-cerrar {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}
.pedrito-acciones { display: flex; align-items: center; gap: 6px; flex: none; }
.pedrito-nuevo {
  background: rgba(255, 255, 255, .18);
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 6px 9px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.pedrito-nuevo:hover { background: rgba(255, 255, 255, .32); }

.pedrito-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f4f6f8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pedrito-msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: normal;
}
.pedrito-msg.bot { background: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
.pedrito-msg.cliente { background: var(--pedrito-color); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.pedrito-msg a { color: inherit; text-decoration: underline; }

.pedrito-typing { display: flex; gap: 4px; align-items: center; }
.pedrito-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9aa3ad;
  animation: pedrito-blink 1.2s infinite ease-in-out;
}
.pedrito-typing span:nth-child(2) { animation-delay: .15s; }
.pedrito-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pedrito-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Compositor: fila fija (no se encoge) con aire y botón de enviar visible */
.pedrito-form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e8eb;
  background: #fff;
}
/* Divi estiliza input[type=text] y button en global: subimos especificidad y fijamos el alto */
.pedrito-chat .pedrito-form .pedrito-input {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  box-sizing: border-box !important;
  border: 1px solid #e0e3e7 !important;
  border-radius: 20px !important;
  padding: 0 14px !important;
  margin: 0 !important;
  font-size: 14px !important;
  line-height: 38px !important;
  outline: none !important;
  background: #f7f8f9 !important;
  color: #111 !important;
  box-shadow: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}
.pedrito-chat .pedrito-form .pedrito-input:focus {
  border-color: var(--pedrito-color) !important;
  background: #fff !important;
}
.pedrito-chat .pedrito-form button.pedrito-enviar {
  flex: 0 0 auto !important;
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--pedrito-color) !important;
  color: #fff !important;
  font-size: 15px !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  box-shadow: none !important;
}
.pedrito-chat .pedrito-form button.pedrito-enviar:hover { filter: brightness(1.08); }

.pedrito-pie {
  font-size: 10px;
  color: #8b93a3;
  text-align: center;
  padding: 5px;
  background: #fff;
  border-top: 1px solid #f0f2f4;
}

@media (max-width: 480px) {
  .pedrito-panel { width: calc(100vw - 24px); height: calc(100vh - var(--pedrito-offset, 20px) - 80px); right: -8px; }
  .pedrito-chat .pedrito-form { padding: 8px 10px; }
}

/* --- Productos, enlaces y carrito --- */
.pedrito-adjunto { display: flex; flex-direction: column; gap: 8px; }

.pedrito-card {
  display: flex; gap: 10px; align-items: center;
  background: #fff; border: 1px solid #e5e8eb; border-radius: 10px;
  padding: 8px; text-decoration: none; color: inherit;
  transition: border-color .15s ease, transform .15s ease;
}
.pedrito-card:hover { border-color: var(--pedrito-color); transform: translateY(-1px); }
.pedrito-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.pedrito-card .pc-sin-foto { width: 56px; height: 56px; border-radius: 8px; background: #eef1f4; flex: none; }
.pedrito-card .pc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pedrito-card b { font-size: 12.5px; line-height: 1.3; font-weight: 600; }
.pedrito-card i { font-size: 11px; color: #8b93a3; font-style: normal; }
.pedrito-card .pc-precio { font-size: 13px; font-weight: 700; color: #0b7a5e; }
.pedrito-card .pc-agotado { font-size: 10px; color: #b32d2e; text-transform: uppercase; letter-spacing: .4px; }

.pedrito-enlaces { background: #fff; border: 1px solid #e5e8eb; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; }
.pedrito-enlaces span { display: block; color: #8b93a3; margin-bottom: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.pedrito-enlaces a { display: block; color: var(--pedrito-color); text-decoration: none; padding: 3px 0; }
.pedrito-enlaces a:hover { text-decoration: underline; }

.pedrito-carrito { background: #fff; border: 1px solid #e5e8eb; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; }
.pedrito-btn-carrito {
  width: 100%; border: 0; border-radius: 8px; padding: 10px;
  background: var(--pedrito-color); color: #fff; font-weight: 600; cursor: pointer;
}
.pedrito-btn-carrito:disabled { opacity: .6; cursor: default; }
.pedrito-carrito-msg { display: block; margin-top: 8px; color: #0b7a5e; }
.pedrito-carrito-msg a { color: inherit; font-weight: 700; }

/* --- Formulario previo (lead) --- */
.pedrito-gate { flex: 1; padding: 16px; background: #f4f6f8; display: flex; flex-direction: column; gap: 8px; }
.pedrito-gate p { margin: 0 0 4px; font-size: 13px; color: #50575e; }
.pedrito-gate input {
  width: 100%; border: 1px solid #d0d3d6; border-radius: 8px; padding: 10px;
  font-size: 14px; background: #fff; color: #111; box-sizing: border-box;
}
.pedrito-gate input:focus { outline: none; border-color: var(--pedrito-color); }
.pedrito-btn-gate {
  background: var(--pedrito-color); color: #fff; border: 0; border-radius: 8px;
  padding: 11px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.pedrito-gate-err { color: #b32d2e; font-size: 12px; min-height: 16px; }

/* --- Correcciones de visibilidad y formulario previo --- */
.pedrito-chat [hidden] { display: none !important; }

.pedrito-gate {
  flex: 1;
  justify-content: center;
  padding: 24px 18px;
}
.pedrito-gate p { text-align: center; font-size: 14px; margin-bottom: 8px; line-height: 1.4; }
.pedrito-gate input { margin-bottom: 2px; }
.pedrito-btn-gate { margin-top: 10px; }

/* Tarjeta sin enlace (SKU que no está en la tienda) */
.pedrito-card-sin-enlace { cursor: default; }
.pedrito-card-sin-enlace:hover { border-color: #e5e8eb; transform: none; }
.pedrito-aviso { color: #b32d2e; font-size: 12px; }

/* --- Blindaje contra los estilos globales de Divi/Woo (inputs y botones) --- */
.pedrito-chat .pedrito-gate input {
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  box-sizing: border-box !important;
  border: 1px solid #d0d3d6 !important;
  border-radius: 8px !important;
  padding: 10px !important;
  margin: 0 0 2px !important;
  font-size: 14px !important;
  line-height: normal !important;
  background: #fff !important;
  color: #111 !important;
  box-shadow: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}
.pedrito-chat .pedrito-gate input:focus {
  outline: none !important;
  border-color: var(--pedrito-color) !important;
}
.pedrito-chat .pedrito-gate .pedrito-btn-gate {
  width: 100% !important;
  border: 0 !important;
  border-radius: 8px !important;
  padding: 11px !important;
  margin-top: 10px !important;
  background: var(--pedrito-color) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  cursor: pointer !important;
  box-shadow: none !important;
}
.pedrito-chat .pedrito-cabecera button { box-shadow: none !important; }
.pedrito-chat .pedrito-cabecera .pedrito-cerrar {
  background: transparent !important;
  border: 0 !important;
  padding: 0 0 0 4px !important;
  font-size: 22px !important;
  line-height: 1 !important;
  color: #fff !important;
}
.pedrito-chat .pedrito-cabecera .pedrito-nuevo {
  background: rgba(255, 255, 255, .18) !important;
  border: 0 !important;
  border-radius: 12px !important;
  padding: 6px 9px !important;
  color: #fff !important;
  font-size: 11px !important;
  line-height: 1 !important;
  font-family: inherit !important;
  cursor: pointer !important;
}
.pedrito-chat .pedrito-cabecera .pedrito-nuevo:hover { background: rgba(255, 255, 255, .32) !important; }

/* --- Cierre por WhatsApp (el chat no cobra: el pedido se cierra en el WhatsApp de la tienda) --- */
.pedrito-wa { background: #fff; border: 1px solid #e5e8eb; border-radius: 10px; padding: 10px 12px; }
.pedrito-chat .pedrito-btn-wa {
  display: block !important;
  text-align: center;
  text-decoration: none !important;
  background: #25d366 !important;
  color: #fff !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  border-radius: 8px !important;
  padding: 11px !important;
  box-shadow: none !important;
}
.pedrito-chat .pedrito-btn-wa:hover { filter: brightness(.95); }
.pedrito-wa-msg {
  display: block;
  margin-top: 6px;
  color: #8b93a3;
  font-size: 11.5px;
  line-height: 1.35;
}

/* Enlaces dentro del mensaje (el nombre del producto): mismo color de la burbuja, subrayado. */
.pedrito-chat .pedrito-msg a {
  color: inherit !important;
  text-decoration: underline !important;
  font-weight: 600 !important;
}
.pedrito-chat .pedrito-msg a:hover { opacity: .85; }

/* --- Valoración del chat (estrellas) --- */
.pedrito-puntuar {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
}
.pedrito-puntuar .pp-txt { flex: 0 0 auto; }
.pedrito-puntuar .pp-estrellas { display: inline-flex; gap: 2px; }
.pedrito-chat .pedrito-puntuar .pp-est {
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 1px !important;
  margin: 0 !important;
  min-width: 0 !important;
  height: auto !important;
  font-size: 19px !important;
  line-height: 1 !important;
  color: #d1d5db !important;
  cursor: pointer !important;
  text-shadow: none !important;
}
.pedrito-chat .pedrito-puntuar .pp-est:hover,
.pedrito-chat .pedrito-puntuar .pp-est.activa { color: #f5b301 !important; }
.pedrito-puntuar .pp-gracias { color: #0f7b3f; font-weight: 600; }