.cmfb-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    isolation: isolate;
}

.cmfb-chat-widget *,
.cmfb-chat-widget *::before,
.cmfb-chat-widget *::after {
    box-sizing: border-box;
}

/* =======================================
   BOTÓN FLOTANTE
   ======================================= */
.cmfb-chat-button {
    width: 90px;
    height: 90px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #2b331f;
    color: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform .2s ease, box-shadow .2s ease;
}

.cmfb-chat-button:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .32);
}

.cmfb-chat-button-icon {
    font-size: 25px;
    line-height: 1;
}

.cmfb-chat-button.is-hidden {
    display: none;
}

.cmfb-chat-notify {
    position: absolute;
    right: -1px;
    top: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    color: #2b331f;
    border: 2px solid #2b331f;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =======================================
   PANEL DEL CHAT
   ======================================= */
.cmfb-chat-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 410px;
    height: 620px;
    max-height: calc(100vh - 105px);
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 70px rgba(15, 23, 42, .22), 0 8px 25px rgba(15, 23, 42, .10);
    display: none;
    flex-direction: column;
}

.cmfb-chat-panel.is-open {
    display: flex;
}

/* =======================================
   CABECERA
   ======================================= */
.cmfb-chat-panel-header {
    min-height: 80px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1a1f18 0%, #2b331f 65%, #3f4a2e 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid #5a6b47;
}

.cmfb-chat-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.cmfb-chat-avatar {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    border: 2px solid rgba(255, 255, 255, .20);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 20px;
}

.cmfb-chat-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.cmfb-chat-profile > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

#cmfbChatName {
    display: block;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cmfbChatSubtitle {
    display: block;
    font-size: 11px;
    line-height: 1.2;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmfb-chat-close {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease;
}

.cmfb-chat-close:hover {
    background: rgba(255, 255, 255, .25);
}

/* =======================================
   ÁREA DE MENSAJES
   ======================================= */
.cmfb-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 20px;
    background: #f8fafc;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cmfb-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.cmfb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cmfb-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.cmfb-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =======================================
   BURBUJAS DE CHAT
   ======================================= */
.cmfb-chat-message {
    width: fit-content;
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: cmfbChatMessage .25s ease-out forwards;
    margin: 0;
    position: relative;
}

.cmfb-chat-bot {
    margin-right: auto;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cmfb-chat-user {
    margin-left: auto;
    background: linear-gradient(135deg, #2b331f, #4a5c36);
    color: #ffffff;
    border: 0;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(43, 51, 31, .2);
}

/* =======================================
   IMÁGENES DEL BOT
   ======================================= */
.cmfb-chat-image {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    margin: 4px 0;
    animation: cmfbChatMessage .25s ease-out forwards;
}

.cmfb-chat-image img {
    max-width: 85%;
    max-height: 220px;
    border-radius: 12px;
    object-fit: contain;
    background: transparent;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* =======================================
   BOTONES DE OPCIONES
   ======================================= */
.cmfb-chat-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin: 4px 0 10px;
}

.cmfb-chat-option {
    width: fit-content;
    max-width: 90%;
    padding: 10px 18px;
    background: #ffffff;
    color: #2b331f;
    border: 1.5px solid #4a5c36;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all .2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.cmfb-chat-option:hover {
    background: #4a5c36;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 92, 54, 0.2);
}

.cmfb-chat-option:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* =======================================
   BOTÓN VOLVER AL MENÚ
   ======================================= */
.cmfb-chat-menu-button {
    margin: 10px auto;
    display: block;
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: #e2e8f0;
    color: #475569;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all .2s ease;
}

.cmfb-chat-menu-button:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* =======================================
   INDICADOR DE ESCRIBIENDO...
   ======================================= */
.cmfb-chat-typing {
    display: flex;
    align-items: center;
    width: fit-content;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    animation: cmfbChatMessage .2s ease-out forwards;
    margin: 0;
}

.cmfb-chat-typing span {
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background: #94a3b8;
    animation: cmfbChatTyping 1.2s infinite ease-in-out;
}

.cmfb-chat-typing span:nth-child(2) { animation-delay: .2s; }
.cmfb-chat-typing span:nth-child(3) { animation-delay: .4s; margin-right: 8px; }

.cmfb-chat-typing b {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

/* =======================================
   ESTADOS DE CARGA Y ERROR
   ======================================= */
.cmfb-chat-loading {
    margin: auto;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cmfb-chat-error {
    margin: auto;
    max-width: 80%;
    padding: 15px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    text-align: center;
    color: #b91c1c;
    font-size: 13px;
    line-height: 1.5;
}

/* =======================================
   INPUT Y BOTÓN DE ENVÍO
   ======================================= */
.cmfb-chat-input-area {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    align-items: center;
}

.cmfb-chat-input-area input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 16px;
    border: 1.5px solid #cbd5e1;
    border-radius: 24px;
    background: #f8fafc;
    color: #0f172a;
    outline: none;
    font-size: 14px;
    transition: all .2s ease;
}

.cmfb-chat-input-area input:focus {
    background: #ffffff;
    border-color: #4a5c36;
    box-shadow: 0 0 0 3px rgba(74, 92, 54, 0.1);
}

.cmfb-chat-input-area button {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2b331f, #4a5c36);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform .2s ease, box-shadow .2s ease;
}

.cmfb-chat-input-area button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(43, 51, 31, .3);
}

/* =======================================
   ANIMACIONES
   ======================================= */
@keyframes cmfbChatMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cmfbChatTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* =======================================
   RESPONSIVO
   ======================================= */
@media (max-width: 900px) {
    .cmfb-chat-panel {
        width: 380px;
        height: 600px;
    }
}

@media (max-width: 600px) {
    .cmfb-chat-widget {
        right: 16px;
        bottom: 16px;
    }
    .cmfb-chat-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 84px;
        width: auto;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        border-radius: 12px;
    }
    .cmfb-chat-panel-header {
        min-height: 70px;
        padding: 12px 16px;
    }
    .cmfb-chat-avatar {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }
    #cmfbChatName { font-size: 15px; }
    #cmfbChatSubtitle { font-size: 10px; }
    
    .cmfb-chat-messages { padding: 16px; }
    .cmfb-chat-message { max-width: 90%; font-size: 13.5px; }
    
    .cmfb-chat-input-area { padding: 12px 16px; }
    .cmfb-chat-input-area input { height: 42px; }
    .cmfb-chat-input-area button { width: 42px; height: 42px; flex-basis: 42px; }
    .cmfb-chat-button { width: 56px; height: 56px; }
}

@media (max-width: 380px) {
    .cmfb-chat-panel {
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}

.cmfb-chat-button img, .cmfb-chat-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 12px;
    }
    .cmfb-chat-avatar {
        width: 100px;
        height: 44px;
        border-radius: 12px;
        overflow: hidden;
        background: #e2e8f0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #475569;
        flex-shrink: 0;
    }
    .cmfb-chat-button {
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .cmfb-chat-options {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin: 10px 0;
    }
    .cmfb-chat-option {
        background: #f8fafc;
        border: 1.5px solid #2563eb;
        color: #1e40af;
        padding: 9px 14px;
        border-radius: 8px;
        cursor: pointer;
        font-weight: 600;
        text-align: left;
        font-size: 13.5px;
        transition: all 0.2s ease;
    }
    .cmfb-chat-option:hover {
        background: #2563eb;
        color: #ffffff;
    }