/* ==========================================================================
   Siempre Contigo - Interactive Support Chatbot
   Inspired by First Union Home (wp-openai-chatbot-direct architecture)
   ========================================================================== */

#wp-openai-chatbot {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10000;
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  -webkit-font-smoothing: antialiased;
}

/* Floating Launch Button */
.wp-openai-chatbot__toggle {
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--navy, #143B6E) 0%, #1e4d8c 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px -4px rgba(20, 59, 110, 0.45), 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, opacity 0.25s ease;
  position: relative;
  outline: none;
}

.wp-openai-chatbot__toggle:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 16px 32px -4px rgba(20, 59, 110, 0.55), 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wp-openai-chatbot__toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
}

/* Texto solo para lectores de pantalla: visible para tecnologías de asistencia, oculto a la vista */
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wp-openai-chatbot__badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  background-color: #25D366;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  animation: pulse-online 2.5s infinite;
}

@keyframes pulse-online {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
  70% { box-shadow: 0 0 0 7px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

#wp-openai-chatbot.active .wp-openai-chatbot__toggle {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
  visibility: hidden;
}

/* Prevent hidden panel from taking layout space and pushing toggle button */
.wp-openai-chatbot__panel[hidden],
#wp-openai-chatbot:not(.active) .wp-openai-chatbot__panel {
  display: none !important;
}

/* Chat Main Panel */
.wp-openai-chatbot__panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 550px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 45px -8px rgba(20, 59, 110, 0.28), 0 6px 16px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(20, 59, 110, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

#wp-openai-chatbot.active .wp-openai-chatbot__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* Header */
.wp-openai-chatbot__header {
  background: linear-gradient(135deg, var(--navy, #143B6E) 0%, #174580 100%);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.wp-openai-chatbot__header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wp-openai-chatbot__avatar-header-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.wp-openai-chatbot__avatar-header {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background-color: var(--beige-calido, #F4EDE3);
  display: block;
}

.wp-openai-chatbot__avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background-color: #25D366;
  border: 2px solid var(--navy, #143B6E);
  border-radius: 50%;
}

.wp-openai-chatbot__header-info {
  display: flex;
  flex-direction: column;
}

.wp-openai-chatbot__title {
  font-family: var(--font-heading, Montserrat, sans-serif);
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  line-height: 1.25;
}

.wp-openai-chatbot__subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.wp-openai-chatbot__status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #25D366;
  display: inline-block;
}

.wp-openai-chatbot__close {
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.2s;
  outline: none;
}

.wp-openai-chatbot__close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

/* Quick Channels Bar under Header */
.wp-openai-chatbot__quick-bar {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  flex-shrink: 0;
}

.wp-openai-chatbot__quick-bar a {
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  font-weight: 600;
  color: var(--navy, #143B6E);
  transition: color 0.2s;
}

.wp-openai-chatbot__quick-bar a:hover {
  color: var(--gold, #D7A25C);
}

.wp-openai-chatbot__quick-bar a.quick-wa {
  color: #128C7E;
}

.wp-openai-chatbot__quick-bar a.quick-wa:hover {
  color: #075E54;
}

/* Messages area */
.wp-openai-chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wp-openai-chatbot__messages::-webkit-scrollbar {
  width: 6px;
}
.wp-openai-chatbot__messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* Message items */
.wp-openai-chatbot__message {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: message-slide-in 0.25s ease forwards;
}

@keyframes message-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.wp-openai-chatbot__message--bot {
  align-self: flex-start;
}

.wp-openai-chatbot__message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.wp-openai-chatbot__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 4px;
  border: 1px solid rgba(20, 59, 110, 0.15);
}

.wp-openai-chatbot__content {
  display: flex;
  flex-direction: column;
}

.wp-openai-chatbot__bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  word-break: break-word;
}

.wp-openai-chatbot__message--bot .wp-openai-chatbot__bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-top-left-radius: 4px;
}

.wp-openai-chatbot__message--user .wp-openai-chatbot__bubble {
  background: var(--navy, #143B6E);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.wp-openai-chatbot__name {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy, #143B6E);
  margin-bottom: 4px;
}

.wp-openai-chatbot__message--user .wp-openai-chatbot__name {
  color: rgba(255, 255, 255, 0.85);
  text-align: right;
}

.wp-openai-chatbot__time {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 3px;
}

.wp-openai-chatbot__message--user .wp-openai-chatbot__time {
  text-align: right;
}

.wp-openai-chatbot__bubble p {
  margin: 0 0 6px;
}
.wp-openai-chatbot__bubble p:last-child {
  margin-bottom: 0;
}

/* Quick Action Chips */
.wp-openai-chatbot__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.wp-openai-chatbot__chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--navy, #143B6E);
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  text-align: left;
}

.wp-openai-chatbot__chip:hover {
  background: var(--navy, #143B6E);
  color: #ffffff;
  border-color: var(--navy, #143B6E);
  transform: translateY(-1px);
}

/* Thinking Indicator */
.wp-openai-chatbot__thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
}

.wp-openai-chatbot__dot {
  width: 7px;
  height: 7px;
  background-color: var(--navy, #143B6E);
  border-radius: 50%;
  animation: typing-dot 1.4s infinite ease-in-out;
}
.wp-openai-chatbot__dot:nth-child(1) { animation-delay: 0s; }
.wp-openai-chatbot__dot:nth-child(2) { animation-delay: 0.2s; }
.wp-openai-chatbot__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Form input at bottom */
.wp-openai-chatbot__form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.wp-openai-chatbot__input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1e293b;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.wp-openai-chatbot__input:focus {
  border-color: var(--navy, #143B6E);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(20, 59, 110, 0.12);
}

.wp-openai-chatbot__submit {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--navy, #143B6E);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.15s;
  flex-shrink: 0;
  outline: none;
}

.wp-openai-chatbot__submit:hover {
  background: var(--gold, #D7A25C);
  transform: scale(1.05);
}

.wp-openai-chatbot__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Person Request / Lead Form Inside Chat */
.wp-openai-chatbot__person-request-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  background: #f1f5f9;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

.wp-openai-chatbot__person-request-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wp-openai-chatbot__person-request-field input,
.wp-openai-chatbot__person-request-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #1e293b;
  outline: none;
}

.wp-openai-chatbot__person-request-field input:focus,
.wp-openai-chatbot__person-request-field textarea:focus {
  border-color: var(--navy, #143B6E);
}

.wp-openai-chatbot__person-request-submit {
  align-self: flex-start;
  background: var(--navy, #143B6E);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  transition: background-color 0.2s;
}

.wp-openai-chatbot__person-request-submit:hover {
  background: var(--gold, #D7A25C);
}

.wp-openai-chatbot__person-request-status {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 600;
}
.wp-openai-chatbot__person-request-status.is-success {
  color: #15803d;
}
.wp-openai-chatbot__person-request-status.is-error {
  color: #b91c1c;
}

/* Responsive Rules */
@media (max-width: 768px) {
  #wp-openai-chatbot {
    right: 16px;
    bottom: 72px; /* Positioned right above the mobile bottom bar */
  }

  .wp-openai-chatbot__toggle {
    width: 54px;
    height: 54px;
  }

  .wp-openai-chatbot__panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 110px);
    max-height: 520px;
    bottom: 0;
    right: 0;
  }
}
