/**
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 * We offer the best and most useful modules PrestaShop and modifications for your online store.
 * 
 * @author    Carlos Ucha
 * @copyright 2010-2100 Carlos Ucha
 * @license   see file: LICENSE.txt
 * This program is not free software and you can't resell and redistribute it
 *
 * CONTACT WITH DEVELOPER
 * carlosucha92@gmail.com
 */


/* CSS code for the chatbox styling */
.chatbox-embedded {
  display: flex !important;
  flex-direction: column;
  width: 100% !important;
  height: var(--height-pc, 500px) !important;
  position: relative !important;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  bottom: auto !important;
  right: auto !important;
  left: auto !important;
  top: auto !important;
}

@media (max-width: 1024px) {
  .chatbox-embedded {
    height: var(--height-tablet, 450px) !important;
  }
}

@media (max-width: 767px) {
  .chatbox-embedded {
    height: var(--height-mobile, 80%) !important;
  }
}

.chatbox {
  position: fixed;
  z-index: 9999;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  background-color: #fff;
  font-family: Arial, sans-serif;
  font-size: var(--chat-msg-font-size, 14px);
  transition: all 0.3s ease;
}

.chatbox.chatbox-closed {
  display: none !important;
}

.chatbox.bottom_right {
  bottom: var(--margin-v, 20px);
  right: var(--margin-h, 20px);
}

.chatbox.top_right {
  top: var(--margin-v, 20px);
  right: var(--margin-h, 20px);
}

.chatbox.bottom_left {
  bottom: var(--margin-v, 20px);
  left: var(--margin-h, 20px);
}

.chatbox.top_left {
  top: var(--margin-v, 20px);
  left: var(--margin-h, 20px);
}

.chatbox-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}

/* ============================================
   PREMIUM HEADER (WhatsApp Style)
   ============================================ */

