@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

/* ============================================================
   CHATBOT QPH — Centralita de Ayuda & Conversión
   Diseño optimizado siguiendo Design System QuePlanHacer
============================================================ */

:root{
  --qph-primary:        #e63946;
  --qph-primary-hover:  #c1121f;
  --qph-primary-dark:   #d90429;
  --qph-primary-light:  #fff0f1;
  --qph-primary-glow:   rgba(230,57,70,0.14);
  --qph-bg:             #f2f4f8;
  --qph-surface:        #ffffff;
  --qph-surface-2:      #f9fafb;
  --qph-text:           #111827;
  --qph-text-mid:       #374151;
  --qph-text-light:     #6b7280;
  --qph-border:         #e5e7eb;
  --qph-blue:           #3b82f6;
  --qph-blue-bg:        #eff6ff;
  --qph-radius-sm:      8px;
  --qph-radius:         14px;
  --qph-radius-lg:      20px;
  --qph-shadow-sm:      0 1px 3px rgba(0,0,0,0.06);
  --qph-shadow-card:    0 2px 8px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.03);
  --qph-shadow:         0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --qph-shadow-hover:   0 16px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --qph-shadow-red:     0 3px 12px rgba(230,57,70,0.28);
  --qph-shadow-red-lg:  0 4px 16px rgba(230,57,70,0.28);
  --qph-transition:     all 0.25s cubic-bezier(0.4,0,0.2,1);
  --qph-ease:           cubic-bezier(0.4,0,0.2,1);
}

/* ---------- TOGGLE BUTTON ---------- */
#qph-chatbot-toggle{
  position:fixed;
  right:22px;
  bottom:22px;
  width:62px;
  height:62px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  z-index:99999;
  background:var(--qph-primary);
  color:#fff;
  font-size:26px;
  box-shadow:var(--qph-shadow-red-lg), 0 8px 24px rgba(0,0,0,0.12);
  transition:transform 0.3s var(--qph-ease), box-shadow 0.3s var(--qph-ease);
  -webkit-font-smoothing:antialiased;
  border:none;
  outline:none;
}
#qph-chatbot-toggle:hover{
  transform:translateY(-3px) scale(1.06);
  box-shadow:var(--qph-shadow-red-lg), 0 12px 32px rgba(0,0,0,0.18);
}
#qph-chatbot-toggle:active{
  transform:scale(0.96);
}
#qph-chatbot-toggle .qph-chatbot-toggle-close{
  display:none;
  font-size:22px;
  font-weight:700;
}
#qph-chatbot-toggle.open .qph-chatbot-toggle-icon{ display:none; }
#qph-chatbot-toggle.open .qph-chatbot-toggle-close{ display:block; }

/* Pulse animation when not open */
#qph-chatbot-toggle:not(.open)::after{
  content:'';
  position:absolute;
  inset:-4px;
  border-radius:50%;
  border:2px solid var(--qph-primary);
  animation:qph-pulse 2s infinite;
  opacity:0.5;
}
@keyframes qph-pulse{
  0%{transform:scale(1);opacity:0.5;}
  70%{transform:scale(1.15);opacity:0;}
  100%{transform:scale(1);opacity:0;}
}

/* Badge de notificación */
#qph-chatbot-toggle .qph-toggle-badge{
  position:absolute;
  top:-2px;
  right:-2px;
  width:18px;
  height:18px;
  background:var(--qph-primary);
  border:2px solid #fff;
  border-radius:50%;
  animation:qph-pulse 2s infinite;
}

/* ---------- CHAT WINDOW ---------- */
#qph-chatbot-window{
  position:fixed;
  right:22px;
  bottom:96px;
  width:400px;
  height:640px;
  max-height:calc(100vh - 120px);
  background:var(--qph-surface);
  border-radius:var(--qph-radius-lg);
  overflow:hidden;
  display:none;
  flex-direction:column;
  z-index:99998;
  box-shadow:0 30px 70px rgba(0,0,0,0.18), 0 10px 30px rgba(0,0,0,0.08);
  font-family:'Outfit',system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing:antialiased;
  border:1px solid var(--qph-border);
}
#qph-chatbot-window.open{
  display:flex;
  animation:qph-chat-in 0.22s var(--qph-ease) both;
}
@keyframes qph-chat-in{
  from{opacity:0;transform:translateY(14px) scale(0.97);}
  to{opacity:1;transform:none;}
}

