/* ==========================================================================
   BOTÓN FLOTANTE LANZADOR
   ========================================================================== */
.chatbot-launcher {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: linear-gradient(135deg, #00a88f, #16a085);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 168, 143, 0.35);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.chatbot-launcher:hover { 
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 168, 143, 0.45);
    background: linear-gradient(135deg, #00c2a5, #1bc2a1);
}

.chatbot-launcher img {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    padding: 20px; 
    transition: transform 0.3s ease;
    filter: brightness(0) invert(1); 
}

.chatbot-launcher:hover img {
    transform: scale(1.05);
}

/* ==========================================================================
   VENTANA PRINCIPAL DEL CHAT
   ========================================================================== */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 25px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background-color: #f7f9fa;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.16);
    display: none; 
    flex-direction: column;
    overflow: hidden;
    z-index: 1001; 
    font-family: 'Poppins', sans-serif;
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Encabezado del Chat */
.chatbot-header {
    background: #ffffff;
    color: #2c3e50;
    padding: 20px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid #edf1f2;
    position: relative;
}

.chatbot-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    padding-right: 35px;
    min-width: 0; 
}

.chatbot-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: #f4f7f6;
    padding: 4px;
    border: 2px solid #00a88f;
    object-fit: contain;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    flex-direction: column;
    min-width: 0; 
    flex: 1;
}

.chatbot-header-info strong {
    font-size: 15px;
    color: #1a1a1a;
    font-weight: 600;
    display: block;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

.chatbot-header-info span { 
    font-size: 12px; 
    color: #7f8c8d;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.chatbot-header-info span::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background-color: #2ecc71;
    border-radius: 50%;
}

/* Botón de cierre (X) */
.chatbot-close-btn {
    position: absolute !important;
    top: 50% !important;
    right: 20px !important;
    transform: translateY(-50%) !important;
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    color: #88929a !important;
    font-size: 22px !important; 
    font-weight: 300 !important;
    line-height: 24px !important;
    text-align: center !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s ease, transform 0.2s ease !important;
    z-index: 1002 !important;
}

.chatbot-close-btn:hover {
    color: #e53e3e !important;
    transform: translateY(-50%) scale(1.1) !important;
}

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f8fafb;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Burbujas de Mensajes */
.msg { 
    padding: 12px 16px; 
    font-size: 13.5px;
    line-height: 1.5; 
    word-wrap: break-word;
}

.msg.bot { 
    background-color: #ffffff; 
    color: #2c3e50; 
    align-self: flex-start; 
    margin-right: auto; 
    border-radius: 4px 18px 18px 18px;
    border-left: 4px solid #f1c40f; 
    max-width: 85%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.msg.user { 
    background-color: #2c3e50; 
    color: white; 
    align-self: flex-end; 
    margin-left: auto; 
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
}

/* Área de Entrada de Texto */
.chatbot-input-area {
    display: flex;
    align-items: center;
    padding: 16px;
    background: #ffffff;
    flex-shrink: 0;
    border-top: 1px solid #edf1f2;
    gap: 10px;
}

.chatbot-input-area input {
    width: 100%;
    border: 1px solid #e1e6e8;
    padding: 12px 16px;
    border-radius: 24px;
    outline: none;
    font-size: 13.5px;
    background-color: #f8fafb;
    transition: all 0.2s ease;
}

.chatbot-input-area input:focus {
    border-color: #00a88f;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(0,168,143,0.1);
}

.chatbot-send-btn {
    background-color: #00a88f;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover { background-color: #117a65; }

.chatbot-send-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ==========================================================================
   VISTA RESPONSIVA OPTIMIZADA PARA SMARTPHONES (NO PANTALLA COMPLETA)
   ========================================================================== */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 95px !important;      /* Eleva el chat para que conviva con el launcher */
        right: 15px !important;
        left: 15px !important;
        width: calc(100% - 30px) !important; /* Centrado perfecto horizontal con aire en los lados */
        height: 480px !important;     /* Altura amigable que no asfixia al usuario */
        max-height: 65vh !important;  /* Garantiza visibilidad parcial del simulador de fondo */
        border-radius: 20px !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2) !important;
    }

    .chatbot-header {
        padding: 12px 15px !important;
    }

    .chatbot-messages {
        padding: 15px !important;
        gap: 10px !important;
    }

    .msg {
        font-size: 13px !important;
        padding: 10px 14px !important;
    }

    .chatbot-input-area {
        padding: 12px !important;
    }
}