.scroll-indicator {
    position: absolute;
    bottom: 80px;
    right: 16px;
    font-size: 20px;
    color: white;
    padding: 8px 8px;
    cursor: pointer;
    z-index: 999;
    display: none;
    animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

#chat-box.fullscreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  padding-bottom: 1.5%;
}

#chat-box.fullscreen .chat-body {
  flex: 1;
  overflow-y: auto;
}

#chat-box.fullscreen #chat-form {
  position: sticky;
  padding: 10px;
  border-top: 1px solid #ddd;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
  bottom: 0;
}

.chat-footer {
  display: flex;
  align-items: center;
  padding: 10px;
  background: #f1f1f1;
  position: sticky;
  bottom: 0;
  width: 100%;
  z-index: 1;
  gap: 8px;
  box-sizing: border-box;
}

.chat-menu-wrapper {
  position: relative;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.chat-menu {
  position: absolute;
  top: 28px;
  right: 0;
  background: white;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 8px;
  list-style: none;
  padding: 8px 0;
  margin: 0;
  display: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-menu li {
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.chat-menu li:hover {
  background: #f1f1f1;
}

#chat-form {
  display: flex;
  align-items: flex-end;
  width: 100%;
}

#chat-input {
  flex: 1;
  resize: none;
  border-radius: 20px;
  border: 1px solid #ccc;
  padding: 10px 14px;
  margin-right: 8px;
  font-size: 14px;
  max-height: 100px;
  overflow-y: auto;
  box-sizing: border-box;
  margin-bottom: 7%;
}

.footer-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding-bottom: 11%;
}

.footer-buttons button {
  background-color: #0d6efd;
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-box {
    width: 40vh;
    height: 80vh; 
    max-height: 80vh;
    position: fixed;
    bottom: 80px;
    right: 30px;
    z-index: 1050;
    display: none;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-direction: column;
    transition: all 0.3s ease;
    border: 1px solid #ddd;
    transform: translateY(30px);
    bottom: 5%;
}

.chat-box.fullscreen {
    width: 100%;
    height: 100%;
    max-height: none;
    right: 0;
    bottom: 0;
    border-radius: 0;
}

.chat-box.dark-mode {
    background-color: #333;
    color: #fff;
}



.chat-actions button {
    margin-left: 5px;
}

:root {
    --chat-footer-height: 45%;
}

.chat-body {
    padding: 10px;
    overflow-y: auto;
    flex: 1 1 auto;
    background-color: #f9f9f9;
    max-height: 100%; /* This prevents the messages from being cut off */
    position: relative;
    padding-bottom: var(--chat-footer-height);
    box-sizing: border-box;
    
}

.chat-footer .form-control {
    resize: none;
    overflow: hidden;
    max-height: 100px;
}

.chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, transform 0.2s ease;
}

/* TamaÃ±o por defecto (para pantallas grandes/PC) */
.chat-button {
    width: 70px;
    height: 70px;
    font-size: 30px;
}

/* AnimaciÃ³n al pasar el cursor */
.chat-button:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

/* TamaÃ±o por defecto (para pantallas grandes/PC) */
.chat-button {
    width: 70px;
    height: 70px;
    font-size: 30px;
}

/* AnimaciÃ³n al pasar el cursor */
.chat-button:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}


.chat-button.notify {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(13,110,253,0.5); }
    70% { box-shadow: 0 0 0 10px rgba(13,110,253,0); }
    100% { box-shadow: 0 0 0 0 rgba(13,110,253,0); }
}

.chat-message.typing .message-text {
    font-style: italic;
    color: #888;
}

#chat-input::placeholder {
    font-style: italic;
    color: #aaa;
    padding-left: 1rem;
}

/* Contenedor general de cada mensaje */
.chat-message {
    margin: 8px 0;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);

    animation: fadeIn 0.3s ease-in-out;
    position: relative;
    display: block;

    overflow-y: auto;
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;

    overflow-wrap: break-word;
    word-break: break-word;
}

