/* ============================================================
   CHATBOT JEMSA — Asesora de ventas "Nina"
   ============================================================ */

/* ── Botón flotante ── */
.chatbot-toggle {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #003D7B, #0052a0);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,61,123,0.35);
    transition: all 0.3s ease;
    z-index: 999;
    border: none;
    color: white;
    font-size: 26px;
}
.chatbot-toggle:hover { 
    transform: scale(1.1); 
    box-shadow: 0 6px 28px rgba(0,61,123,0.45); 
}

/* ── Ventana ── */
.chatbot-window {
    position: fixed;
    bottom: 170px;
    right: 20px;
    width: 370px;
    max-height: 520px;
    background: #f0f2f5;
    border-radius: 18px;
    box-shadow: 0 12px 45px rgba(0,0,0,0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}
.chatbot-window.active {
    display: flex;
    animation: cbSlideUp 0.3s cubic-bezier(.22,.61,.36,1);
}
@keyframes cbSlideUp {
    from { opacity: 0; transform: translateY(22px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)  scale(1);    }
}

/* ── Header ── */
.chatbot-header {
    background: linear-gradient(135deg, #003D7B, #005299);
    color: white;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chatbot-header-info { 
    display: flex; 
    align-items: center; 
    gap: 11px; 
}
.chatbot-header-info .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border: 2px solid rgba(255,255,255,0.4);
    overflow: hidden;
}
.chatbot-header-info .avatar img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 50%; 
}
.chatbot-header-info .info h4 { 
    font-size: 0.95rem; 
    margin: 0 0 1px; 
    font-weight: 700; 
}
.chatbot-header-info .info p  {
    font-size: 0.7rem;
    margin: 0;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chatbot-header-info .info p::before {
    content: '';
    width: 7px; 
    height: 7px;
    background: #4cde80;
    border-radius: 50%;
    display: inline-block;
}
.chatbot-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    width: 28px; 
    height: 28px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: background 0.2s;
}
.chatbot-close:hover { 
    background: rgba(255,255,255,0.3); 
}

/* ── Cuerpo ── */
.chatbot-body {
    flex: 1;
    padding: 16px 14px;
    overflow-y: auto;
    max-height: 380px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chatbot-body::-webkit-scrollbar { 
    width: 3px; 
}
.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-body::-webkit-scrollbar-thumb { 
    background: #c0c8d4; 
    border-radius: 10px; 
}

/* ── Mensajes ── */
.cb-msg {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    animation: cbFade 0.25s ease;
    max-width: 100%;
}
@keyframes cbFade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}
.cb-msg-user { 
    flex-direction: row-reverse; 
}

.cb-avatar {
    width: 30px; 
    height: 30px;
    border-radius: 50%;
    background: #003D7B;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}
.cb-avatar img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 50%; 
}
.cb-avatar-user { 
    background: #d4d8e0; 
}

.cb-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.84rem;
    line-height: 1.55;
    word-wrap: break-word;
    position: relative;
}
.cb-msg-bot .cb-bubble {
    background: white;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.cb-msg-user .cb-bubble {
    background: #003D7B;
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.cb-msg-user .cb-bubble a { 
    color: #9fc3ff; 
}
.cb-msg-bot .cb-bubble a {  
    color: #003D7B; 
    font-weight: 600; 
}

/* ============================================================
   FEEDBACK SUTIL - Botones pequeños y elegantes
   ============================================================ */
.cb-feedback-container {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.65rem;
    color: #bbb;
    border-top: 1px solid #f0f0f0;
    padding-top: 6px;
}

.cb-feedback-container .fb-yes,
.cb-feedback-container .fb-no {
    background: none;
    border: 1px solid #e0e0e0;
    color: #aaa;
    border-radius: 12px;
    padding: 1px 10px;
    cursor: pointer;
    font-size: 0.6rem;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.8;
}

.cb-feedback-container .fb-yes:hover {
    border-color: #28a745;
    color: #28a745;
    background: #e8f5e9;
}

.cb-feedback-container .fb-no:hover {
    border-color: #dc3545;
    color: #dc3545;
    background: #fce4ec;
}

.cb-feedback-container .fb-yes:active,
.cb-feedback-container .fb-no:active {
    transform: scale(0.92);
}

/* Feedback - estado de agradecimiento */
.cb-feedback-container .fb-thanks {
    font-size: 0.6rem;
    color: #28a745;
}

.cb-feedback-container .fb-sorry {
    font-size: 0.6rem;
    color: #dc3545;
}

/* ── Feedback - input adicional ── */
.cb-feedback-extra {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.cb-feedback-extra input {
    flex: 1;
    padding: 4px 10px;
    border: 1px solid #eee;
    border-radius: 12px;
    font-size: 0.65rem;
    outline: none;
    font-family: inherit;
    background: #fafafa;
    transition: border-color 0.2s;
}

.cb-feedback-extra input:focus {
    border-color: #003D7B;
    background: white;
}

.cb-feedback-extra .fb-enviar {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.65rem;
    font-family: inherit;
    transition: background 0.2s;
}

.cb-feedback-extra .fb-enviar:hover {
    background: #5a6268;
}

/* ── Quick replies ── */
.cb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.cb-qr-btn {
    background: rgba(0,61,123,0.07);
    border: 1px solid rgba(0,61,123,0.22);
    color: #003D7B;
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.cb-qr-btn:hover { 
    background: #003D7B; 
    color: white; 
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,61,123,0.2);
}
.cb-qr-btn:active {
    transform: scale(0.95);
}

/* ── Typing dots ── */
.cb-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    width: fit-content;
}
.cb-typing span {
    width: 7px; 
    height: 7px;
    background: #b0b8c4;
    border-radius: 50%;
    animation: cbDot 1.3s infinite both;
}
.cb-typing span:nth-child(2) { animation-delay: 0.18s; }
.cb-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cbDot {
    0%,80%,100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* ── Footer / input ── */
.chatbot-footer {
    padding: 10px 12px;
    border-top: 1px solid #e2e5ea;
    display: flex;
    gap: 8px;
    background: white;
    flex-shrink: 0;
    align-items: center;
}
#chatbotInput {
    flex: 1;
    padding: 9px 16px;
    border: 1px solid #dde1e8;
    border-radius: 22px;
    font-size: 0.84rem;
    outline: none;
    background: #f6f7fb;
    transition: border-color 0.25s;
    font-family: inherit;
}
#chatbotInput:focus { 
    border-color: #003D7B; 
    background: white; 
}
#chatbotSend {
    width: 38px; 
    height: 38px;
    background: #003D7B;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: background 0.25s, transform 0.15s;
    flex-shrink: 0;
}
#chatbotSend:hover { 
    background: #002952; 
    transform: scale(1.08); 
}
#chatbotSend:active {
    transform: scale(0.92);
}
#chatbotSend::after { 
    content: '➤'; 
}

