/* Fonts */
@font-face {
  font-family: "Monument Extended";
  src: url("../fonts/MonumentExtended/MonumentExtended-Regular.otf")
    format("opentype");
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins/Poppins-Regular.ttf") format("truetype");
}

/* BEAT Chat Widget Styles */
.beat-chat-widget-container {
  position: fixed;
  bottom: 20px;
  z-index: 999999;
  transform: scale(var(--bcw-zoom, 100%));
}

.beat-chat-widget-position-right {
  right: 20px;
  transform-origin: bottom right;
}

.beat-chat-widget-position-left {
  left: 20px;
  transform-origin: bottom left;
}

.beat-chat-widget-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
  padding: 0 !important;
}

.chat-toggle {
  width: 100% !important;
  height: 100% !important;
}

.beat-chat-widget-button .beat-icon.chat-open,
.beat-chat-widget-button .bot-icon.chat-open {
  display: block;
}

.beat-chat-widget-button .beat-icon,
.beat-chat-widget-button .bot-icon {
  display: none;
}

.beat-chat-widget-button:hover {
  transform: scale(1.05);
}

.beat-chat-widget-open .beat-chat-widget-button {
  transform: scale(0.9);
}

.beat-chat-widget-icon {
  background-color: var(--bcw-color);
  border-radius: 50%;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.beat-chat-widget-svg-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.beat-chat-widget-svg-icon img,
.beat-chat-widget-svg-icon .svg-icon,
.beat-svg-wrapper img {
  max-width: 60%;
  max-height: 60%;
  width: 24px !important;
  height: 24px !important;
  filter: brightness(0) invert(1); /* Makes the SVG white */
  object-fit: contain;
}

.beat-svg-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.beat-chat-widget-popup {
  position: absolute;
  bottom: 80px;
  width: 500px;
  height: 500px;
  background-color: var(--bcw-color);
  border-radius: var(--bcw-border-radius, 24px);
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(20px);
  padding: 0.5rem;
}

.beat-chat-widget-popup-open {
  opacity: 1;
  transform: translateY(0);
}

.beat-chat-widget-position-right .beat-chat-widget-popup {
  right: 0;
}

.beat-chat-widget-position-left .beat-chat-widget-popup {
  left: 0;
}

/** Chat Header **/
.beat-chat-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
}

.beat-chat-widget-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  color: white;
  font-family: "Monument Extended", sans-serif;
  font-size: 18px;
  font-weight: 300;
  border-radius: var(--bcw-border-radius, 16px) var(--bcw-border-radius, 16px) 0
    0;
}

.beat-chat-header-icon-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.beat-chat-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background-color: #2ecc71; /* Green */
  border-radius: 50%;
  border: 2px solid var(--bcw-color); /* Match header bg */
  box-sizing: content-box;
}

.chat-icon {
  width: 32px;
  height: 32px;
}

.beat-chat-widget-close {
  background: none;
  border: none;
  color: white;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 50%;
}

.beat-chat-widget-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.beat-chat-widget-chat-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #f3f4f7;
  border-radius: var(--bcw-border-radius, 24px) var(--bcw-border-radius, 24px) 0
    0;
  display: flex;
  flex-direction: column;
}

/** Chat body **/
.beat-chat-widget-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-height: 0; /* Important for flex scrolling */
}

.beat-chat-widget-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: "Poppins", sans-serif;
}
.message-content p {
  padding: 12px 16px !important;
  font-size: 14px;
  line-height: 1.5;
}

.message-content li {
  font-size: 14px;
  line-height: 1.5;
}

/* Mensaje del bot - alineado a la IZQUIERDA */
.bot-message {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

.bot-message-content {
  background-color: white;
  color: #333;
  border-radius: 4px 16px 16px 16px;
  margin: 1rem 0 0 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
}

/* Estilos para el HTML generado por marked dentro del mensaje del bot */
.bot-message-content p {
  margin: 0 0 8px 0;
  padding: 0 !important;
}

.bot-message-content p:last-child {
  margin-bottom: 0;
}

.bot-message-content strong,
.bot-message-content b {
  font-weight: 600;
  color: #222;
}

.bot-message-content em,
.bot-message-content i {
  font-style: italic;
}

.bot-message-content ul,
.bot-message-content ol {
  margin: 6px 0;
  padding-left: 20px;
}

.bot-message-content ul {
  list-style-type: disc;
}

.bot-message-content ol {
  list-style-type: decimal;
}

.bot-message-content li {
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.5;
}

.bot-message-content code {
  background-color: #f0f0f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 13px;
}

.bot-message-content pre {
  background-color: #f0f0f0;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
}

.bot-message-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}

.bot-message-content a {
  color: var(--bcw-color);
  text-decoration: underline;
}

.bot-message-content h1,
.bot-message-content h2,
.bot-message-content h3 {
  font-weight: 600;
  margin: 8px 0 4px 0;
  line-height: 1.3;
}

