/* Estilos del Chat Flotante - La Terraza del Puerto */
/* Mantiene la coherencia con el diseño principal del restaurante */

/* Botón flotante del chat */
.boton-chat-flotante {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--color-secundario), #d4b882);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--sombra-fuerte);
    z-index: 1000;
    transition: var(--transicion-suave);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.boton-chat-flotante:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px rgba(201, 169, 110, 0.4);
    background: linear-gradient(135deg, #d4b882, var(--color-secundario));
}

.boton-chat-flotante.activo {
    background: var(--color-primario);
    transform: rotate(45deg);
}

/* Indicador de mensajes nuevos */
.indicador-mensajes {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #e74c3c;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    animation: pulso-notificacion 2s infinite;
}

@keyframes pulso-notificacion {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Contenedor principal del chat */
.contenedor-chat {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: var(--radio-borde);
    box-shadow: var(--sombra-fuerte);
    z-index: 1001;
    transform: translateY(100%) scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid rgba(201, 169, 110, 0.2);
    display: flex;
    flex-direction: column;
}


.contenedor-chat.abierto {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Header del chat */
.header-chat {
    background: linear-gradient(135deg, var(--color-primario), #34495e);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    flex-shrink: 0;
}

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

.avatar-chat {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-secundario);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.detalles-chat h4 {
    font-family: var(--fuente-elegante);
    font-size: 16px;
    margin-bottom: 2px;
}

.estado-chat {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.indicador-online {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: parpadeo-online 2s infinite;
}

@keyframes parpadeo-online {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.boton-cerrar-chat {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: var(--transicion-suave);
}

.boton-cerrar-chat:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Área de mensajes */
.area-mensajes {
    height: 370px;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

.area-mensajes::-webkit-scrollbar {
    width: 6px;
}

.area-mensajes::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.area-mensajes::-webkit-scrollbar-thumb {
    background: var(--color-secundario);
    border-radius: 3px;
}

/* Mensajes */
.mensaje {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 12px;
    line-height: 1.4;
    position: relative;
    animation: aparicion-mensaje 0.3s ease-out;
}

@keyframes aparicion-mensaje {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mensaje.usuario {
    background: var(--color-secundario);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.mensaje.asistente {
    background: white;
    color: var(--color-texto);
    border: 1px solid #e0e0e0;
    align-self: flex-start;
}

.mensaje.sistema {
    background: #ecf0f1;
    color: var(--color-texto-claro);
    font-style: italic;
    text-align: center;
    align-self: center;
    font-size: 12px;
    padding: 8px 12px;
}

.hora-mensaje {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.texto-mensaje {
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    word-wrap: break-word;
}

/* Estilos para contenido Markdown en mensajes */
.mensaje .titulo-mensaje {
    font-family: var(--fuente-elegante);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primario);
    margin: 8px 0 6px 0;
    line-height: 1.3;
}

.mensaje.asistente .titulo-mensaje {
    color: var(--color-acento);
}

.mensaje .lista-mensaje {
    margin: 6px 0;
    padding-left: 16px;
}

.mensaje .lista-mensaje li {
    margin: 4px 0;
    line-height: 1.4;
}

.mensaje strong {
    font-weight: 600;
    color: var(--color-primario);
}

.mensaje.asistente strong {
    color: var(--color-acento);
}

.mensaje em {
    font-style: italic;
    opacity: 0.9;
}

.mensaje a {
    color: var(--color-secundario);
    text-decoration: underline;
    transition: var(--transicion-suave);
}

.mensaje a:hover {
    color: var(--color-acento);
}

/* Indicador de escritura */
.indicador-escribiendo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border: 1px solid #e0e0e0;
    align-self: flex-start;
    max-width: 80px;
}

.puntos-escribiendo {
    display: flex;
    gap: 3px;
}

.punto-escribiendo {
    width: 6px;
    height: 6px;
    background: var(--color-secundario);
    border-radius: 50%;
    animation: escribiendo 1.5s infinite;
}

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

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

@keyframes escribiendo {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Área de entrada */
.area-entrada {
    padding: 16px 20px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.input-mensaje {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--fuente-principal);
    resize: none;
    max-height: 80px;
    min-height: 44px;
    height: 64px;
    outline: none;
    transition: var(--transicion-suave);
    line-height: 1.4;
    vertical-align: top;
}

.input-mensaje:focus {
    border-color: var(--color-secundario);
    box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.2);
}

.input-mensaje::placeholder {
    color: var(--color-texto-claro);
}

.boton-enviar {
    width: 40px;
    height: 40px;
    background: var(--color-secundario);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transicion-suave);
    font-size: 16px;
}

.boton-enviar:hover:not(:disabled) {
    background: var(--color-acento);
    transform: scale(1.05);
}

.boton-enviar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Botones de acción rápida */
.acciones-rapidas {
    display: flex;
    gap: 8px;
    padding: 0 20px 15px;
    flex-wrap: wrap;
}

.accion-rapida {
    background: white;
    border: 1px solid var(--color-secundario);
    color: var(--color-secundario);
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transicion-suave);
}

.accion-rapida:hover {
    background: var(--color-secundario);
    color: white;
}


/* Responsive - Móvil */
@media (max-width: 768px) {
    .contenedor-chat {
        width: calc(100vw - 40px);
        right: 20px;
        top: 40px;
        bottom: auto;
        height: calc(100vh - 60px);
        max-height: calc(100vh - 60px);
        z-index: 1001;
    }
    
    .boton-chat-flotante {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .contenedor-chat {
        width: calc(100vw - 30px);
        right: 15px;
        height: 450px;
        max-height: 65vh;
    }
    
    .area-mensajes {
        padding: 15px;
    }
    
    .header-chat {
        padding: 12px 15px;
    }
    
    .area-entrada {
        padding: 12px 15px 15px;
    }
    
    .acciones-rapidas {
        padding: 0 15px 10px;
        gap: 6px;
    }
    
    .accion-rapida {
        padding: 6px 8px;
        font-size: 11px;
        border-radius: 12px;
        text-align: center;
    }
    
    .mensaje {
        font-size: 14px;
        padding: 10px 14px;
        border-radius: 16px;
    }
    
    .input-mensaje {
        font-size: 14px;
        padding: 10px 14px;
        min-height: 40px;
        height: 40px;
    }
}


/* Estados de conexión */
.estado-desconectado .header-chat {
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
}

.estado-desconectado .indicador-online {
    background: #e74c3c;
    animation: none;
}

.estado-error .header-chat {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

/* Animaciones de entrada */
.chat-apareciendo {
    animation: deslizar-entrada 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes deslizar-entrada {
    from {
        transform: translateY(100%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}