/* ---------- HEADER ---------- */
#qph-chatbot-header{
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  color:#fff;
  flex-shrink:0;
  background:var(--qph-primary);
}
.qph-chatbot-header-info{
  display:flex;
  align-items:center;
  gap:12px;
}
.qph-chatbot-avatar{
  position:relative;
  width:40px;
  height:40px;
  border-radius:50%;
  background:rgba(255,255,255,0.2);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  flex-shrink:0;
}
.qph-chatbot-status{
  position:absolute;
  bottom:2px;
  right:2px;
  width:10px;
  height:10px;
  background:#22c55e;
  border:2px solid var(--qph-primary);
  border-radius:50%;
}
.qph-chatbot-header-text{
  display:flex;
  flex-direction:column;
  gap:1px;
}
#qph-chatbot-title{
  font-weight:800;
  font-size:1rem;
  line-height:1.2;
}
.qph-chatbot-subtitle{
  font-size:0.72rem;
  font-weight:500;
  opacity:0.85;
}
#qph-chatbot-close{
  background:none;
  border:none;
  color:#fff;
  font-size:20px;
  cursor:pointer;
  width:32px;
  height:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  transition:var(--qph-transition);
}
#qph-chatbot-close:hover{
  background:rgba(255,255,255,0.15);
}

/* ---------- MESSAGES AREA ---------- */
#qph-chatbot-messages{
  flex:1;
  overflow-y:auto;
  overflow-x:hidden;
  padding:16px;
  background:var(--qph-bg);
  scroll-behavior:smooth;
}
#qph-chatbot-messages::-webkit-scrollbar{
  width:5px;
}
#qph-chatbot-messages::-webkit-scrollbar-thumb{
  background:#d1d5db;
  border-radius:10px;
}

/* ---------- BUBBLES ---------- */
.qph-chatbot-bubble{
  background:var(--qph-surface);
  padding:14px 16px;
  border-radius:var(--qph-radius);
  margin-bottom:14px;
  font-size:0.9rem;
  line-height:1.55;
  color:var(--qph-text);
  border:1px solid var(--qph-border);
  box-shadow:var(--qph-shadow-card);
  animation:qph-msg-in 0.25s var(--qph-ease) both;
}
.qph-chatbot-bubble strong{
  color:var(--qph-primary);
  font-weight:700;
}
@keyframes qph-msg-in{
  from{opacity:0;transform:translateY(6px);}
  to{opacity:1;transform:none;}
}

/* Mensaje del bot con avatar */
.qph-chatbot-msg-bot{
  display:flex;
  gap:10px;
  margin-bottom:14px;
  animation:qph-msg-in 0.25s var(--qph-ease) both;
}
.qph-chatbot-msg-bot .qph-chatbot-msg-avatar{
  width:32px;
  height:32px;
  border-radius:50%;
  background:var(--qph-primary-light);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
  flex-shrink:0;
  margin-top:2px;
}
.qph-chatbot-msg-bot .qph-chatbot-msg-content{
  background:var(--qph-surface);
  padding:12px 16px;
  border-radius:var(--qph-radius);
  border:1px solid var(--qph-border);
  box-shadow:var(--qph-shadow-card);
  font-size:0.9rem;
  line-height:1.55;
  color:var(--qph-text);
  max-width:calc(100% - 50px);
}

/* ---------- TOPBAR / NAV ---------- */
.qph-chatbot-topbar{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:14px;
  animation:qph-msg-in 0.2s var(--qph-ease) both;
}
.qph-chatbot-back{
  width:38px;
  height:38px;
  border:none;
  border-radius:12px;
  background:var(--qph-surface);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:18px;
  font-weight:700;
  color:var(--qph-text);
  box-shadow:var(--qph-shadow-card);
  transition:var(--qph-transition);
  flex-shrink:0;
  border:1px solid var(--qph-border);
}
.qph-chatbot-back:hover{
  transform:translateY(-1px);
  box-shadow:var(--qph-shadow);
  border-color:var(--qph-primary);
  color:var(--qph-primary);
}
.qph-chatbot-step-title{
  font-size:0.92rem;
  font-weight:800;
  color:var(--qph-text);
  letter-spacing:-0.2px;
  line-height:1.2;
}