/* Mensajes del sistema o del bot */
.chat-message.bot {
    background-color: #e9ecef;
    align-self: flex-start;
    color: #212529;
    border-bottom-left-radius: 0;
}

/* Mensajes del usuario */
.chat-message.user {
    background-color: #0d6efd;
    color: white;
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    max-width: 72%;
    border-bottom-right-radius: 6px;

}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

button:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.message-text {
    display: block;
}

.message-time {
    display: block;
    font-size: 11px;
    color: rgba(0, 0, 0, 0.5);
    margin-top: 4px;
    text-align: right;
}

/* Hora en mensajes de usuario (color claro para fondo azul) */
.chat-message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-actions button {
    background-color: transparent;
    border: none;
    color: white;
    font-size: 16px;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    position: relative;
}

.chat-actions button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.chat-actions button:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.chat-header {
    background-color: #0d6efd;
    color: white;
    padding: 12px 16px;   /* usa esta, es la más correcta */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    flex-shrink: 0;      /* CLAVE: evita que se oculte en móviles */
}

.chat-header > div {
    display: flex;
    gap: 8px;
}


.chat-box.dark-mode ::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.chat-box.dark-mode #chat-input {
  background-color: #444;
  border: 1px solid #666;
  color: white;
}

.chat-box.dark-mode .chat-body {
  scrollbar-color: #666 #222;
  scrollbar-width: thin;
  color: #fff;
  background-color: #222;
}

.chat-box.dark-mode .chat-footer {
    background-color: #2a2a2a;
}

.chat-box.dark-mode .chat-message.bot {
    background-color: #444;
    color: #fff;
}

.chat-box.dark-mode .chat-message.user {
    background-color: #0d6efd;
    color: #fff;
}

/* Botón cerrar */
.chat-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 18px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease;
}

.chat-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

.chat-close-btn:active {
    transform: scale(0.92);
}

.chat-body-close {
    position: sticky;
    top: 8px;
    float: right;
    margin-bottom: 8px;

    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;

    font-size: 16px;
    cursor: pointer;
    z-index: 5;
}

.chat-body-close:hover {
    background: rgba(0,0,0,0.25);
}


@media (min-width: 992px) {
  .chat-box {
    width: 420px;
    height: 85vh;
    max-height: 85vh;
  }
}

@media (max-width: 576px) {
    .chat-box {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        right: 1%;
        left: 1%;
        bottom: 4%;
    }
    .chat-footer {
        padding: 12px;
    }

    .chat-button {
        bottom: 10px;
    }

    body.chat-open {
        overflow: hidden; /* evita scroll duplicado al abrir chat */
    }
}

/* Reemplaza en media query para mÃ³viles */
@media (max-width: 768px) {
    .chat-box {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        right: 1%;
        left: 1%;
        bottom: 0;
    }

    .chat-footer {
        padding: 12px;
    }

    .chat-button {
        bottom: 10px;
    }

    body.chat-open {
        overflow: hidden;
    }
}

#chat-box.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 9999;
}

/* Header siempre visible */
.chat-header {
    background-color: #0d6efd;
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    flex-shrink: 0;   /* importante para que no desaparezca */
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Chat body: scrollable solo esta parte */
.chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px;
    box-sizing: border-box;
    background-color: #f9f9f9;
    padding-bottom: 45%;
}

/* Footer siempre visible */
.chat-footer {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #f1f1f1;
    flex-shrink: 0;    /* no se encoge */
    position: sticky;
    bottom: 0;
    width: 100%;
    z-index: 10;
}

/* Input dentro del footer */
#chat-form {
    display: flex;
    align-items: flex-end;
    width: 100%;
}
#chat-input {
    flex: 1;
    resize: none;
    border-radius: 20px;
    border: 1px solid #ccc;
    padding: 10px 14px;
    margin-right: 8px;
    font-size: 14px;
    max-height: 100px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Botones del footer */
.footer-buttons {
    display: flex;
    gap: 6px;
}
.footer-buttons button {
    background-color: #0d6efd;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
}
