/* Estilos para el chatbot profesional */

/* Contenedor principal del chatbot */
#chatbot-container {
    font-family: "Geogrotesque Cyr", sans-serif;
    position: fixed;
    bottom: 30px; /* Bajado de 100px a 30px para posicionarlo más abajo */
    right: 30px; /* Restaurado a la derecha como estaba originalmente */
    z-index: 1000; /* Mayor que WhatsApp (999) para estar por encima */
    --chat-primary: var(--Rojo, #e31e24);
    --chat-primary-dark: #c41c1c;
    --chat-text-light: #fff;
    --chat-text-dark: #333;
    --chat-bg-light: #f8f9fa;
    --chat-bg-dark: #f0f0f0;
    --chat-border: #e0e0e0;
    --chat-shadow: rgba(0, 0, 0, 0.1);
}

/* Fondo de bloqueo cuando el chat está abierto en móvil */
@media (max-width: 768px) {
  #chatbot-container.chat-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 999;
  }
}

.chat-promo {
    position: inherit;
    right: 87px;
    bottom: 44px;
    background: #fff;
    color: #333;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 12px;
    z-index: 1001;
    animation: promoIn .25s ease-out;
}
.chat-promo:after {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 16px;
  width: 0;
  height: 0;
  border-left: 8px solid #fff;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}
.chat-promo-icon {
  width: 24px;
  height: 24px;
}
.chat-promo-text strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}
.chat-promo-text span {
  display: block;
  font-size: 12px;
  color: #666;
}
.chat-promo-cta {
  background: var(--chat-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.chat-promo-close {
  background: transparent;
  border: none;
  color: #999;
  font-size: 16px;
  cursor: pointer;
}
@keyframes promoIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .chat-promo {
    right: 70px;
    bottom: 37px;
    padding: 12px;
  }
}

/* Icono del chat */
.chat-icon {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px var(--chat-shadow);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.chat-icon::before { content: ''; display: none; }
.chat-icon:hover::before { display: none; }

.chat-icon:hover {
    transform: scale(1.1);
    background-color: var(--chat-primary-dark);
    box-shadow: 0 6px 12px var(--chat-shadow);
}

.chat-icon img {
    width: 30px;
    height: 30px;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(227, 30, 36, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(227, 30, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(227, 30, 36, 0); }
}

/* Ventana del chat */
.chat-window {
    position: absolute;
    bottom: 0px;
    right: 0; /* Restaurado a la posición original */
    width: 360px;
    height: 460px;
    background-color: var(--chat-text-light);
    border-radius: 15px;
    box-shadow: 0 8px 25px var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--chat-border);
}

.chat-window.desktop-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 25vw;
  height: 100vh;
  border-radius: 0;
  z-index: 1000;
}

.chat-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

/* Encabezado del chat */
.chat-header {
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--chat-text-light);
    display: flex;
    align-items: center;
}

.chat-header h3::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #4CAF50;
    border-radius: 50%;
    margin-right: 8px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

.chat-close {
    background: none;
    border: none;
    color: var(--chat-text-light);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-actions { display:flex; align-items:center; gap:8px; }
.chat-maximize { background:none; border:none; color: var(--chat-text-light); font-size:16px; cursor:pointer; }

.chat-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--chat-bg-light);
    scrollbar-width: thin;
    scrollbar-color: var(--chat-border) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--chat-border);
    border-radius: 10px;
}

/* Estilos de mensajes */
.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 2px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px var(--chat-shadow);
    position: relative;
    transition: transform 0.2s;
}

.chat-message:hover {
    transform: translateY(-2px);
}

.chat-message p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.bot-message {
    align-self: flex-start;
    background-color: var(--chat-bg-dark);
    color: var(--chat-text-dark);
    border-bottom-left-radius: 4px;
}

.bot-message::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 12px;
    height: 12px;
    background-color: var(--chat-bg-dark);
    border-radius: 0 0 12px 0;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.user-message {
    align-self: flex-end;
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    border-bottom-right-radius: 4px;
}

.user-message::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -6px;
    width: 12px;
    height: 12px;
    background-color: var(--chat-primary);
    border-radius: 0 0 0 12px;
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}

/* Timestamp y metadatos del mensaje */
.message-meta {
    font-size: 10px;
    margin-top: 5px;
    opacity: 0.7;
}

.bot-message .message-meta {
    text-align: left;
}

