/* =========================================================================
   Estilos Corporativos Premium y Ultra-Modernos para Chatbot Flops (Flopy)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

#chatbot-flops-widget {
    --cb-bg-app: rgba(255, 255, 255, 0.75); /* Glassmorphism unificado ultra-moderno */
    --cb-bg-card: rgba(0, 0, 0, 0.03); /* Burbuja de bot minimalista */
    --cb-bg-input: rgba(255, 255, 255, 0.85);
    --cb-text-main: hsl(240, 15%, 15%); /* Texto oscuro de alta legibilidad */
    --cb-text-muted: hsl(240, 8%, 45%);
    --cb-border-soft: rgba(0, 0, 0, 0.04);
    --cb-shadow-window: 0 30px 70px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
    --cb-transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
}

/* Master Reset de SVG para evitar que Elementor/temas los oculten en escritorio */
#chatbot-flops-widget svg {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Botón Flotante (FAB) */
#chatbot-flops-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-gradient-end) 100%);
    border: none;
    outline: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px var(--cb-primary-glow-heavy);
    transition: var(--cb-transition);
    position: relative;
    padding: 0;
}

#chatbot-flops-toggle::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid var(--cb-primary);
    opacity: 0.35;
    animation: chatbot-pulse 2.2s infinite;
    pointer-events: none;
}

#chatbot-flops-toggle:hover {
    transform: scale(1.06) translateY(-2px);
    box-shadow: 0 12px 35px var(--cb-primary-glow-heavy);
}

#chatbot-flops-toggle:active {
    transform: scale(0.95) translateY(0);
}

#chatbot-flops-toggle svg {
    width: 24px !important;
    height: 24px !important;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#chatbot-flops-toggle.active svg {
    transform: rotate(90deg);
}

/* Ventana del Chat (Sleek Borderless Card) */
#chatbot-flops-container {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--cb-bg-app);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1.5px solid var(--cb-primary-glow);
    border-radius: 24px;
    box-shadow: var(--cb-shadow-window);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

/* Estado oculto */
#chatbot-flops-container.chatbot-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.88) translateY(35px);
}

/* Cabecera del Chat (Minimalista y Unificada) */
#chatbot-flops-header {
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid var(--cb-border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chatbot-avatar-container {
    position: relative;
}

.chatbot-avatar {
    width: 38px;
    height: 38px;
    background: var(--cb-primary-light);
    color: var(--cb-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid rgba(155, 28, 96, 0.08);
}

.chatbot-avatar-svg {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0;
    color: var(--cb-primary);
}

.chatbot-status-dot {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 9px;
    height: 9px;
    background-color: #10b981;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    animation: chatbot-status-pulse 1.8s infinite;
}

.chatbot-title-container {
    display: flex;
    flex-direction: column;
}

.chatbot-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--cb-text-main);
    line-height: 1.2;
    letter-spacing: -0.15px;
}

.chatbot-subtitle {
    font-size: 11px;
    color: var(--cb-text-muted);
    margin-top: 2px;
    font-weight: 500;
}

#chatbot-flops-close {
    background: transparent;
    border: none;
    color: var(--cb-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

#chatbot-flops-close:hover {
    background-color: rgba(0, 0, 0, 0.04);
    color: var(--cb-text-main);
}

#chatbot-flops-close svg {
    width: 18px !important;
    height: 18px !important;
}

/* Barra de Acciones Rápidas (Chips Minimalistas) */
#chatbot-flops-quick-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid var(--cb-border-soft);
    gap: 8px;
    z-index: 10;
}

.cb-quick-pill {
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--cb-primary-glow);
    border-radius: 12px;
    padding: 7px 10px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--cb-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--cb-transition);
    font-family: inherit;
    outline: none;
    flex: 1;
    justify-content: center;
}

.cb-quick-pill svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
    stroke: var(--cb-primary);
    transition: var(--cb-transition);
}

.cb-quick-pill:hover {
    color: white;
    background: var(--cb-primary);
    border-color: var(--cb-primary);
    transform: translateY(-1.5px);
    box-shadow: 0 4px 10px var(--cb-primary-glow);
}

.cb-quick-pill:hover svg {
    stroke: white;
}

.cb-quick-pill:active {
    transform: scale(0.97) translateY(0);
}

/* Historial de Mensajes */
#chatbot-flops-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.01) 100%);
}

/* Personalización del Scrollbar */
#chatbot-flops-messages::-webkit-scrollbar {
    width: 4px;
}

#chatbot-flops-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-flops-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
}

#chatbot-flops-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* Burbujas de Mensaje */
.chatbot-message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: chatbot-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    margin: 0 !important; /* Evitar que el tema de WP añada márgenes externos */
    padding: 0 !important;
}

