/* ==========================================================================
   RAY-Bot: Chatbot Flotante de Marinero Robot (Capitán RAY-Bot)
   Ubicación: Inferior Izquierda (Bottom-Left)
   ========================================================================== */

/* --- Contenedor Flotante Principal --- */
.raybot-floating-container {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 99999;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
}

.raybot-floating-container * {
    box-sizing: border-box;
    pointer-events: auto;
}

/* --- Botón Flotante del Marinero --- */
.raybot-trigger-btn {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
}

.raybot-trigger-btn:hover {
    transform: translateY(-4px) scale(1.08);
}

.raybot-trigger-btn:active {
    transform: scale(0.95);
}

.raybot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(0, 21, 49, 0.45));
}

/* Anillo de pulso animado */
.raybot-pulse-ring {
    display: none;
}

@keyframes raybotPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

/* Badge del ícono / Estado online */
.raybot-online-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 15px;
    height: 15px;
    background-color: #2ecc71;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px #2ecc71;
}

/* Burbuja de Saludo Flotante */
.raybot-greeting-tooltip {
    position: absolute;
    bottom: 12px;
    left: 82px;
    background: rgba(0, 21, 49, 0.95);
    backdrop-filter: blur(10px);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: raybotTooltipBounce 3s infinite ease-in-out;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.raybot-greeting-tooltip::after {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid rgba(0, 21, 49, 0.95);
}

.raybot-greeting-tooltip .close-tooltip {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 0.9rem;
    cursor: pointer;
    margin-left: 4px;
}

.raybot-greeting-tooltip .close-tooltip:hover {
    color: #ffffff;
}

@keyframes raybotTooltipBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* --- Ventana del Chat Modal --- */
.raybot-chat-window {
    position: absolute;
    bottom: 85px;
    left: 0;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 15px 50px rgba(0, 21, 49, 0.35), 0 0 0 1px rgba(0, 21, 49, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(25px) scale(0.95);
    transform-origin: bottom left;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.raybot-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Cabecera del Chat */
.raybot-header {
    background: linear-gradient(135deg, #001531 0%, #0d2847 100%);
    padding: 16px 18px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #d4af37;
    position: relative;
}

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

.raybot-header-avatar {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: transparent;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.raybot-header-text h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.raybot-status {
    font-size: 0.75rem;
    color: #2ecc71;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.raybot-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #2ecc71;
    border-radius: 50%;
    animation: raybotPulseGreen 1.5s infinite;
}

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

.raybot-header-actions {
    display: flex;
    gap: 8px;
}

.raybot-btn-icon {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.raybot-btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #d4af37;
}

/* Área de Mensajes del Chat */
.raybot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: #f6f8fb;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

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

.raybot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.raybot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Mensajes Individuales */
.raybot-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: msgFadeIn 0.3s ease-out;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.raybot-msg.bot {
    align-self: flex-start;
}

.raybot-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.raybot-msg-avatar {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    flex-shrink: 0;
}

.raybot-msg-content {
    background: #ffffff;
    padding: 12px 15px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
    font-size: 0.9rem;
    color: #2b3a4a;
    line-height: 1.5;
}

.raybot-msg.user .raybot-msg-content {
    background: #001531;
    color: #ffffff;
    border-radius: 16px;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 21, 49, 0.15);
}

.raybot-msg-content p {
    margin: 0 0 8px 0;
    color: inherit;
}

.raybot-msg-content p:last-child {
    margin-bottom: 0;
}

.raybot-msg-content strong {
    color: #001531;
    font-weight: 700;
}

.raybot-msg.user .raybot-msg-content strong {
    color: #d4af37;
}

.raybot-msg-content ul {
    margin: 6px 0 8px 16px;
    padding: 0;
    list-style-type: disc;
}

.raybot-msg-content li {
    margin-bottom: 4px;
}

/* Botón interior de cotizar o acción en el mensaje */
.raybot-msg-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 14px;
    background: #d4af37;
    color: #001531 !important;
    font-weight: 700;
    font-size: 0.82rem;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.1s ease;
    cursor: pointer;
    border: none;
}

.raybot-msg-btn:hover {
    background: #b5952f;
    transform: translateY(-1px);
}

/* --- Área de Entrada del Chat --- */
.raybot-input-area {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.raybot-input {
    flex: 1;
    padding: 11px 16px;
    border: 1.5px solid #cbd5e1;
    border-radius: 24px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.raybot-input:focus {
    border-color: #001531;
    box-shadow: 0 0 0 3px rgba(0, 21, 49, 0.1);
}

.raybot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #001531;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.raybot-send-btn:hover {
    background: #d4af37;
    color: #001531;
    transform: scale(1.05);
}

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

/* Indicador de escribiendo (Typing Dots) */
.raybot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
}

.raybot-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: raybotTypingBounce 1.4s infinite ease-in-out both;
}

.raybot-typing span:nth-child(1) { animation-delay: -0.32s; }
.raybot-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes raybotTypingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Responsivo para móviles */
@media (max-width: 480px) {
    .raybot-floating-container {
        bottom: 15px;
        left: 15px;
    }
    
    .raybot-chat-window {
        width: calc(100vw - 30px);
        height: 500px;
        bottom: 80px;
    }
    
    .raybot-greeting-tooltip {
        display: none; /* Ocultamos el tooltip en móvil para no tapar el contenido */
    }
}