.user-message .message-meta {
    text-align: right;
}

/* Estilo para la hora del mensaje */
.message-timestamp {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 3px;
    color: inherit;
}

.message-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3px;
}

.bot-message .message-timestamp,
.bot-message .message-info {
    text-align: left;
}

.user-message .message-timestamp {
    text-align: right;
}

/* Feedback de mensajes */
.message-feedback {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.bot-message:hover .message-feedback {
    opacity: 1;
}

.feedback-btn {
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.feedback-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.feedback-btn.positive {
    color: #4CAF50;
}

.feedback-btn.negative {
    color: #F44336;
}

.feedback-thanks {
    font-size: 11px;
    color: #4CAF50;
    font-style: italic;
}

/* Indicador de escritura */
.typing-indicator {
    background-color: rgba(240, 240, 240, 0.7);
    padding: 8px 12px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: inline-block;
    margin-bottom: 10px;
    align-self: flex-start;
}

.typing-indicator p {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    margin: 0;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background-color: var(--chat-primary);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    opacity: 0.4;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Sugerencias de mensajes */
.chat-suggestions {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 15px;
    background-color: var(--chat-bg-light);
    border-top: 1px solid var(--chat-border);
}

.suggestion-btn {
    background-color: var(--chat-bg-dark);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* max-width: 150px; */
    color: var(--chat-text-dark);
}

.suggestion-btn:hover {
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    border-color: var(--chat-primary);
}

/* Área de entrada de texto */
.chat-input-container {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    background-color: var(--chat-text-light);
    position: relative;
}

.chat-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    box-shadow: 0 1px 3px var(--chat-shadow);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 1px 5px rgba(227, 30, 36, 0.2);
}

.chat-input::placeholder {
    color: #999;
    font-style: italic;
}

.chat-send {
    background-color: var(--chat-primary);
    color: var(--chat-text-light);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    box-shadow: 0 2px 5px var(--chat-shadow);
}

.chat-send:hover {
    background-color: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chat-send:active {
    transform: scale(0.95);
}

.chat-send i {
    font-size: 18px;
}

/* Enlaces en mensajes */
.chat-message a {
    color: var(--chat-primary);
    text-decoration: none;
    border-bottom: 1px dotted;
    transition: border-bottom 0.2s;
}

.chat-message a:hover {
    border-bottom: 1px solid;
}

.user-message a {
    color: var(--chat-text-light);
    font-weight: bold;
}

/* Elementos de lista en mensajes */
.list-item {
    display: block;
    margin: 5px 0;
}

/* Responsive */
@media (max-width: 480px) {
    #chatbot-container {
        bottom: 20px; /* Ajustado para que esté más abajo en móviles */
        right: 15px; /* Restaurado a la derecha con margen reducido en móviles */
    }
    
    .chat-window {
        width: 350px;
        height: 500px;
        right: 0;
        bottom: 0px;
    }
    
    .chat-icon {
        width: 60px;
        height: 60px;
    }
    
    .chat-icon img {
        width: 30px;
        height: 30px;
    }
    
    .suggestion-btn {
        /* max-width: 120px; */
        font-size: 13px;
        padding: 5px 10px;
    }
}

@media (max-width: 768px) {
  .chat-window.chat-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: calc(var(--vh, 1vh) * 100);
    border-radius: 0;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
  }
  body.chatbot-fullscreen-open {
    overflow: hidden;
  }
  .chat-window.chat-fullscreen .chat-input-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0);
    background: var(--chat-text-light);
    z-index: 1002;
  }
  .chat-window.chat-fullscreen .chat-messages {
    padding-bottom: 140px;
  }
  .chat-input {
    font-size: 16px; /* evitar zoom en iOS */
  }

  /* Sugerencias visibles por completo, arriba del input */
  .chat-window.chat-fullscreen .chat-suggestions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0) + 64px);
    background: var(--chat-bg-light);
    border-top: 1px solid var(--chat-border);
    z-index: 1001;
    display: flex !important;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .chat-window.chat-fullscreen .chat-suggestions::-webkit-scrollbar {
    height: 6px;
  }
  .chat-window.chat-fullscreen .chat-suggestions::-webkit-scrollbar-thumb {
    background-color: var(--chat-border);
    border-radius: 10px;
  }
  .chat-window.chat-fullscreen .suggestion-btn {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    font-size: 13px;
    padding: 8px 12px;
  }
}