/* ---------- SEARCH BOX ---------- */
.qph-chatbot-search-wrap{
  position:relative;
  margin-bottom:14px;
  animation:qph-msg-in 0.2s var(--qph-ease) both;
}
.qph-chatbot-search{
  width:100%;
  padding:12px 14px 12px 40px;
  border:1.5px solid var(--qph-border);
  border-radius:var(--qph-radius);
  outline:none;
  font-size:0.88rem;
  background:var(--qph-surface);
  font-family:inherit;
  font-weight:500;
  color:var(--qph-text);
  transition:var(--qph-transition);
  box-shadow:var(--qph-shadow-sm);
}
.qph-chatbot-search::placeholder{
  color:var(--qph-text-light);
  font-weight:400;
}
.qph-chatbot-search:focus{
  border-color:var(--qph-primary);
  box-shadow:0 0 0 4px var(--qph-primary-glow), var(--qph-shadow);
}
.qph-chatbot-search-wrap::before{
  content:'🔍';
  position:absolute;
  left:14px;
  top:50%;
  transform:translateY(-50%);
  font-size:14px;
  opacity:0.5;
  pointer-events:none;
}

/* ---------- OPTION BUTTONS ---------- */
.qph-chatbot-btn{
  width:100%;
  border:none;
  padding:13px 16px;
  border-radius:var(--qph-radius);
  margin-bottom:10px;
  cursor:pointer;
  font-size:0.9rem;
  font-weight:700;
  color:#fff;
  background:var(--qph-primary);
  transition:var(--qph-transition);
  font-family:inherit;
  text-align:left;
  display:flex;
  align-items:center;
  gap:10px;
  box-shadow:var(--qph-shadow-sm);
  animation:qph-msg-in 0.2s var(--qph-ease) both;
}
.qph-chatbot-btn:hover{
  transform:translateY(-2px);
  box-shadow:var(--qph-shadow-red);
  filter:brightness(1.05);
}
.qph-chatbot-btn:active{
  transform:scale(0.98);
}
.qph-chatbot-btn .qph-btn-icon{
  font-size:1.15rem;
  flex-shrink:0;
}
.qph-chatbot-btn .qph-btn-arrow{
  margin-left:auto;
  font-size:0.85rem;
  opacity:0.7;
  transition:transform 0.2s;
}
.qph-chatbot-btn:hover .qph-btn-arrow{
  transform:translateX(3px);
}

/* Botón secundario (outlined) */
.qph-chatbot-btn--secondary{
  background:var(--qph-surface);
  color:var(--qph-text-mid);
  border:1.5px solid var(--qph-border);
  box-shadow:var(--qph-shadow-sm);
}
.qph-chatbot-btn--secondary:hover{
  background:var(--qph-primary-light);
  color:var(--qph-primary);
  border-color:var(--qph-primary);
  box-shadow:0 3px 12px var(--qph-primary-glow);
}

/* Botón de acción de contacto */
.qph-chatbot-btn--action{
  background:var(--qph-surface);
  color:var(--qph-text-mid);
  border:1.5px solid var(--qph-border);
}
.qph-chatbot-btn--action:hover{
  background:var(--qph-blue-bg);
  color:var(--qph-blue);
  border-color:var(--qph-blue);
}

/* Grid de botones */
.qph-chatbot-btn-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:14px;
}
.qph-chatbot-btn-grid .qph-chatbot-btn{
  margin-bottom:0;
  flex-direction:column;
  text-align:center;
  padding:16px 10px;
  gap:6px;
}
.qph-chatbot-btn-grid .qph-btn-icon{
  font-size:1.6rem;
}
.qph-chatbot-btn-grid .qph-btn-label{
  font-size:0.82rem;
}

