/* =========================================
   CHATBOT FLOTANTE - MULTILIGA GOLIX
   Estilo: WhatsApp-like, colores naranja
========================================= */

/* BOTÓN FLOTANTE */
#ml-chat-btn {
    position: fixed;
    bottom: 105px; /* Justo encima del bottom-nav */
    right: 22px;
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #ff7a00, #ff9f0a);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255,122,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform 0.2s cubic-bezier(0.16,1,0.3,1);
}
#ml-chat-btn:hover { transform: scale(1.1); }
#ml-chat-btn svg { width:28px; height:28px; fill:#fff; }

/* PULSO ANIMADO */
.ml-pulse {
    position: absolute;
    width: 100%; height: 100%;
    border-radius: 50%;
    background: #ff7a00;
    z-index: -1;
    animation: mlPulse 2.2s infinite;
}
@keyframes mlPulse {
    0%   { transform:scale(1);   opacity:0.7; }
    100% { transform:scale(1.6); opacity:0;   }
}

/* BADGE NOTIFICACIÓN */
#ml-chat-badge {
    position: absolute;
    top: -4px; right: -4px;
    width: 20px; height: 20px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
}

/* CONTENEDOR PRINCIPAL */
#ml-chat-container {
    position: fixed;
    bottom: 175px;
    right: 22px;
    width: 370px;
    height: 590px;
    max-width: calc(100vw - 30px);
    max-height: calc(100vh - 200px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 60px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
}
#ml-chat-container.ml-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.65) translateY(40px);
}

/* HEADER */
#ml-chat-header {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #ff7a00;
}
.ml-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ml-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff7a00, #ff9f0a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255,122,0,0.4);
}
.ml-header-text strong { font-size:15px; font-weight:600; display:block; }
.ml-header-text small  { font-size:12px; color:#22c55e; }

#ml-close-btn {
    background: transparent; border: none;
    color: rgba(255,255,255,0.7);
    font-size: 26px; cursor: pointer; line-height: 1;
    transition: color 0.2s;
}
#ml-close-btn:hover { color: #fff; }

/* ÁREA DE MENSAJES */
#ml-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #1a1a1a;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 30px,
        rgba(255,122,0,0.02) 30px,
        rgba(255,122,0,0.02) 60px
    );
}

/* BURBUJAS */
.ml-msg {
    padding: 9px 13px;
    max-width: 82%;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
    position: relative;
    word-wrap: break-word;
}
.ml-bot-msg {
    background: #2a2a2a;
    color: #f0f0f0;
    align-self: flex-start;
    border-top-left-radius: 2px;
    border-left: 3px solid #ff7a00;
}
.ml-user-msg {
    background: linear-gradient(135deg, #ff7a00, #ff8c1a);
    color: #fff;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

/* FORMULARIO PRE-CHAT */
#ml-prechat {
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #111;
    flex: 1;
    text-align: center;
}
#ml-prechat .ml-prechat-icon { font-size: 40px; margin-bottom: 4px; }
#ml-prechat h3 { margin:0 0 4px; font-size:17px; color:#fff; font-weight:600; }
#ml-prechat p  { font-size:13px; color:#999; margin:0 0 12px; }
#ml-prechat input {
    padding: 12px 15px;
    border: 1px solid #333;
    border-radius: 10px;
    outline: none;
    font-size: 14px;
    background: #1e1e1e;
    color: #fff;
    transition: border 0.2s;
}
#ml-prechat input::placeholder { color: #666; }
#ml-prechat input:focus { border-color: #ff7a00; }
#ml-prechat-submit {
    margin-top: 6px;
    background: linear-gradient(135deg, #ff7a00, #ff9f0a);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255,122,0,0.4);
    transition: transform 0.2s;
}
#ml-prechat-submit:hover { transform: translateY(-1px); }

/* INPUT ÁREA */
#ml-input-area {
    display: flex;
    padding: 10px;
    background: #111;
    border-top: 1px solid #222;
    align-items: flex-end;
    gap: 8px;
}
#ml-input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid #333;
    border-radius: 22px;
    outline: none;
    font-size: 14px;
    background: #1e1e1e;
    color: #fff;
}
#ml-input::placeholder { color: #555; }
#ml-input:focus { border-color: #ff7a00; }

#ml-send-btn {
    background: linear-gradient(135deg, #ff7a00, #ff9f0a);
    color: #fff;
    border: none;
    width: 42px; height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
    box-shadow: 0 2px 10px rgba(255,122,0,0.4);
}
#ml-send-btn:hover { transform: scale(1.08); }
#ml-send-btn svg { width:18px; height:18px; fill:#fff; }

/* BOTÓN WHATSAPP (CTA al final) */
.ml-wa-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #25D366;
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    margin: 4px 0;
    box-shadow: 0 3px 10px rgba(37,211,102,0.3);
    transition: transform 0.2s;
    align-self: flex-start;
    max-width: 90%;
}
.ml-wa-btn:hover { transform: translateY(-2px); }
.ml-wa-btn svg { width:20px; height:20px; fill:#fff; flex-shrink:0; }

.ml-hidden-view { display: none !important; }

/* MOBILE */
@media (max-width: 480px) {
    #ml-chat-container {
        bottom: 0; right: 0; left: 0;
        width: 100%; height: 100%;
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
    }
    #ml-chat-btn { bottom: 90px; right: 16px; }
}
