/* ============================================
   Paycaster Chatbot Widget
   Componente reutilizable - no modifica estilos del sitio
   ============================================ */

#pc-chatbot-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #034346 0%, #01a522 60%, #d4ff32 100%);
  box-shadow: 0 4px 24px rgba(1, 165, 34, 0.45), 0 0 0 0 rgba(212, 255, 50, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: pc-pulse 2.8s infinite;
  outline: none;
  padding: 0;
}

#pc-chatbot-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(1, 165, 34, 0.6), 0 0 0 8px rgba(212, 255, 50, 0.15);
  animation: none;
}

#pc-chatbot-btn:focus-visible {
  outline: 3px solid #d4ff32;
  outline-offset: 3px;
}

#pc-chatbot-btn .pc-btn-icon {
  width: 30px;
  height: 30px;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pc-chatbot-btn .pc-btn-icon--close {
  display: none;
}

#pc-chatbot-btn.is-open .pc-btn-icon--chat {
  display: none;
}

#pc-chatbot-btn.is-open .pc-btn-icon--close {
  display: flex;
}

#pc-chatbot-btn.is-open {
  animation: none;
  background: linear-gradient(135deg, #034346 0%, #09353c 100%);
}

@keyframes pc-pulse {
  0%   { box-shadow: 0 4px 24px rgba(1,165,34,0.45), 0 0 0 0 rgba(212,255,50,0.4); }
  60%  { box-shadow: 0 4px 24px rgba(1,165,34,0.45), 0 0 0 14px rgba(212,255,50,0); }
  100% { box-shadow: 0 4px 24px rgba(1,165,34,0.45), 0 0 0 0 rgba(212,255,50,0); }
}

/* Tooltip */
#pc-chatbot-btn::before {
  content: "¿En qué te ayudo?";
  position: absolute;
  right: 74px;
  bottom: 50%;
  transform: translateY(50%);
  background: #034346;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

#pc-chatbot-btn::after {
  content: "";
  position: absolute;
  right: 68px;
  bottom: 50%;
  transform: translateY(50%);
  border: 6px solid transparent;
  border-left-color: #034346;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#pc-chatbot-btn:hover::before,
#pc-chatbot-btn:hover::after {
  opacity: 1;
}

#pc-chatbot-btn.is-open::before,
#pc-chatbot-btn.is-open::after {
  display: none;
}

/* ============================================
   Chat Window
   ============================================ */

#pc-chatbot-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 9998;
  width: 370px;
  max-height: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(3, 67, 70, 0.22), 0 2px 12px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}

#pc-chatbot-window.is-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.pc-chat-header {
  background: linear-gradient(135deg, #034346 0%, #01a522 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.pc-chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pc-chat-header-avatar svg {
  width: 22px;
  height: 22px;
}

.pc-chat-header-info {
  flex: 1;
}

.pc-chat-header-name {
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.pc-chat-header-status {
  color: #d4ff32;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.pc-chat-header-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d4ff32;
  display: inline-block;
  animation: pc-blink 1.8s infinite;
}

@keyframes pc-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Messages area */
.pc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7f9fa;
  scroll-behavior: smooth;
}

.pc-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.pc-chat-messages::-webkit-scrollbar-track { background: transparent; }
.pc-chat-messages::-webkit-scrollbar-thumb {
  background: #c8d6d7;
  border-radius: 4px;
}

/* Message bubbles */
.pc-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: pc-msg-in 0.2s ease;
}

@keyframes pc-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pc-msg--bot { align-self: flex-start; }
.pc-msg--user { align-self: flex-end; }

.pc-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.pc-msg--bot .pc-msg-bubble {
  background: #fff;
  color: #1a2e2f;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Markdown styles inside bot bubble */
.pc-msg--bot .pc-msg-bubble p { margin: 0 0 8px; }
.pc-msg--bot .pc-msg-bubble p:last-child { margin-bottom: 0; }
.pc-msg--bot .pc-msg-bubble h1,
.pc-msg--bot .pc-msg-bubble h2,
.pc-msg--bot .pc-msg-bubble h3 {
  font-size: 13px;
  font-weight: 700;
  color: #034346;
  margin: 10px 0 4px;
}
.pc-msg--bot .pc-msg-bubble strong { font-weight: 600; color: #034346; }
.pc-msg--bot .pc-msg-bubble em { font-style: italic; }
.pc-msg--bot .pc-msg-bubble hr {
  border: none;
  border-top: 1px solid #e0eaeb;
  margin: 8px 0;
}
.pc-msg--bot .pc-msg-bubble ul,
.pc-msg--bot .pc-msg-bubble ol {
  margin: 4px 0 8px 16px;
  padding: 0;
}
.pc-msg--bot .pc-msg-bubble li { margin-bottom: 3px; }
.pc-msg--bot .pc-msg-bubble code {
  background: #f0f5f5;
  color: #034346;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}
.pc-msg--bot .pc-msg-bubble pre {
  background: #f0f5f5;
  padding: 8px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
}
.pc-msg--bot .pc-msg-bubble pre code {
  background: none;
  padding: 0;
  font-size: 12px;
}
.pc-msg--bot .pc-msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 6px 0;
}
.pc-msg--bot .pc-msg-bubble th {
  background: #034346;
  color: #d4ff32;
  padding: 5px 8px;
  text-align: left;
  font-weight: 600;
}
.pc-msg--bot .pc-msg-bubble td {
  padding: 5px 8px;
  border-bottom: 1px solid #e0eaeb;
}
.pc-msg--bot .pc-msg-bubble tr:last-child td { border-bottom: none; }
.pc-msg--bot .pc-msg-bubble tr:nth-child(even) td { background: #f7fafa; }

.pc-msg--user .pc-msg-bubble {
  background: linear-gradient(135deg, #034346, #01a522);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.pc-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  width: fit-content;
  align-self: flex-start;
}

.pc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #034346;
  animation: pc-bounce 1.2s infinite;
}
.pc-typing span:nth-child(2) { animation-delay: 0.2s; }
.pc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.pc-chat-input-area {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e8eeef;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#pc-chat-input {
  flex: 1;
  border: 1.5px solid #d0dfe0;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: #1a2e2f;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 42px;
  line-height: 1.4;
  transition: border-color 0.2s;
  background: #f7f9fa;
}

#pc-chat-input:focus {
  border-color: #01a522;
  background: #fff;
}

#pc-chat-input::placeholder {
  color: #9ab0b1;
}

#pc-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #034346, #01a522);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  outline: none;
}

#pc-chat-send:hover { transform: scale(1.08); }
#pc-chat-send:active { transform: scale(0.95); }
#pc-chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
#pc-chat-send:focus-visible { outline: 2px solid #d4ff32; outline-offset: 2px; }

.pc-chat-footer {
  text-align: center;
  padding: 6px 0 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: #9ab0b1;
  background: #fff;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 480px) {
  #pc-chatbot-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 96px;
    max-height: 70vh;
  }
  #pc-chatbot-btn {
    right: 16px;
    bottom: 20px;
  }
}