.chatbox-header-premium {
  background-color: var(--header-bg, #0084ff);
  color: var(--header-text-color, #fff);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50% !important;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.chatbot-avatar-placeholder {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar-placeholder img {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
}

.chatbox-title-premium {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.3px;
}

/* ============================================
   NEW UNIFIED CLOSE ACTION
   ============================================ */
.chatbox-action-close {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  color: var(--header-text-color, #fff);
  position: relative;
  z-index: 2147483647 !important;
  /* Max z-index */
  touch-action: manipulation;
  pointer-events: auto !important;
  margin-right: -8px;
  /* Offset to align visually with edge */
}

.chatbox-action-close svg {
  width: 28px;
  height: 28px;
  pointer-events: none;
  /* SVG ignores clicks, parent handles it */
}



.chatbox-content {
  display: none;
}

.chatbox-content.open {
  display: flex;
  flex-direction: column;
  max-width: 400px;
  height: 450px;
  max-height: 100dvh;
  /* Fallback for dynamic viewport height */
}

.chatbox-embedded .chatbox-content {
  display: flex !important;
  flex-direction: column;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  flex: 1;
  /* Key to push input down */
  overflow: hidden;
}

.chatbox-embedded .chatbox-messages {
  flex: 1;
  overflow-y: auto;
}

.chatbox-embedded .chatbox-input {
  flex-shrink: 0;
}

/* Hide scrollbars globally for chat components */
.chatbox-messages,
.chatbox-input-text,
textarea {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.chatbox-messages::-webkit-scrollbar,
.chatbox-input-text::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* ============================================
   FLOATING TOGGLE BUTTON
   ============================================ */

.chatbox-toggle {
  position: fixed;
  z-index: 9998;
  min-width: var(--toggle-size, 60px);
  min-height: var(--toggle-size, 60px);
  width: auto;
  height: auto;
  padding: var(--toggle-pad-t, 10px) var(--toggle-pad-r, 20px) var(--toggle-pad-b, 10px) var(--toggle-pad-l, 20px);
  background-color: var(--toggle-bg, #0084ff);
  border-radius: 50px; /* Pill shape fallback */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, opacity 0.3s ease;
  gap: 8px;
}

/* If it's only the icon (no text) */
.chatbox-toggle:not(:has(.chatbox-toggle-text)) {
    border-radius: 50%;
    padding: 0; /* Fallback to fixed size for pure icon circle */
    width: var(--toggle-size, 60px);
    height: var(--toggle-size, 60px);
}

/* If it has text but NO icon (text only) */
.chatbox-toggle:not(:has(.floating-icon-wrapper)) {
    border-radius: 50px;
}

.chatbox-toggle-text {
    color: var(--icon-color, #ffffff);
    font-size: var(--toggle-text-size, 14px);
    font-weight: 600;
    white-space: nowrap;
}

.chatbox-toggle:hover {
  transform: scale(1.05);
}

.chatbox-toggle.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.chatbox-toggle.bottom_right {
  bottom: var(--margin-v, 20px);
  right: var(--margin-h, 20px);
}

.chatbox-toggle.bottom_left {
  bottom: var(--margin-v, 20px);
  left: var(--margin-h, 20px);
}

.chatbox-toggle.top_right {
  top: var(--margin-v, 20px);
  right: var(--margin-h, 20px);
}

.chatbox-toggle.top_left {
  top: var(--margin-v, 20px);
  left: var(--margin-h, 20px);
}

.floating-icon-wrapper {
  width: var(--icon-size, 30px);
  height: var(--icon-size, 30px);
  background-color: var(--icon-color, #ffffff);
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.header-icon-wrapper {
  width: 24px;
  height: 24px;
  background-color: var(--chat-bot-color, #ffffff);
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.chatbox-messages {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Hide scrollbar for all browsers */
  scrollbar-width: none !important;
  /* Firefox */
  -ms-overflow-style: none !important;
  /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari, Opera */
.chatbox-messages::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* ============================================
   MESSENGER-STYLE MESSAGE BUBBLES
   ============================================ */

.chatbox-messages .message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--chat-border-radius, 18px);
  font-size: var(--font-size-pc, 14px);
  line-height: 1.4;
  word-wrap: break-word;
  clear: both;
}

@media (max-width: 1024px) {
  .chatbox-messages .message {
    font-size: var(--font-size-tablet, 14px);
  }
}

@media (max-width: 767px) {
  .chatbox-messages .message {
    font-size: var(--font-size-mobile, 14px);
  }
}

/* User messages - RIGHT side (like Facebook Messenger) */
.chatbox-messages .message.user {
  align-self: flex-end !important;
  text-align: left;
  background-color: var(--chat-user-bg, #0084ff);
  color: var(--chat-user-color, #ffffff);
  border-bottom-right-radius: 4px;
  margin-left: auto !important;
  margin-right: 0 !important;
}

/* Bot/Response messages - LEFT side */
.chatbox-messages .message.response {
  align-self: flex-start !important;
  text-align: left;
  background-color: var(--chat-bot-bg, #e4e6eb);
  color: var(--chat-bot-color, #000000);
  border-bottom-left-radius: 4px;
  margin-right: auto !important;
  margin-left: 0 !important;
  font-weight: normal;
}

/* Markdown Support Styles */
.chatbox-messages .message.response p {
  margin: 0 0 8px 0;
}

.chatbox-messages .message.response p:has(img) {
  margin: 0;
  padding: 0;
}

.chatbox-messages .message.response p:last-child {
  margin-bottom: 0;
}

.chatbox-messages .message.response strong,
.chatbox-messages .message.response b {
  font-weight: 700;
}

.chatbox-messages .message.response ul,
.chatbox-messages .message.response ol {
  margin: 8px 0;
  padding-left: 20px;
}

.chatbox-messages .message.response li {
  margin-bottom: 4px;
}

/* Error messages styling */
.message.chatbot-error {
  background-color: #FFCDD2 !important;
  color: #D32F2F !important;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Consent message styling */
.chatbox-messages .message.consent {
  align-self: center;
  max-width: 100%;
  background-color: transparent;
  color: #666;
  font-size: 12px;
  text-align: center;
  padding: 5px;
}

/* ============================================
   INPUT AREA
   ============================================ */

.chatbox-input {
  display: flex;
  align-items: flex-end;
  /* Align to bottom for expanding textarea */
  padding: 10px;
  border-top: 1px solid #e4e6eb;
  gap: 8px;
}

.chatbox-input-text {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  /* Approximately 5 lines */
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 20px;
  outline: none;
  font-size: var(--font-size-pc, 14px);
  font-family: inherit;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  box-sizing: border-box;
  /* Hide scrollbar for all browsers */
  scrollbar-width: none !important;
  /* Firefox */
  -ms-overflow-style: none !important;
  /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari, Opera */
.chatbox-input-text::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}



/* Responsive font size for textarea */
@media (max-width: 1024px) {
  .chatbox-input-text {
    font-size: var(--font-size-tablet, 14px);
  }
}

@media (max-width: 767px) {
  .chatbox-input-text {
    font-size: var(--font-size-mobile, 14px);
  }
}

.chatbox-send-button {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}

.chatbox-send-button:hover {
  opacity: 0.9;
}

.chatbox-send-button.icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
}

.chatbox-send-button svg {
  width: 20px;
  height: 20px;
  fill: var(--send-icon-color, #ffffff);
  display: block;
  margin: 0 auto;
}

.chatbox-send-button:disabled,
.chatbox-send-button.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-selected {
  border: 2px solid #4b4b4b;
}

/* Additional styling to show/hide the chatbox toggle button */
.chatbox-closed .chatbox-toggle {
  display: block;
}

.chatbox-open .chatbox-toggle {
  display: none;
}

.chatbox #consent-buttons {
  padding-top: 10px;
  text-align: center;
}

.chatbox #consent-buttons button {
  margin: 0 5px;
}

/* ============================================
   WAITING DOTS ANIMATION
   ============================================ */

@keyframes dots {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

#waiting-dots {
  min-width: 60px;
  box-sizing: border-box;
}

.dot {
  display: inline-block;
  height: 8px;
  width: 8px;
  border-radius: 50%;
  background-color: var(--chat-bot-color, #666);
  margin: 0 2px;
  animation: dots 1s infinite;
  vertical-align: middle;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ============================================
   LINKS IN MESSAGES
   ============================================ */

.chatbox-messages .message a {
  color: inherit;
  text-decoration: var(--chat-link-decoration, underline);
}

.chatbox-messages .message.user a {
  color: #fff;
}

.chatbox-messages .message.response a {
  color: var(--chat-link-color, #0084ff);
}

.chatbox-messages .message.response a:has(img) {
  display: block;
  text-decoration: none !important;
  margin: 0;
  padding: 0;
  border: none;
}

.chatbox-messages .message.response img {
  max-width: 100%;
  height: auto !important;
  margin: 8px 0;
  display: block;
}

/* ============================================
   DIMENSIONES MULTIDISPOSITIVO
   ============================================ */

/* PC - Default (pantallas grandes) */
.chatbox-content.open {
  width: var(--width-pc, 400px);
  max-height: var(--height-pc, 500px);
}

/* Tablet - max-width: 1024px */
@media (max-width: 1024px) {
  .chatbox-content.open {
    width: var(--width-tablet, 350px);
    height: var(--height-tablet, 450px);
    max-height: 100dvh;
  }
}

/* Móvil - max-width: 767px */
@media (max-width: 767px) {
  .chatbox-content.open {
    width: var(--width-mobile, 90%);
    height: var(--height-mobile, 80vh);
    max-height: calc(100vh - 40px);
  }
}

/* ============================================
   MODO FULLSCREEN PARA MÓVILES REALES
   (Activado por JavaScript cuando detecta móvil real)
   La posición y altura son controladas por JavaScript
   ============================================ */
.chatbox.mobile-fullscreen {
  display: flex !important;
  flex-direction: column !important;
  border-radius: 0 !important;
  width: 100% !important;
  /* Safe area for iOS notch */
  padding-top: env(safe-area-inset-top, 0);
  box-sizing: border-box;
  overflow: hidden;
  background-color: #fff;
}

.chatbox.mobile-fullscreen .chatbox-content,
.chatbox.mobile-fullscreen .chatbox-content.open {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: var(--visual-viewport-height, 100%) !important;
  max-height: none !important;
  min-height: 0 !important;
  border-radius: 0 !important;
  overflow: hidden;
}

.chatbox.mobile-fullscreen .chatbox-header-premium {
  border-radius: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 99 !important;
}

.chatbox.mobile-fullscreen .chatbox-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.chatbox.mobile-fullscreen .chatbox-input {
  flex-shrink: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  background-color: #fff;
  /* Force visibility */
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Cuando el teclado está abierto, menos padding inferior */
.chatbox.mobile-fullscreen.keyboard-open .chatbox-input {
  padding-bottom: 10px;
}

/* ============================================
   OVERLAY DE FONDO
   ============================================ */

.chatbox-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-color, rgba(0, 0, 0, 0.5));
  z-index: var(--overlay-zindex, 9998);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.chatbox-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Responsive Overlay Visibility */
@media (min-width: 1025px) {
    .chatbox-overlay[data-pc="0"] { display: none !important; }
}
@media (min-width: 768px) and (max-width: 1024px) {
    .chatbox-overlay[data-tablet="0"] { display: none !important; }
}
@media (max-width: 767px) {
    .chatbox-overlay[data-mobile="0"] { display: none !important; }
}

/* Scroll lock for background page on mobile */
body.chatbot-no-scroll {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}
/* Shortcode Custom Button Styling */
.chatbox-custom-shortcode-btn {
    cursor: pointer;
}

.chatbox-custom-shortcode-btn.chatbox-default-style {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--toggle-bg);
    color: var(--icon-color);
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbox-custom-shortcode-btn.chatbox-default-style:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0,0,0,0.15);
}

.chatbox-custom-shortcode-btn.chatbox-default-style .shortcode-btn-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: var(--icon-color);
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    /* Uses a default chat bubble SVG data URI */
    mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z" fill="currentColor"/></svg>');
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z" fill="currentColor"/></svg>');
}

/* Responsive Visibility for Floating Toggle */
@media (min-width: 1025px) {
    .chatbox-floating-toggle[data-btn-pc="shortcode"] {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .chatbox-floating-toggle[data-btn-tablet="shortcode"] {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .chatbox-floating-toggle[data-btn-mobile="shortcode"] {
        display: none !important;
    }
}