.chatbot-message.bot {
    align-self: flex-start !important;
}

.chatbot-message.user {
    align-self: flex-end !important;
}

.chatbot-msg-content {
    padding: 12px 16px !important;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    font-weight: 500;
    text-align: left !important; /* Forzar alineación a la izquierda y anular centrado de tema */
    margin: 0 !important;
}

/* Reset y espaciado limpio para elementos internos del mensaje frente a overrides del tema */
.chatbot-msg-content p,
.chatbot-msg-content ul,
.chatbot-msg-content ol,
.chatbot-msg-content li {
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    text-align: left !important;
}

.chatbot-msg-content p:last-child,
.chatbot-msg-content ul:last-child,
.chatbot-msg-content ol:last-child {
    margin-bottom: 0 !important;
}

.chatbot-msg-content ul,
.chatbot-msg-content ol {
    padding-left: 20px !important; /* Restaurar el sangrado para las listas */
}

.chatbot-msg-content li {
    display: list-item !important; /* Asegurar que se renderice como lista */
    list-style-type: disc !important;
}

/* Listas parseadas dinámicamente con estética Premium */
.chatbot-msg-content ul.cb-parsed-list,
.chatbot-msg-content ol.cb-parsed-list {
    margin: 8px 0 !important;
    padding-left: 0 !important;
    list-style: none !important;
}

.chatbot-msg-content ul.cb-parsed-list li {
    position: relative;
    padding-left: 22px !important;
    margin-bottom: 6px !important;
    line-height: 1.5;
    list-style-type: none !important;
    display: block !important;
}

/* Bullet personalizado del color corporativo */
.chatbot-msg-content ul.cb-parsed-list li::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--cb-primary);
}

/* En el mensaje del usuario, los bullets son blancos para contrastar con el fondo */
.chatbot-message.user .chatbot-msg-content ul.cb-parsed-list li::before {
    background-color: rgba(255, 255, 255, 0.85);
}

.chatbot-msg-content ol.cb-parsed-list li {
    counter-increment: cb-list-counter;
    position: relative;
    padding-left: 22px !important;
    margin-bottom: 6px !important;
    line-height: 1.5;
    list-style-type: none !important;
    display: block !important;
}

.chatbot-msg-content ol.cb-parsed-list li::before {
    content: counter(cb-list-counter) ".";
    position: absolute;
    left: 2px;
    top: 0;
    color: var(--cb-primary);
    font-weight: 700;
}

/* En el mensaje del usuario, los números son blancos para contrastar con el fondo */
.chatbot-message.user .chatbot-msg-content ol.cb-parsed-list li::before {
    color: rgba(255, 255, 255, 0.85);
}

.chatbot-message.bot .chatbot-msg-content {
    background: var(--cb-bg-card);
    color: var(--cb-text-main);
    border-radius: 20px 20px 20px 6px;
    border: 1px solid var(--cb-primary-glow); /* Borde sutil del color corporativo */
}

.chatbot-message.user .chatbot-msg-content {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-gradient-end) 100%);
    color: white;
    border-radius: 20px 20px 6px 20px;
    box-shadow: 0 6px 16px var(--cb-primary-glow);
    border: 1px solid rgba(255, 255, 255, 0.08); /* Borde claro sutil */
}

.chatbot-msg-time {
    font-size: 10px;
    color: var(--cb-text-muted);
    padding: 0 4px;
    font-weight: 500;
}

.chatbot-message.bot .chatbot-msg-time {
    align-self: flex-start !important;
}

.chatbot-message.user .chatbot-msg-time {
    align-self: flex-end !important;
}

/* Enlaces automáticos (tel, mailto, urls) */
.cb-chat-link {
    color: var(--cb-primary);
    text-decoration: underline;
    font-weight: 600;
    transition: var(--cb-transition);
}

.cb-chat-link:hover {
    color: var(--cb-primary-hover);
    text-decoration: none;
}

/* Enlaces dentro de burbujas del usuario en blanco para contraste */
.chatbot-message.user .cb-chat-link {
    color: #ffffff !important;
    text-decoration: underline !important;
}

.chatbot-message.user .cb-chat-link:hover {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Escribiendo... Animación */
.chatbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--cb-bg-card);
    border-radius: 20px 20px 20px 6px;
    align-self: flex-start;
    animation: chatbot-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border: 1px solid var(--cb-primary-glow); /* Borde sutil corporativo */
}

.chatbot-typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--cb-text-muted);
    border-radius: 50%;
    animation: chatbot-bounce 1.4s infinite ease-in-out both;
}

