/* =============================================
   Chatbot Widget - The Unofficial Club 26
   ============================================= */

#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
}

/* Boton flotante */
#chatbot-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

#chatbot-btn-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

#chatbot-btn:hover {
    transform: scale(1.1);
}

#chatbot-btn.chatbot-btn-oculto {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Badge de notificacion */
#chatbot-btn-badge {
    display: none;
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ff3b30;
    border: 2px solid #fff;
    animation: chatbot-badge-pulse 1.5s infinite;
}

#chatbot-btn-badge.chatbot-badge-activo {
    display: block;
}

@keyframes chatbot-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes chatbot-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Burbuja de notificacion */
#chatbot-notificacion {
    position: fixed;
    bottom: 95px;
    right: 20px;
    max-width: 280px;
    background: #fff;
    color: #333;
    padding: 14px 38px 14px 18px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99998;
}

#chatbot-notificacion.chatbot-notificacion-oculto {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    visibility: hidden;
}

#chatbot-notificacion.chatbot-notificacion-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
    animation: chatbot-notif-in 0.5s ease;
}

@keyframes chatbot-notif-in {
    from { opacity: 0; transform: translateY(20px) scale(0.8); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#chatbot-notif-cerrar {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

#chatbot-notif-cerrar:hover {
    color: #333;
}

/* Ventana del chat */
#chatbot-ventana {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-ventana.chatbot-oculto {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    visibility: hidden;
}

#chatbot-ventana.chatbot-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

/* Header */
#chatbot-header {
    background: #000000;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.chatbot-avatar-sm {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-header-info strong {
    display: block;
    font-size: 15px;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

#chatbot-cerrar {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

#chatbot-cerrar:hover {
    opacity: 1;
}

/* Area de mensajes */
#chatbot-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa !important;
    color: #333 !important;
}

#chatbot-mensajes::-webkit-scrollbar {
    width: 5px;
}

#chatbot-mensajes::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chatbot-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
    animation: chatbot-fadeIn 0.3s ease;
}

.chatbot-msg-bot {
    align-self: flex-start;
}

.chatbot-msg-usuario {
    align-self: flex-end;
    flex-direction: row-reverse;
}

@keyframes chatbot-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chatbot-avatar-msg {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8f5e9;
}

.chatbot-avatar-msg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-burbuja {
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-burbuja-bot {
    background: #fff !important;
    color: #333 !important;
    border: 1px solid #e5e7eb;
    border-radius: 16px 16px 16px 4px;
}

.chatbot-burbuja-bot * {
    color: #333 !important;
}

.chatbot-burbuja-usuario {
    background: #000000 !important;
    color: #fff !important;
    border-radius: 16px 16px 4px 16px;
}

/* Input */
#chatbot-input-area {
    display: flex;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8f9fa !important;
    color: #333 !important;
}

#chatbot-input:focus {
    border-color: #000000;
    background: #fff;
}

#chatbot-enviar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #000000;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#chatbot-enviar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Opciones */
#chatbot-opciones-area {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.chatbot-opcion-btn {
    padding: 8px 18px;
    border: 2px solid #000000;
    border-radius: 24px;
    background: transparent;
    color: #000000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-opcion-btn:hover {
    background: #000000;
    color: #fff;
}

/* Typing animation */
.chatbot-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px !important;
}

.chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: chatbot-typing 1.4s infinite;
}

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

.chatbot-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatbot-typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Responsive movil */
@media (max-width: 480px) {
    #chatbot-ventana {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 10px;
        right: 10px;
        border-radius: 12px;
    }

    #chatbot-btn {
        bottom: 15px;
        right: 15px;
    }

    #chatbot-notificacion {
        right: 10px;
        bottom: 90px;
        max-width: 250px;
    }

    /* Oculto al inicio en mobile, aparece con scroll */
    #chatbot-widget {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
        transition: opacity 0.4s ease, transform 0.4s ease;
    }

    #chatbot-widget.chatbot-scroll-visible {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1);
    }
}