/* ---------- CARDS DE PRODUCTO ---------- */
.qph-chatbot-card{
  display:flex;
  gap:12px;
  padding:10px;
  background:var(--qph-surface);
  border:1px solid var(--qph-border);
  border-radius:var(--qph-radius);
  margin-bottom:12px;
  text-decoration:none;
  color:inherit;
  transition:var(--qph-transition);
  box-shadow:var(--qph-shadow-card);
  animation:qph-msg-in 0.25s var(--qph-ease) both;
}
.qph-chatbot-card:hover{
  transform:translateY(-4px);
  box-shadow:var(--qph-shadow-hover);
  border-color:var(--qph-primary);
}
.qph-chatbot-card img{
  width:90px;
  height:90px;
  border-radius:var(--qph-radius-sm);
  object-fit:cover;
  background:var(--qph-bg);
  flex-shrink:0;
}
.qph-chatbot-card-body{
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  min-width:0;
}
.qph-chatbot-card-body h4{
  margin:0 0 6px;
  font-size:0.92rem;
  font-weight:800;
  line-height:1.35;
  color:var(--qph-text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.qph-chatbot-card-body p{
  margin:0 0 6px;
  font-size:0.78rem;
  color:var(--qph-text-light);
  line-height:1.4;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.qph-chatbot-card-price{
  font-size:0.85rem;
  font-weight:800;
  color:var(--qph-primary);
}
.qph-chatbot-card-price .woocommerce-Price-amount{
  color:var(--qph-primary) !important;
  font-weight:800 !important;
}

/* ---------- CONTACT LINKS ---------- */
.qph-chatbot-contact-list{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-bottom:14px;
}
.qph-chatbot-contact-item{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px;
  background:var(--qph-surface);
  border:1.5px solid var(--qph-border);
  border-radius:var(--qph-radius);
  text-decoration:none;
  color:var(--qph-text);
  transition:var(--qph-transition);
  box-shadow:var(--qph-shadow-sm);
  animation:qph-msg-in 0.2s var(--qph-ease) both;
}
.qph-chatbot-contact-item:hover{
  transform:translateY(-2px);
  box-shadow:var(--qph-shadow);
  border-color:var(--qph-primary);
}
.qph-chatbot-contact-item .qph-contact-icon{
  width:44px;
  height:44px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:1.3rem;
  flex-shrink:0;
}
.qph-chatbot-contact-item .qph-contact-info{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.qph-chatbot-contact-item .qph-contact-label{
  font-size:0.78rem;
  color:var(--qph-text-light);
  font-weight:600;
}
.qph-chatbot-contact-item .qph-contact-value{
  font-size:0.92rem;
  font-weight:800;
  color:var(--qph-text);
}
.qph-chatbot-contact-item .qph-contact-arrow{
  margin-left:auto;
  font-size:1rem;
  opacity:0.4;
}

/* Colores específicos de contacto */
.qph-contact-wa .qph-contact-icon{ background:#dcfce7; }
.qph-contact-phone .qph-contact-icon{ background:var(--qph-primary-light); }
.qph-contact-email .qph-contact-icon{ background:#eff6ff; }
.qph-contact-page .qph-contact-icon{ background:#fef3c7; }

/* ---------- FORMULARIO DE LEAD ---------- */
.qph-chatbot-form{
  background:var(--qph-surface);
  border:1.5px solid var(--qph-border);
  border-radius:var(--qph-radius);
  padding:16px;
  box-shadow:var(--qph-shadow-card);
  animation:qph-msg-in 0.25s var(--qph-ease) both;
}
.qph-chatbot-form-group{
  margin-bottom:12px;
}
.qph-chatbot-form-group label{
  display:block;
  font-size:0.78rem;
  font-weight:700;
  color:var(--qph-text-mid);
  margin-bottom:5px;
  text-transform:uppercase;
  letter-spacing:0.04em;
}
.qph-chatbot-form-group input,
.qph-chatbot-form-group textarea,
.qph-chatbot-form-group select{
  width:100%;
  padding:11px 14px;
  border:1.5px solid var(--qph-border);
  border-radius:var(--qph-radius-sm);
  font-size:0.9rem;
  font-family:inherit;
  color:var(--qph-text);
  background:var(--qph-surface-2);
  transition:var(--qph-transition);
  outline:none;
}
.qph-chatbot-form-group input:focus,
.qph-chatbot-form-group textarea:focus,
.qph-chatbot-form-group select:focus{
  border-color:var(--qph-primary);
  box-shadow:0 0 0 3px var(--qph-primary-glow);
  background:var(--qph-surface);
}
.qph-chatbot-form-group textarea{
  resize:vertical;
  min-height:80px;
}
.qph-chatbot-form-submit{
  width:100%;
  padding:13px;
  border:none;
  border-radius:var(--qph-radius-sm);
  background:var(--qph-primary);
  color:#fff;
  font-size:0.92rem;
  font-weight:800;
  font-family:inherit;
  cursor:pointer;
  transition:var(--qph-transition);
  box-shadow:var(--qph-shadow-red);
}
.qph-chatbot-form-submit:hover{
  transform:translateY(-2px);
  box-shadow:var(--qph-shadow-red-lg);
  filter:brightness(1.05);
}
.qph-chatbot-form-submit:disabled{
  opacity:0.6;
  cursor:not-allowed;
  transform:none;
}

/* ---------- LOADING ---------- */
.qph-chatbot-loading{
  display:flex;
  justify-content:center;
  gap:8px;
  padding:30px 0;
}
.qph-chatbot-loading span{
  width:10px;
  height:10px;
  border-radius:50%;
  background:#cbd5e1;
  animation:qph-bounce 1.2s infinite ease-in-out;
}
.qph-chatbot-loading span:nth-child(2){animation-delay:0.15s;}
.qph-chatbot-loading span:nth-child(3){animation-delay:0.3s;}
@keyframes qph-bounce{
  0%,80%,100%{transform:translateY(0);opacity:0.5;}
  40%{transform:translateY(-8px);opacity:1;}
}

/* Skeleton */
.qph-chatbot-skeleton{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.qph-chatbot-skeleton-row{
  height:52px;
  border-radius:var(--qph-radius);
  background:linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size:200% 100%;
  animation:qph-shimmer 1.4s infinite;
}
@keyframes qph-shimmer{
  from{background-position:200% 0;}
  to{background-position:-200% 0;}
}

/* ---------- EMPTY STATE ---------- */
.qph-chatbot-empty{
  text-align:center;
  padding:36px 20px;
  background:var(--qph-surface);
  border-radius:var(--qph-radius);
  border:2px dashed var(--qph-border);
  animation:qph-msg-in 0.25s var(--qph-ease) both;
}
.qph-chatbot-empty-icon{
  font-size:2.4rem;
  margin-bottom:10px;
  display:block;
}
.qph-chatbot-empty h4{
  font-size:0.95rem;
  font-weight:800;
  margin:0 0 6px;
  color:var(--qph-text);
}
.qph-chatbot-empty p{
  color:var(--qph-text-light);
  font-size:0.85rem;
  margin:0 0 16px;
  line-height:1.5;
}

/* ---------- QUICK REPLIES (chips) ---------- */
.qph-chatbot-chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:14px;
}
.qph-chatbot-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 14px;
  background:var(--qph-surface);
  border:1.5px solid var(--qph-border);
  border-radius:50px;
  font-size:0.8rem;
  font-weight:700;
  color:var(--qph-text-mid);
  cursor:pointer;
  transition:var(--qph-transition);
  font-family:inherit;
  box-shadow:var(--qph-shadow-sm);
}
.qph-chatbot-chip:hover{
  border-color:var(--qph-primary);
  color:var(--qph-primary);
  background:var(--qph-primary-light);
  transform:translateY(-1px);
}

/* ---------- FOOTER ---------- */
#qph-chatbot-footer{
  padding:10px 16px;
  background:var(--qph-surface);
  border-top:1px solid var(--qph-border);
  text-align:center;
  flex-shrink:0;
}
.qph-chatbot-footer-link{
  font-size:0.78rem;
  color:var(--qph-text-light);
  text-decoration:none;
  font-weight:600;
  transition:color 0.2s;
}
.qph-chatbot-footer-link:hover{
  color:var(--qph-primary);
}

/* ---------- SUCCESS / ERROR MESSAGES ---------- */
.qph-chatbot-alert{
  padding:14px 16px;
  border-radius:var(--qph-radius);
  margin-bottom:14px;
  font-size:0.88rem;
  font-weight:600;
  animation:qph-msg-in 0.25s var(--qph-ease) both;
}
.qph-chatbot-alert--success{
  background:#f0fdf4;
  border:1.5px solid #bbf7d0;
  color:#166534;
}
.qph-chatbot-alert--error{
  background:var(--qph-primary-light);
  border:1.5px solid #fecaca;
  color:#991b1b;
}

/* ---------- ANIMACIONES DE ENTRADA STAGGER ---------- */
.qph-chatbot-stagger > *:nth-child(1){animation-delay:0.02s;}
.qph-chatbot-stagger > *:nth-child(2){animation-delay:0.06s;}
.qph-chatbot-stagger > *:nth-child(3){animation-delay:0.10s;}
.qph-chatbot-stagger > *:nth-child(4){animation-delay:0.14s;}
.qph-chatbot-stagger > *:nth-child(5){animation-delay:0.18s;}
.qph-chatbot-stagger > *:nth-child(6){animation-delay:0.22s;}

/* ---------- RESPONSIVE ---------- */
@media (max-width:480px){
  #qph-chatbot-window{
    left:8px;
    right:8px;
    width:auto;
    height:78vh;
    bottom:84px;
    border-radius:var(--qph-radius);
  }
  #qph-chatbot-toggle{
    right:14px;
    bottom:14px;
    width:56px;
    height:56px;
  }
  .qph-chatbot-btn-grid{
    grid-template-columns:1fr;
  }
  .qph-chatbot-card img{
    width:72px;
    height:72px;
  }
}

@media (max-width:380px){
  #qph-chatbot-window{
    left:6px;
    right:6px;
    height:82vh;
  }
  #qph-chatbot-messages{
    padding:12px;
  }
}