.chatbot-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbot-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Caja de Entrada de Mensaje */
#chatbot-flops-input-container {
    padding: 16px 20px 14px;
    border-top: 1px solid var(--cb-border-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
}

.chatbot-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.03);
    border: 1.5px solid var(--cb-primary-glow);
    border-radius: 16px;
    padding: 6px 6px 6px 14px;
    width: 100%;
    transition: var(--cb-transition);
    box-sizing: border-box;
}

.chatbot-input-wrapper:focus-within {
    border-color: var(--cb-primary);
    background: white;
    box-shadow: 0 4px 18px var(--cb-primary-glow);
}

.chatbot-flops-disclaimer {
    font-size: 9px;
    color: var(--cb-text-muted);
    text-align: center;
    width: 100%;
    opacity: 0.8;
    line-height: 1.4;
    padding: 0 6px;
}

#chatbot-flops-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    padding: 8px 0 !important;
    margin: 0 !important;
    color: var(--cb-text-main);
    font-size: 14px;
    outline: none !important;
    box-shadow: none !important;
    font-weight: 500;
}

#chatbot-flops-input::placeholder {
    color: var(--cb-text-muted);
    opacity: 0.75;
}

#chatbot-flops-send {
    height: 32px;
    padding: 0 14px;
    box-sizing: border-box;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--cb-text-muted) !important;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.5;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    font-family: inherit;
}

#chatbot-flops-send.has-text {
    background: var(--cb-primary);
    color: white !important;
    cursor: pointer;
    opacity: 1;
    box-shadow: 0 2px 8px var(--cb-primary-glow);
}

#chatbot-flops-send.has-text:hover {
    background: var(--cb-primary-hover);
    transform: scale(1.03) translateY(-1px);
    box-shadow: 0 4px 12px var(--cb-primary-glow-heavy);
}

#chatbot-flops-send.has-text:active {
    transform: scale(0.97) translateY(0);
}

/* Animaciones */
@keyframes chatbot-pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.55;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
    100% {
        transform: scale(0.95);
        opacity: 0;
    }
}

@keyframes chatbot-status-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes chatbot-bounce {
    0%, 80%, 100% { 
        transform: scale(0);
    } 40% { 
        transform: scale(1.0);
    }
}

@keyframes chatbot-slide-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botones de Respuesta Rápida */
.chatbot-quick-replies {
    align-self: flex-start;
    max-width: 90%;
}

.chatbot-quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.chatbot-quick-reply-btn {
    background: #fff;
    border: 1px solid rgba(155, 28, 96, 0.12);
    color: var(--cb-primary);
    padding: 7px 16px;
    border-radius: 18px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 5px rgba(155, 28, 96, 0.03);
    font-family: inherit;
    outline: none;
}

.chatbot-quick-reply-btn:hover {
    background: var(--cb-primary);
    color: white;
    border-color: var(--cb-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px var(--cb-primary-glow);
}

.chatbot-quick-reply-btn:active {
    transform: scale(0.96);
}

/* Autocompletado y Sugerencias de FAQ */
#chatbot-autocomplete-list {
    position: absolute;
    bottom: 107px;
    left: 18px;
    right: 18px;
    background: var(--cb-bg-app);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 6px;
    animation: chatbot-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#chatbot-autocomplete-list::-webkit-scrollbar {
    width: 4px;
}

#chatbot-autocomplete-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.chatbot-autocomplete-item {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--cb-text-main);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.chatbot-autocomplete-item:hover,
.chatbot-autocomplete-item.active {
    background: var(--cb-primary-light);
    color: var(--cb-primary);
    font-weight: 600;
    transform: translateX(3px);
}

/* Botones ricos de acción dinámica en respuestas */
.chatbot-rich-btn {
    display: inline-block;
    margin-top: 10px;
    margin-right: 6px;
    background: #fff;
    border: 1px solid rgba(155, 28, 96, 0.12);
    color: var(--cb-primary);
    padding: 7px 16px;
    border-radius: 18px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 5px rgba(155, 28, 96, 0.03);
    font-family: inherit;
    outline: none;
}

.chatbot-rich-btn:hover {
    background: var(--cb-primary);
    color: #fff;
    border-color: var(--cb-primary);
    transform: translateY(-1px);
    box-shadow: 0 5px 12px var(--cb-primary-glow);
}

.chatbot-rich-btn:active {
    transform: scale(0.96);
}

/* Responsividad en Dispositivos Móviles */
@media (max-width: 480px) {
    #chatbot-flops-widget {
        bottom: 16px;
        right: 16px;
    }

    #chatbot-flops-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 72px;
        right: 0;
        border-radius: 20px;
    }
}