/* ── Responsive — móvil mejorado ── */
@media (max-width: 600px) {
    .chatbot-window {
        position: fixed;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-height: 92svh !important;
        border-radius: 22px 22px 0 0 !important;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.18) !important;
    }
    .chatbot-body {
        max-height: calc(92svh - 130px) !important;
        padding: 14px 12px;
    }
    .chatbot-toggle {
        bottom: 16px !important;
        right: 16px !important;
        width: 56px !important;
        height: 56px !important;
        font-size: 24px !important;
    }
    .chatbot-header { 
        padding: 14px 16px; 
    }
    .chatbot-header-info .info h4 { 
        font-size: 0.9rem; 
    }
    .chatbot-footer { 
        padding: 10px; 
    }
    #chatbotInput { 
        font-size: 16px; /* evita zoom en iOS */ 
    }
    .cb-bubble { 
        max-width: 88%; 
        font-size: 0.86rem; 
    }
    .cb-qr-btn { 
        font-size: 0.78rem; 
        padding: 6px 14px; 
    }
    
    /* Feedback en móvil - más táctil */
    .cb-feedback-container .fb-yes,
    .cb-feedback-container .fb-no {
        padding: 4px 14px;
        font-size: 0.7rem;
    }
}

@media (max-width: 380px) {
    .chatbot-body { 
        max-height: calc(92svh - 120px) !important; 
    }
    .cb-bubble { 
        max-width: 92%; 
    }
    .cb-feedback-container {
        flex-wrap: wrap;
    }
}

/* ── Mejora para enlaces en mensajes ── */
.cb-bubble a {
    text-decoration: none;
    border-bottom: 1px dashed rgba(0,61,123,0.3);
    transition: border-color 0.2s;
}
.cb-bubble a:hover {
    border-bottom-color: #003D7B;
}
.cb-msg-user .cb-bubble a {
    border-bottom-color: rgba(255,255,255,0.3);
}
.cb-msg-user .cb-bubble a:hover {
    border-bottom-color: white;
}

/* ── Botones de WhatsApp en mensajes ── */
.cb-bubble .wa-btn {
    display: inline-block;
    background: #25D366;
    color: white;
    padding: 8px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 8px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
}
.cb-bubble .wa-btn:hover {
    background: #1da851;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}