.bot-message-content h1 {
  font-size: 16px;
}
.bot-message-content h2 {
  font-size: 15px;
}
.bot-message-content h3 {
  font-size: 14px;
}
.bot-icon {
  width: 40px;
  height: 40px;
  display: block;
  flex-shrink: 0;
}
/* Mensaje del usuario - alineado a la DERECHA */
.user-message {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  flex-direction: row-reverse;
}

.user-message p {
  background-color: var(--bcw-color);
  color: white;
  border-radius: 16px 4px 16px 16px;
  margin: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message {
  position: relative;
}

.chat-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  display: block;
}

.bot-message .chat-time {
  text-align: left;
}

.user-message .chat-time {
  text-align: right;
}

.user-message::after {
  text-align: left;
}

/** Chat Footer **/
.beat-chat-widget-footer {
  padding: 16px;
  background-color: #f5f5f5;
  border-radius: 0 0 var(--bcw-border-radius, 24px)
    var(--bcw-border-radius, 24px);
}

.beat-chat-widget-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: white;
  border: 1px solid #a7a7a7;
  border-radius: var(--bcw-border-radius, 24px);
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.beat-chat-widget-input textarea {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: #333;
  background: transparent;
  resize: none;
}
.beat-chat-widget-input textarea::placeholder {
  color: #7b7b7b;
  font-weight: 400;
  font-family: "Poppins", sans-serif;
}

.beat-chat-widget-input-send-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bcw-color); /* Color from admin settings */
  transition: color 0.2s;
}

.beat-chat-widget-input-send-button:disabled {
  color: #cccccc; /* Gray when disabled */
  cursor: not-allowed;
}

.beat-chat-widget-input-send-button:not(:disabled):hover {
  color: var(--bcw-color-dark); /* Darker shade on hover */
}

/* Loading indicator */
.beat-chat-widget-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  z-index: 1;
}

.beat-chat-widget-loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #45d3d3;
  border-radius: 50%;
  animation: beat-chat-widget-spin 1s linear infinite;
}

@keyframes beat-chat-widget-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
  .beat-chat-widget-popup {
    width: calc(100vw - 40px);
    max-width: 500px;
    height: calc(100vh - 120px);
    max-height: 80vh;
    position: fixed;
    bottom: 90px !important;
    border-radius: var(--bcw-border-radius, 16px);
    margin: 0;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
  }

  /* Centrar el popup en móviles - sobrescribir las reglas de posición */
  .beat-chat-widget-position-right .beat-chat-widget-popup,
  .beat-chat-widget-position-left .beat-chat-widget-popup {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
  }

  .beat-chat-widget-button {
    width: 56px;
    height: 56px;
  }

  /* Hide button when chat is open on mobile */
  .beat-chat-widget-open .beat-chat-widget-button {
    display: none !important;
  }

  .beat-chat-widget-icon {
    font-size: 22px;
  }

  .beat-chat-widget-svg-icon img,
  .beat-chat-widget-svg-icon .svg-icon,
  .beat-svg-wrapper img {
    width: 22px !important;
    height: 22px !important;
  }
}

/* Mobile landscape orientation - horizontal mode */
@media (max-height: 500px) and (orientation: landscape) {
  .beat-chat-widget-popup {
    width: auto;
    max-width: 450px;
    height: calc(100vh - 110px) !important;
    max-height: calc(100vh - 110px) !important;
    position: fixed;
    bottom: 90px !important;
    border-radius: 12px;
  }

  .beat-chat-widget-position-right .beat-chat-widget-popup {
    right: 20px !important;
    left: auto !important;
  }

  .beat-chat-widget-position-left .beat-chat-widget-popup {
    left: 20px !important;
    right: auto !important;
  }

  .beat-chat-widget-title {
    padding: 12px 16px;
    font-size: 16px;
  }

  .beat-chat-widget-body {
    padding: 12px;
  }

  .beat-chat-widget-footer {
    padding: 12px;
  }
}

/* Typing Indicator */
.typing-indicator {
  padding: 12px 16px;
  background-color: transparent;
  border-radius: 16px 16px 16px 4px;
  /* display: inline-block; */ /* Removed to work better with flex if needed, or keep if it's the bubble */
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px; /* Add some spacing since padding might feel empty, or keep padding */
}

.typing-dots span {
  width: 10px;
  height: 10px;
  background-color: var(--bcw-color);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
  background-color: var(--bcw-color);
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
  opacity: 0.75;
}

.typing-dots span:nth-child(3) {
  opacity: 0.5;
  animation-delay: 0s;
}

/* Updated animation to pulse opacity instead of scale to keep them visible but fading */
@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Quick Reply Options */
.beat-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
  width: 100%;
}

.beat-chat-option-btn {
  background-color: var(--bcw-color);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "Poppins", sans-serif;
  font-weight: 400;
  white-space: normal; /* Allow text to wrap if needed */
  text-align: center;
  flex-grow: 1; /* Make buttons expand */
  display: flex;
  align-items: center;
  justify-content: center;
}

.beat-chat-option-btn:hover {
  background-color: var(--bcw-color-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.beat-chat-option-btn:active {
  transform: translateY(0);
}
